diff options
author | Juan J. Martinez <jjm@usebox.net> | 2024-04-20 08:39:23 +0100 |
---|---|---|
committer | Juan J. Martinez <jjm@usebox.net> | 2024-04-20 08:39:23 +0100 |
commit | d17a1e3aa5565963c24e9e0b40ca4548f377a44c (patch) | |
tree | 1ae5baa7eaa0218fc62314dbce540bf1bf8611e9 /examples/fold.fco | |
parent | ecac79e7d4e83ce728b5eff2a8111f4be50b1d1e (diff) | |
download | funco-d17a1e3aa5565963c24e9e0b40ca4548f377a44c.tar.gz funco-d17a1e3aa5565963c24e9e0b40ca4548f377a44c.zip |
An example showing fold
Diffstat (limited to 'examples/fold.fco')
-rw-r--r-- | examples/fold.fco | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/examples/fold.fco b/examples/fold.fco new file mode 100644 index 0000000..ea3f5e4 --- /dev/null +++ b/examples/fold.fco @@ -0,0 +1,12 @@ +def op(acc x) + if mod(x 2) + +(acc x) + else + acc + end +end + +# add odd numbers from 1 to 10 +def main() + display(fold(0 op list(1 2 3 4 5 6 7 8 9 10))) +end |