finish fibonacci example

main
Clyne 4 months ago
parent c278aa4e69
commit d832f781db
Signed by: clyne
GPG Key ID: 1B74EE6C49C96795

@ -10,7 +10,7 @@
(nil eq) $null? (nil eq) $null?
($x x) $force ($x x) $force
(10 emit) $cr (10 emit) $cr
(dup car swap cdr) $carcdr (print) $print
; if-stmt ; if-stmt
($c $t $f c ^f ^t rot cswap $_ force) $if ($c $t $f c ^f ^t rot cswap $_ force) $if
@ -24,13 +24,25 @@
endif endif
) $range ) $range
($self $func $list ; map [$fn $list -> $out-list]
($self $fn $list
^if (^list null?) ^if (^list null?)
nil ^nil
(^list carcdr swap func ^func self) (^list car fn ^list cdr ^fn self swap cons)
endif endif
) $foreach ) $map
; each [$fn $list]
($fn (fn ^nil) map drop) $each
; implementation
(0 1 ($self $a $b $n
^if (^n 0 eq) (^b) (
^n 1 - ^a ^b + ^b self
) endif
) force) $fibonacci
58 48 range 10 1 range
^emit foreach cr ^fibonacci map
^print each
) )

Loading…
Cancel
Save