(defun extend-env (vars vals env) (cond ((null vars) (assert (null vals) () "Too many args") env) ((atom vars) (cons (list vars vals) env)) (t (assert (rest vals) () "Too few args") (cons (list (first vars) (first vals)) (extend-env (rest vars) (rest vals) env)))))
<cl> (scheme) ==> (define test (lambda x x)) TEST ==> (test 1 2 3) (1 2 3) ==> (define test2 (lambda (x y . z) (list x y z))) TEST2 ==> (test2 1 2 3 4) (1 2 (3 4)) ==> (test2 1 2 3 4 5) (1 2 (3 4 5)) ==> (define (test3 x . y) (list x y)) TEST3 ==> (test3 1 2 3) (1 (2 3)) ==> (test3 1) Error: Too few args Restart actions (select using :continue): 0: retry assertion. 1: Return to Top Level (an "abort" restart)