diff options
author | Juan J. Martinez <jjm@usebox.net> | 2024-04-19 20:21:56 +0100 |
---|---|---|
committer | Juan J. Martinez <jjm@usebox.net> | 2024-04-19 20:25:26 +0100 |
commit | 044360219f2e4e0b5b5a95cb7ede00753340d61d (patch) | |
tree | 4c2341a6e4941b3c3b70ca9941699e8f84353901 /examples/fact.fco | |
download | funco-044360219f2e4e0b5b5a95cb7ede00753340d61d.tar.gz funco-044360219f2e4e0b5b5a95cb7ede00753340d61d.zip |
Initial import
Diffstat (limited to 'examples/fact.fco')
-rw-r--r-- | examples/fact.fco | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/examples/fact.fco b/examples/fact.fco new file mode 100644 index 0000000..6eccca9 --- /dev/null +++ b/examples/fact.fco @@ -0,0 +1,14 @@ +# Factorial of a number +def fact(n acc) + if =(n 1) + acc + else + # tagging a tail call with "@" so it can be optimized + @fact(-(n 1) *(acc n)) + end +end + +def main() + display("Running fact(50)...") + display(fact(50. 1)) +end |