title: Explanation of Racket function using map, append, and a recursive call
body: <p>This procedure takes a non-negative integer n and creates a list of all lists of n 0's or 1's in the specific order required for a truth table. I am just trying to understand how the map portion of the procedure works. I am particularly confused as to how append, map, and the recursive call to all-lists are working together in the second argument of the if. Any help would be greatly greatly appreciated! </p>
  
  <pre><code>(define all-lists
    (lambda (n)
      (if (= n 0)
        '(())
        (append (map (lambda (k) (cons 0 k)) (all-lists (- n 1)))
                (map (lambda (k) (cons 1 k)) (all-lists (- n 1)))
                ))))
  </code></pre>