Section 17
Want more of a challenge? View in iconic form (experimental)



       # HACK describe changes to the implicit interpreter to allow new special forms
[hear] (define base-translate / translate);

[hear] (define translate /
         ? x /
         if (= (x) 10) 15 (base-translate / x));

[hear] (= 10 15);

[hear] (= (+ 10 15) 30);

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

[hear] (not / = 10 15);

[hear] (= (+ 10 15) 25);

       # now can create a special form for lists
[hear] (define translate /
         ? x /
         if (number? /
           x)
          (base-translate /
           x)
          (if (= (head / x) vector)
            (translate /
             prepend
              ((list 2) list (list-length / tail / x))
              (tail /
               x))
            (base-translate /
             x)));

[hear] (= (vector 1 2 3) ((list 3) 1 2 3));

       # now to desugar let expressions
[hear] (define translate-with-vector / translate);

[hear] (define translate-let-form /
         ? x /
         ? body /
         if (= (list-length / x) 0)
          (translate /
           body)
          (translate-let-form
            (tail /
             x)
            (vector
              (vector ? (head / head / x) (body))
              (head /
               tail /
               head /
               x))));

[hear] (define translate /
         ? x /
         if (number? /
           x)
          (translate-with-vector /
           x)
          (if (= (head / x) let)
            (translate-let-form
              (head /
               tail /
               x)
              (head /
               tail /
               tail /
               x))
            (translate-with-vector /
             x)));

[hear] (let ((x 20)) (= (x) 20));

[hear] (let ((x 50) (y 20)) (= (- (x) (y)) 30));

       # the is-list function is now on dubious ground
       # this stuff will be replaced with typing ASAP
[hear] (define is-list /
         ? x /
         not /
         number? /
         x);

[hear] (is-list / (list 2) 1 3);

[hear] (is-list / (list 0));

[hear] (not / is-list 23);

[hear] (is-list /
         (list 3) ((list 2) 2 3) 1 (? x / + (x) 10));