2010/05/31

syntax-rules: allf

便利そうだったので。
こうかなー。
;; On Lisp --- 汎変数 http://www.komaba.utmc.or.jp/~flatline/onlispjhtml/generalizedVariables.html
(use srfi-17)
(define-syntax allf
(syntax-rules ()
((_ val arg1 arg2 ...)
(let ((v val))
(set! arg1 v)
(set! arg2 v)...))))
(let ((prints (lambda args
(for-each print args))))
(let/ #f (a b c d)
(prints a b c d)
(allf #t a b c d)
(prints a b c d)))
;; #f
;; #f
;; #f
;; #f
;; #t
;; #t
;; #t
;; #t
;; #<undef>
view raw allf.scm hosted with ❤ by GitHub


On Lisp

0 件のコメント:

コメントを投稿