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



       # MATH introduce environment / hashmap structure
       # this section needs a LOT more examples :-
       # note that at the time of writing (h 1 2) is same as ((h) 1 2)
[hear] (define hash-add /
         lambda (h x y z)
          (if (equal (z) (x)) (y) (h (z))));

[hear] (define hash-ref / lambda (h x) (h (x)));

[hear] (define hash-null / ? x / undefined);

[hear] (define hash-default /
         ? default /
         ? x /
         default);

[hear] (define test-hash /
         hash-add (hash-add (hash-null) 3 2) 4 9);

[hear] (= (hash-ref (test-hash) 4) 9);

[hear] (= (hash-ref (test-hash) 3) 2);

[hear] (= (hash-ref (test-hash) 8) (undefined));

[hear] (= (hash-ref (test-hash) 15) (undefined));

[hear] (= (hash-ref (hash-add (test-hash) 15 33) 15) 33);

[hear] (= (hash-ref (test-hash) 15) (undefined));

[hear] (define make-hash /
         ? x /
         if (list= (x) (vector))
          (hash-null)
          (hash-add
            (make-hash (tail / x))
            (first /
             head /
             x)
            (second /
             head /
             x)));

[hear] (= (hash-ref
             (make-hash /
              vector (pair 3 10) (pair 2 20) (pair 1 30))
             3)
           10);

[hear] (= (hash-ref
             (make-hash /
              vector (pair 3 10) (pair 2 20) (pair 1 30))
             1)
           30);