Created
July 25, 2013 11:37
-
-
Save eccstartup/6078905 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Fibonacci sequence | |
> fibonacciList = 1:1:zipWith (+) (tail fibonacciList) fibonacciList | |
Prime number sequence | |
> primeList = 2 : let oddList = [3,5..] in filter (\n-> and $ map (\x-> rem n x /= 0) $ takeWhile (\x -> x <= floor (fromIntegral n**(0.5))) primeList) oddList | |
Binomial coefficients for each order, called Pascal's Triangle | |
> pascalTriangleList = let fetch2 = (\(m,list) -> let ls = 1:map (\n->sum $ (take 2.drop n) list) [0..floor $ fromIntegral (m-1)/2] in ls ++ (if odd m then drop 1 else id) (reverse ls)) in [1]:[1,1]: (map fetch2 $ zip [1..] $ tail pascalTriangleList) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment