読者です 読者をやめる 読者になる 読者になる

Dr.Scheme(ry

(define-macro (local defs . body)
  (let* ((split-define
          (lambda (def)
            (let ((name (cadr def))
                  (body (cddr def)))
              (cond [(pair? name)
                     (cons (car name) (list (cons 'lambda (cons (cdr name) body))))]
                    [else (cons name body)]))))
         (def-pairs (map split-define defs))
         (init (map (lambda (p) (list (car p) #f)) def-pairs))
         (setup (map (lambda (p) (cons 'set! (cons (car p) (cdr p)))) def-pairs)))
    (cons 'let (cons init (append setup body)))))

良く見たら,(pair? name)(list? name)の中身がいっしょだった………orz