Created
February 26, 2012 06:10
-
-
Save dtchepak/1914169 to your computer and use it in GitHub Desktop.
Playing around with take and fold
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
data TakeState a = TakeState Int a deriving (Show) | |
take' n = | |
let f (TakeState i acc) head = if i==n then (TakeState i acc) else (TakeState (i+1) (acc++[head])) | |
in foldl f (TakeState 0 []) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment