diff options
| author | Nakidai <nakidai@disroot.org> | 2025-03-26 20:22:14 +0300 |
|---|---|---|
| committer | Nakidai <nakidai@disroot.org> | 2025-03-26 20:22:14 +0300 |
| commit | 6fa64679e24b2bef4aee49657df1b2f411b18392 (patch) | |
| tree | 9a0a34ec741e24dc8ee80231c71fa5baaed02f78 /examples/fib.ccl | |
| parent | ec7a100bd2b528ebc467993fc289bdbbe97dc57e (diff) | |
| download | 3cl-6fa64679e24b2bef4aee49657df1b2f411b18392.tar.gz 3cl-6fa64679e24b2bef4aee49657df1b2f411b18392.zip | |
Add examples as tests
Diffstat (limited to 'examples/fib.ccl')
| -rw-r--r-- | examples/fib.ccl | 20 |
1 files changed, 20 insertions, 0 deletions
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 |