Section 16 Want more of a challenge? View in iconic form (experimental)
# MATH illustrate lists and some list operators # to make list describable as a function, need to preceed lists # ... with an argument count # Lists keep an explicit record of their length # this is to avoid the need for using a special 'nil' symbol # ... which cannot itself be placed in the list. # # missing - intro to cons, car, cdr # used to be pure-cons pure-car pure-cdr but changed for better interface to scheme # also should introduce number? check function # [hear] (define list-helper / ? n / ? ret / if (> (n) 1) (? x / list-helper (- (n) 1) (? y / ? z / ret (+ 1 (y)) (cons (x) (z)))) (? x / ret 1 (x)));
[hear] (define list / ? n / if (= (n) 0) (cons 0 0) (list-helper (n) (? y / ? z / cons (y) (z))));