This file contains hidden or 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
| module Main ( | |
| main | |
| ) where | |
| import Data.List (maximumBy) | |
| import Data.Function (on) | |
| collatz 1 = [1] | |
| collatz i = i : (if odd i then collatz $ 3*i + 1 else collatz $ i `div` 2) | |
| main = putStrLn $ show $ maximumBy (compare `on` length) $ map collatz [1..1000000] |
This file contains hidden or 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
| <?php | |
| class ImpureDatabaseWrapper { | |
| private $sql; | |
| private $pureBinding; | |
| /** | |
| * @var \Zend_Db_Select $sql | |
| * @var \Closure $pureBinding (Closure that contains "pure" code - i.e. it doesn't cause any side-effects!) | |
| */ |
This file contains hidden or 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
| -- The following holds true permuteAll [ [ 'a','b' ], [ 'c','d' ] ] => [ ['a','c'],['a','d'], ['b','c'], ['b','d'] ] | |
| permuteAll :: [[a]] -> [[a]] | |
| permuteAll [] = [] | |
| permuteAll (x:[]) = splitEvery 1 x | |
| permuteAll (x:xs) = foldr (++) [] $ map f x | |
| where | |
| f :: a -> [[a]] | |
| f x' = map ( \y -> (x':y) ) (permuteAll xs) |
This file contains hidden or 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
| -- such that the following holds true (where => indicates function output) | |
| -- splicer [ ['a', 'b'], ['c', 'd'], ['e', 'f'] ] => [ ['a', 'c', 'e'], ['b', 'd', 'f'] ] | |
| splicer :: [[a]] -> [[a]] | |
| splicer [] = [] | |
| splicer (x:[]) = splitEvery 1 x | |
| splicer (x:xs) = zipWith (:) x $ splicer xs |
NewerOlder