home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Usenet 1994 January
/
usenetsourcesnewsgroupsinfomagicjanuary1994.iso
/
sources
/
unix
/
volume10
/
ifp
/
part01
/
fproot
/
demo
/
FibSeq
< prev
next >
Encoding:
Amiga
Atari
Commodore
DOS
FM Towns/JPY
Macintosh
Macintosh JP
NeXTSTEP
RISC OS
UTF-8
Wrap
Text File
|
1987-07-05
|
396 b
|
18 lines
(*
* Fibonacci numbers
*
* n : FibSeq -> sequence of first n Fibonacci numbers
*
* Example
* 6 : FibSeq -> <1 1 2 3 5 8>
*)
DEF FibSeq AS
IF [id,#2] | <= THEN
[#<1 1>,id] | takel (* trivial case *)
ELSE
sub1 | FibSeq | (* generate n-1 Fibonacci numbers *)
[id, [1r,2r]|+] | apndr (* append sum of last two to end of list *)
END;