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