From d17a1e3aa5565963c24e9e0b40ca4548f377a44c Mon Sep 17 00:00:00 2001 From: "Juan J. Martinez" Date: Sat, 20 Apr 2024 08:39:23 +0100 Subject: An example showing fold --- examples/fold.fco | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 examples/fold.fco 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 -- cgit v1.2.3