[ create a new paste ] login | about

Link: http://codepad.org/RV49Sitm    [ raw code | output | fork ]

uskz - Haskell, pasted on Feb 25:
1
2
3
4
5
cond p f g x = if p x then f x else g x 

take' = flip $ foldr (\x f -> (cond (>0) ((x:).f.pred) (const []))) (const [])

main = print $ take' 2 [1, 2, 3]


Output:
1
[1,2]


Create a new paste based on this one


Comments: