RosettaCodeData/Task/Fibonacci-sequence/Factor/fibonacci-sequence-1.factor

6 lines
202 B
Factor
Raw Permalink Normal View History

2024-10-16 18:07:41 -07:00
! produce the nth fib
: fib ( n -- fib ) 1 0 rot [ tuck + ] times drop ; inline
! produce a list of the first n fibs
: fibseq ( n -- fibs ) 1 0 rot [ [ + ] 2keep ] replicate 2nip ; inline