aboutsummaryrefslogtreecommitdiff
path: root/examples/fold.fco
diff options
context:
space:
mode:
authorJuan J. Martinez <jjm@usebox.net>2024-05-26 21:24:41 +0100
committerJuan J. Martinez <jjm@usebox.net>2024-05-26 21:24:41 +0100
commitecb798fd7f9239cc21e89a777f5ffbaff48aabd7 (patch)
tree18c81020055ae581b18463f68755e3ed577213cc /examples/fold.fco
parent00680c131470b7f14243cdc3271fb302d8cfc4f7 (diff)
downloadfunco-ecb798fd7f9239cc21e89a777f5ffbaff48aabd7.tar.gz
funco-ecb798fd7f9239cc21e89a777f5ffbaff48aabd7.zip
Use range
Diffstat (limited to 'examples/fold.fco')
-rw-r--r--examples/fold.fco14
1 files changed, 1 insertions, 13 deletions
diff --git a/examples/fold.fco b/examples/fold.fco
index 97b6de8..44df435 100644
--- a/examples/fold.fco
+++ b/examples/fold.fco
@@ -6,19 +6,7 @@ def op(acc x)
end
end
-# generate a list with integers from 1 to n-1
-def range(n)
- def genrec(l limit n)
- if <(n limit)
- @genrec(+(l list(n)) limit +(n 1))
- else
- l
- end
- end
- genrec(list() n 0)
-end
-
# add odd numbers from 0 to 1000
def main()
- display(fold(0 op range(1001)))
+ display(fold(0 op ..(0 1000)))
end