Skip to content

Commit

Permalink
Added some prelude functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikael Bung committed May 21, 2010
2 parents 7308527 + 09e5995 commit dbd955c
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions hs/Prelude.hs
Expand Up @@ -44,6 +44,16 @@ foldr1 f xs = case xs of
[x] -> x
(x:xs) -> f x $ foldr1 f xs

foldr _ b [] = b
foldr f b (x:xs) = foldr f (f x b) xs

foldl _ b [] = b
foldl f b (x:xs) = foldl f (f b x) xs

reverse = foldl (\a b -> b:a) []

flip f a b = f b a

filter _ [] = []
filter f (x:xs ) | f x = x : filter f xs
| otherwise = filter f xs
Expand Down

0 comments on commit dbd955c

Please sign in to comment.