-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replaced the evaluator from jmc.lisp style to SICP 4.1 style to imple…
…ment lexical scope fully
- Loading branch information
TAKIZAWA Yozo
committed
Oct 27, 2020
1 parent
1832d79
commit 183fe65
Showing
9 changed files
with
204 additions
and
277 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,32 @@ | ||
(def append | ||
'(lambda (a b) | ||
(lambda (a b) | ||
(cond ((eq a nil) b) | ||
(t (append (cdr a) | ||
(cons (car a) b)))))) | ||
|
||
(def fib | ||
'(lambda (n) | ||
(lambda (n) | ||
(cond ((eq n '()) '()) | ||
((eq (cdr n) '()) '(0)) | ||
(t (append (fib (cdr n)) | ||
(fib (cdr (cdr n)))))))) | ||
|
||
(def ten '(0 0 0 0 0 0 0 0 0 0)) | ||
|
||
(cons '(fib ten) (cons '= (cons (length (fib ten)) nil))) | ||
(cons '(fib ten) (cons '= | ||
(cons (length (fib ten)) nil))) | ||
|
||
(def fib2 | ||
'(lambda (n f1 f2) | ||
(cond ((eq n '()) f1) | ||
(lambda (n f1 f2) | ||
(cond ((eq n nil) f1) | ||
(t (fib2 (cdr n) f2 (append f1 f2)))))) | ||
|
||
(def zero '()) | ||
|
||
(def one '(0)) | ||
|
||
(cons '(fib2 ten zero one) (cons '= (cons (length (fib2 ten zero one)) nil))) | ||
(cons '(fib2 ten zero one) (cons '= | ||
(cons (length (fib2 ten zero one)) nil))) | ||
|
||
exit | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters