forked from rui314/minilisp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Increase GC memory to 256 kb
- Loading branch information
Showing
5 changed files
with
149 additions
and
47 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -0,0 +1,43 @@ | ||
;(defun list (x . y) (cons x y)) | ||
|
||
;(defun list2 (a b) (cons a (cons b ()))) | ||
;(defun list3 (a b c) (cons a (cons b (cons c ())))) | ||
|
||
(defmacro cond (rest) | ||
(if (= () rest) | ||
() | ||
(if (= (car (car rest)) t) | ||
(car (cdr (car rest))) | ||
(list 'if | ||
(car (car rest)) | ||
(car (cdr (car rest))) | ||
(cond (cdr rest)))))) | ||
|
||
(defun mapc1 (fn xs) | ||
(if (= () xs) | ||
() | ||
(progn | ||
(fn (car xs)) | ||
(mapc1 fn (cdr xs))))) | ||
|
||
(defun hanoi-print (disk from to) | ||
(println (cons 'Move | ||
(cons 'disk | ||
(cons disk | ||
(cons 'from | ||
(cons from | ||
(cons 'to | ||
(cons to ()))))))))) | ||
|
||
(defun hanoi-move (n from to via) | ||
(if (= n 1) | ||
(hanoi-print n from to) | ||
(progn | ||
(hanoi-move (- n 1) from via to) | ||
(hanoi-print n from to) | ||
(hanoi-move (- n 1) via to from)))) | ||
|
||
(defun hanoi (n) | ||
(hanoi-move n 'L 'M 'R)) | ||
|
||
(hanoi 5) |
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