Y. Hanataniです。 よろしくお願いします。
(car (1 2))
がだめなのに、
(quote (1 2))
がいいのは、quoteでは引数が評価されていないから? =>quoteはSpecial FormだけどcarはFunction。Functionはとりあえず引数をeagerに評価してしまうから。(であってるのだろうか)
gosh> (car '((+ 1 2) 4)) (+ 1 2) gosh> (car `(,(+ 1 2) 4)) 3
gosh> (define-class <foo> () ((bar :accessor bar-of :init-keyword :bar :init-value "baz"))) <foo> gosh> (define instance (make <foo>)) instance gosh> (bar-of instance) "baz" gosh> (define-class hoge () ()) hoge
クラス名に<...>を使うのはただの慣習で、言語仕様とは全く関係ないみたい。
(2003/06/04 18:53:26 PDT)
何となくSchemeっぽいcat
(define cat (lambda (port) (let ((str (read-line port))) (if (not (eof-object? str)) (begin (display str) (newline) (cat port)))))) (if (null? *argv*) (exit) (let ((input-file (car *argv*))) (call-with-input-file input-file cat)))
(2003/06/12 23:37:27 PDT)
算譜の記の(リンク先の)問題より。 mapAccmuRの抽象度が高すぎて今一つかめていないのだが、こんな感じでいいのかな。
(define (xzip xs ys) (define (xzip* xs ys) (if (null? xs) (values ys '()) (receive (ys* zs) (xzip* (cdr xs) ys) (values (cdr ys*) (cons (list (car xs) (car ys*)) zs))))) (receive (ys* zs) (xzip* xs ys) zs)) (display (xzip '(1 2 3) '(4 5 6))) (newline)
(2003/06/21 00:11:10 PDT)