chickadee » sicp » apply*

apply* procedure argumentsprocedure

The SICP definition of apply; had to rename it apply*, because the redefinition of apply wrought havok on the module-system.

procedure
The procedure to apply
arguments
The arguments to which to apply it
(define (apply* procedure arguments)
  (cond ((primitive-procedure? procedure)
         (apply-primitive-procedure procedure arguments))
        ((compound-procedure? procedure)
         (eval-sequence
           (procedure-body procedure)
           (extend-environment
             (procedure-parameters procedure)
             arguments
             (procedure-environment procedure))))
        (else (error "Unknown procedure type: APPLY*" procedure))))