previous | index | next

Creating Arbitrarily Long Lists of Numbers

Facts about lists of the form
          (low low+1 ... high)
  1. If low > high, the list is empty,

  2. Otherwise, create it by consing low onto (low+1 ... high)
     (define integers-from-to
       (lambda (low high)
         (if (> low high)
             '()
             (cons low
                   (integers-from-to (+ 1 low) high)))))
Creating a list by repeatedly consing is called consing up a list. Now try:
          (integers-from-to 1 2000)

          (integers-from-to 13 37)

previous | index | next