summaryrefslogtreecommitdiff
path: root/tests/fiboY.lisp
blob: d12a5ab52b292bf0fe5b543b8a001ea1973eca08 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
(define cadr (l) (car (cdr l)))
(define caddr (l) (car (cdr (cdr l))))

(define YY (recur) (lambda (f) (lambda (a) (f ((recur recur) f) a))))
(define Y (YY YY))

(define forX (recur low_high_func)
	(if (<= (car low_high_func) (cadr low_high_func))
		(do
			((caddr low_high_func) (car low_high_func))
			(recur (list (+ (car low_high_func) 1) (cadr low_high_func) (caddr low_high_func))))
		'()))

(define for (Y forX))

(define fibohelperX (recur n_a_b)
	(if (<= (car n_a_b) 0) (cadr n_a_b)
		(recur (list (- (car n_a_b) 1) (caddr n_a_b) (+ (cadr n_a_b) (caddr n_a_b))))))

(define fibohelper (Y fibohelperX))

(define fibo (n) (fibohelper (list n 0 1)))

(for (list 1 25 (lambda (n) (print (fibo n)))))