base-apply
(define (base-apply operator operand)
  (cond ((and (pair? operator) ; <============== primitive はここ
              (eq? (car operator) *primitive*))
         (let ((name (cadr operator)))
           (cond ((eq? name 'car)        (car (car operand)))
                 ((eq? name 'cdr)        (cdr (car operand)))
                 ((eq? name 'cadr)       (cadr (car operand)))
                 ((eq? name 'caddr)      (caddr (car operand)))
                 ((eq? name 'cadddr)     (cadddr (car operand)))
                 ((eq? name 'cons)       (cons (car operand)
                                               (cadr operand)))
                 ((eq? name 'list)       operand)
                 ...
                 (else
                  (error (list 'base-apply: 'unknown 'primitive: name))))))
        ((and (pair? operator) ; <============== lambda はここ
              (eq? (car operator) *lambda*))
         (let ((lambda-params (cadr operator))
               (lambda-body   (caddr operator))
               (lambda-env    (cadddr operator)))
           (base-eval lambda-body
                      (extend lambda-env lambda-params operand)))); 環境を拡張
        (else
         (error (list 'base-apply: 'not 'a 'function: operator)))))

一覧 前へ 次へ