diff options
author | Camil Staps | 2016-09-24 15:01:04 +0200 |
---|---|---|
committer | Camil Staps | 2016-09-24 15:01:04 +0200 |
commit | babe62b2320dc7a937ef30437b59c7b7e73f3c37 (patch) | |
tree | e557dc908aa95c5f7984fb3aa88d134fea898b07 /examples/fold.fusp | |
parent | cleanup (diff) |
Added examples
Diffstat (limited to 'examples/fold.fusp')
-rw-r--r-- | examples/fold.fusp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/examples/fold.fusp b/examples/fold.fusp new file mode 100644 index 0000000..0d38cdc --- /dev/null +++ b/examples/fold.fusp @@ -0,0 +1,14 @@ +mul a b = code mul a b; +sub a b = code sub a b; + +foldr op r [] = r; +foldr op r [a:x] = op a (foldr op r x); + +prod = foldr mul 1; + +faclist 0 = []; +faclist n = [n:faclist (sub 1 n)]; + +fac n = prod (faclist n); + +main = fac 12; |