diff options
| author | Nakidai <nakidai@disroot.org> | 2025-03-25 18:03:41 +0300 |
|---|---|---|
| committer | Nakidai <nakidai@disroot.org> | 2025-03-25 18:03:41 +0300 |
| commit | daec1746288490bb5ba515bb8cea3a8a3ae92b46 (patch) | |
| tree | 0879ac4657f66bedd8031ca5ca2fab8e9fcd952a /ccl.7 | |
| parent | 00b1d65b7906775ef9fecdcdf1612fc7a70b2f8d (diff) | |
| download | 3cl-daec1746288490bb5ba515bb8cea3a8a3ae92b46.tar.gz 3cl-daec1746288490bb5ba515bb8cea3a8a3ae92b46.zip | |
Add example to ccl.7 v1.0.1
Diffstat (limited to 'ccl.7')
| -rw-r--r-- | ccl.7 | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/ccl.7 b/ccl.7 index 254fe04..899b1ac 100644 --- a/ccl.7 +++ b/ccl.7 @@ -269,6 +269,32 @@ Variable with a given name must exist. .El . +.Sh EXAMPLES +This procedure +calculates nth number +of a fibonacci sequence, +accepting the parameter +and returning the result +over last cell on the stack: +.Bd -literal -offset indent +F { + / define some local variables to work with + &a &b &c + + / if the parameter is either 0 or 1, + / return with it + c? #; $c+ = c + c? #; + + / otherwise, get 2 previous numbers + / of a sequence and sum them + = c $c $c + - @F = a + -- @F = b + $a $b* +} +.Ed +. .Sh SEE ALSO .Xr ascii 7 , .Xr 3cl 1 , |