apl-meta - ; apl-meta.scm APL version of metacircular...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
;;; apl-meta.scm APL version of metacircular evaluator. ;;; SETTING UP THE ENVIRONMENT ;;; APL primitives aren't part of the environment. They are not subject ;;; to redefinition, for example. They are kept in a separate list. So ;;; the initial environment is empty. But define! only works if there is ;;; a non-empty environment, so we fake something. (define the-global-environment '()) ;;; INITIALIZATION AND DRIVER LOOP ;;; The following code initializes the machine and starts the APL ;;; system. You should not call it very often, because it will clobber ;;; the global environment, and you will lose any definitions you have ;;; accumulated. (define (initialize-apl) (set! the-global-environment (extend-environment '(no-name) '(no-value) '())) (set! apl-operators (list (make-scalar-op '+ (lambda (x) x) +) (make-scalar-op '- - -) (make-scalar-op '* (lambda (x) (cond ((< x 0) -1) ((= x 0) 0) (else 1))) *) (make-scalar-op '% / /) (make-scalar-op 'bar abs rem) (make-scalar-op '= error (apl-pred2 =)) (make-scalar-op '< error (apl-pred2 <)) (make-scalar-op '> error (apl-pred2 >)) (make-op '/ error compress) (make-op 'iota iota error) (make-op 'rho shape reshape) (make-op 'comma ravel cat) (make-op 'gets error 'set!))) (apl-loop)) ;;; APPLYING PRIMITIVE PROCEDURES ;;; The mechanism for applying primitive procedures is somewhat ;;; different from the one given in the course notes. We can recognize ;;; primitive procedures (which are all inherited from Scheme) by asking ;;; Scheme if the object we have is a Scheme procedure. (define (primitive-procedure? p)
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 11/30/2010 for the course EECS 21281 taught by Professor Harvey during the Spring '10 term at Berkeley.

Page1 / 5

apl-meta - ; apl-meta.scm APL version of metacircular...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online