Permalink
Browse files

Added reverse function to Generic.Data.List.

  • Loading branch information...
1 parent ba5261f commit 229ee98fdcfbfc28e3fe12f4e73be4a9a7def9e7 @tomlokhorst committed Feb 8, 2010
Showing with 5 additions and 0 deletions.
  1. +5 −0 src/Generic/Data/List.hs
View
@@ -52,3 +52,8 @@ sum = foldr (+) 0
filter :: (ListC j, BoolC j, FunC j) => (j a -> j Bool) -> j [a] -> j [a]
filter p = foldr (\x xs -> bool xs (x `cons` xs) (p x)) nil
+reverse :: (FunC j, ListC j) => j [a] -> j [a]
+reverse l = rev `app` l `app` nil
+ where
+ rev = fix (\r -> lam (\xs -> lam (\a -> list a (\y ys -> r `app` ys `app` (y `cons` a)) xs)))
+

0 comments on commit 229ee98

Please sign in to comment.