feat: 9.5.9
This commit is contained in:
parent
cb1753732b
commit
35f43a7909
1084 changed files with 558985 additions and 0 deletions
19
examples/fatfib.ss
Normal file
19
examples/fatfib.ss
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
;;; fat fibonacci function
|
||||
|
||||
;;; this is "fat" because it uses only increments and decrements
|
||||
;;; for addition and subtraction (i.e., peano arithmetic).
|
||||
|
||||
;;; note that fat+ is tail-recursive; this is how all looping is
|
||||
;;; performed in Scheme.
|
||||
|
||||
(define fat+
|
||||
(lambda (x y)
|
||||
(if (zero? y)
|
||||
x
|
||||
(fat+ (1+ x) (1- y)))))
|
||||
|
||||
(define fatfib
|
||||
(lambda (x)
|
||||
(if (< x 2)
|
||||
1
|
||||
(fat+ (fatfib (1- x)) (fatfib (1- (1- x)))))))
|
||||
Reference in a new issue