From 6fa64679e24b2bef4aee49657df1b2f411b18392 Mon Sep 17 00:00:00 2001 From: Nakidai Date: Wed, 26 Mar 2025 20:22:14 +0300 Subject: Add examples as tests --- examples/fib.ccl | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 examples/fib.ccl (limited to 'examples/fib.ccl') diff --git a/examples/fib.ccl b/examples/fib.ccl new file mode 100644 index 0000000..1a2ae68 --- /dev/null +++ b/examples/fib.ccl @@ -0,0 +1,20 @@ +/ Takes an index in the fibonacci sequence on the stack +/ Returns a number of the fibonacci sequence with a given index +F { + / Let us define some local variables + &a &b &c + + / If index is zero or one then we just return the number + ?c #; $c+ = c + ?c #; + + / Otherwise we get previous two numbers of the sequence + / and return their sum + = c $c $c + - @F = a + -- @F = b + $a $b* +} + +^+++++++++++++++++++++++=t$t +$t@F -- cgit 1.4.1