This gist is part of a blog post. Check it out at:
http://jasonrudolph.com/blog/2011/08/09/programming-achievements-how-to-level-up-as-a-developer
-- http://csokavar.hu/blog/2010/04/20/problem-of-the-week-9-digit-problem/ | |
import Data.List (delete) | |
main :: IO () | |
main = print $ solve 0 1 [1..9] | |
solve :: Integral a => a -> a -> [a] -> [a] | |
solve curr _ [] = [curr] | |
solve curr divisor possibilities = concatMap solveFor possibilities |
This gist is part of a blog post. Check it out at:
http://jasonrudolph.com/blog/2011/08/09/programming-achievements-how-to-level-up-as-a-developer
{- | |
- This is a simple type-safe concatenative (stack-based) language | |
- implemented as an embedded DSL in Haskell. It's based on the ideas presented in | |
- | |
- http://www.codecommit.com/blog/cat/the-joy-of-concatenative-languages-part-1 | |
- -"- 2 | |
- -"- 3 | |
- | |
- MIT License, Tim Baumann | |
-} |
<!doctype html> | |
<html> | |
<head> | |
<meta charset="utf-8" /> | |
<title>Proper with YUI – Test</title> | |
</head> | |
<body> | |
<p id="buttons"> |
// I'm developing this now as a part of substance (https://github.com/michael/substance) | |
{ | |
"a":{ | |
href: function(href) { | |
// accepts only absolute http, https and ftp URLs and email-addresses | |
return /^(mailto:|(https?|ftp):\/\/)/.test(href); | |
} | |
}, | |
"strong": {}, | |
"em": {}, | |
"b": {}, |
<!doctype html> | |
<html> | |
<head> | |
<title>Erstes Beispiel</title> | |
<style> | |
body { | |
background: rgb(200, 200, 0); | |
font-size: 100px; | |
font-family: sans-serif; | |
} |
-- https://www.ai-class.com/course/video/quizquestion/127 | |
module LinearRegression where | |
computeLR :: [(Double, Double)] -> (Double, Double) | |
computeLR vs = (w0, w1) | |
where w1 = enum / denom | |
enum = m * (sum $ zipWith (*) xs ys) - (sum xs) * (sum ys) | |
denom = m * (sum . map (^2) $ xs) - (sum xs)^2 | |
w0 = (sum ys - w1 * sum xs) / m |
-- Extended Euclidean algorithm | |
-- Preconditions: gcd(a, b) = 1, a > b | |
-- Postcondition: (fst result) * a + (snd result) * b = 1 | |
euc :: (Integral a) => a -> a -> (a, a) | |
euc a b = case b of | |
1 -> (0, 1) | |
_ -> let (e, f) = euc b d | |
in (f, e - c*f) | |
where c = a `div` b |
-- https://www.ai-class.com/course/video/quizquestion/285 | |
data State = S { x :: Double | |
, y :: Double | |
, theta :: Double | |
, v :: Double | |
, omega :: Double | |
, dt :: Double | |
} deriving (Show) |