program. Scheme工程复用的值与异常案例[mce-project-cases]

Defines: (examples errors)

Assembled in Scheme工程核验模块

Outputs: lp-example/mce/checks.scm

(define examples
  '((factorial
     ((define (factorial n) (if (= n 0) 1 (* n (factorial (- n 1)))))
      (factorial 6))
     720)
    (lexical
     ((define x 10)
      (define add-x (lambda (y) (+ x y)))
      ((lambda (x) (add-x 2)) 100))
     12)
    (closure
     ((define (make-adder x) (lambda (y) (+ x y)))
      (define add-three (make-adder 3))
      (add-three 4))
     7)
    (lazy-if ((if #t 7 missing)) 7)
    (truth ((if 0 1 2)) 1)
    (mapping ((map (lambda (x) (* x x)) '(1 2 3 4))) (1 4 9 16))
    (application ((apply + '(1 2 3))) 6)
    (named-let
     ((let loop ((n 5) (total 0))
        (if (= n 0) total (loop (- n 1) (+ total n)))))
     15)
    (let-star ((let* ((x 3) (y (+ x 4))) (* x y))) 21)
    (short-circuit ((list (and #f missing) (or 9 missing))) (#f 9))
    (conditional ((cond ((= 1 2) missing) ((= 2 2) 8) (else 0))) 8)))


(define errors
  '((missing (missing) mce-unbound)
    (arity (((lambda (x) x) 1 2)) mce-arity)
    (call ((1 2)) mce-not-procedure)
    (syntax ((if #t 1)) mce-syntax)
    (parameters ((lambda (x x) x)) mce-syntax)))