# MATH build up functions of several variables
[hear] (= ((? x / ? y / - (x) (y)) 4 0) 4);

[hear] (= ((? x / ? y / - (x) (y)) 11 8) 3);

[hear] (= ((? x / ? y / - (x) (y)) 5 5) 0);

[hear] (= ((? x / ? y / - (x) (y)) 10 1) 9);

[hear] (= ((? x / ? y / - (x) (y)) 10 7) 3);

[hear] (define last /
         ? x /
         list-ref (x) (- (list-length / x) 1));

[hear] (define except-last /
         ? x /
         if (> (list-length / x) 1)
          (prepend
            (head /
             x)
            (except-last /
             tail /
             x))
          (vector));

       # test last and except-last
[hear] (= 15 (last / vector 4 5 15));

[hear] (list= (vector 4 5)
               (except-last /
                vector 4 5 15));

[hear] (intro lambda);

[hear] (define prev-translate / translate);

[hear] (define translate /
         let ((prev (prev-translate)))
          (? x /
           if (number? /
             x)
            (prev /
             x)
            (if (= (head / x) lambda)
              (let ((formals (head / tail / x))
                    (body (head / tail / tail / x)))
                (if (> (list-length / formals) 0)
                  (translate
                    (vector
                      lambda
                      (except-last /
                       formals)
                      (vector ? (last / formals) (body))))
                  (translate (body))))
              (prev /
               x))));

       # test lambda
[hear] (= ((lambda (x y) (- (x) (y))) 8 3) 5);

[hear] (= ((lambda (x y) (- (x) (y))) 1 1) 0);

[hear] (= ((lambda (x y) (- (x) (y))) 10 9) 1);

[hear] (= ((lambda (x y) (- (x) (y))) 7 5) 2);

[hear] (= ((lambda (x y) (- (x) (y))) 9 8) 1);

[hear] (define apply /
         lambda (x y)
          (if (list= (y) (vector))
            (x)
            (apply ((x) (head / y)) (tail / y))));

[hear] (= (apply (lambda (x y) (- (x) (y))) (vector 8 6))
           2);

[hear] (= (apply (lambda (x y) (- (x) (y))) (vector 5 0))
           5);

[hear] (= (apply (lambda (x y) (- (x) (y))) (vector 12 9))
           3);

[hear] (= (apply (lambda (x y) (- (x) (y))) (vector 13 8))
           5);

[hear] (= (apply (lambda (x y) (- (x) (y))) (vector 11 3))
           8);