From 044360219f2e4e0b5b5a95cb7ede00753340d61d Mon Sep 17 00:00:00 2001 From: "Juan J. Martinez" Date: Fri, 19 Apr 2024 20:21:56 +0100 Subject: Initial import --- examples/fact.fco | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 examples/fact.fco (limited to 'examples/fact.fco') 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 -- cgit v1.2.3