Permalink
Browse files

Added some prelude functions

  • Loading branch information...
2 parents 7308527 + 09e5995 commit dbd955c6ebd1f74a36c8dd34e7ebe704e219dde1 Mikael Bung committed May 21, 2010
Showing with 10 additions and 0 deletions.
  1. +10 −0 hs/Prelude.hs
View
@@ -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

0 comments on commit dbd955c

Please sign in to comment.