Browse files

Added unfoldn and foldn conversion generators.

  • Loading branch information...
1 parent e36cf61 commit 31d84832cd129ac1b06c75c73169a38d8a259d35 @luqui committed Jun 19, 2009
Showing with 11 additions and 1 deletion.
  1. +11 −1 ixi/IXi/Helpers.hs
View
12 ixi/IXi/Helpers.hs
@@ -1,5 +1,6 @@
module IXi.Helpers
- ( convNF, convInverseNF, convEquiv, convInverseBeta )
+ ( convNF, convInverseNF, convEquiv, convInverseBeta
+ , unfoldn, foldn )
where
import IXi.Term
@@ -70,3 +71,12 @@ convInverseBeta _ = error "convInverseBeta not given a lambda argument"
unfoldn :: Int -> Conversion
unfoldn n = mconcat . reverse . take n $ iterate convInAppL convBetaReduce
+
+foldn :: Int -> Term -> Conversion
+foldn n = mconcat . zipWith ($) appLs . reverse . bodies n
+ where
+ appLs = iterate (convInAppL .) convInverseBeta
+
+ bodies 0 _ = []
+ bodies n t@(Lambda t') = t : bodies (n-1) t'
+ bodies n _ = error "foldn not given n nested lambdas"

0 comments on commit 31d8483

Please sign in to comment.