Created
June 5, 2013 15:02
-
-
Save moratori/5714545 to your computer and use it in GitHub Desktop.
simple read macro
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
;; Lisp のリーダは括弧の始まりを読むと閉じ括弧までを読む | |
;; ( から ) まで | |
;; 今それと同じ機能を [] にも 持たせる | |
;; まず閉じる目印になる括弧を設定 | |
;; こいつは ) と同じ機能 | |
(set-macro-character #\] (get-macro-character #\))) | |
;; 開き括弧に会ったら、閉じ括弧まで読む | |
(set-macro-character #\[ | |
(lambda (stream char) | |
(declare (ignore char)) | |
(read-delimited-list #\] stream t))) | |
[defun fact [n] | |
[cond | |
[[zerop n] 1] | |
[t [* n [fact [1- n]]]]]] | |
[print [fact 5]] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment