anchor.diff:      xs))
   
   (defun pop-last! (xs)
  -  "Mutate the list XS, removing and returning its last element."
  +  "Mutate the list XS, removing and returning its last element.
  +
  +   Example:
  +   ```
  +   > (define list '(1 2 3))
  +   > (pop-last! list)
  +   3
  +   > list
  +   '(1 2)
  +   ``` "
     (assert-type! xs list)
     (set-idx! xs (# xs) nil)
     (set-idx! xs "n" (- (# xs) 1))
     xs)
   
   (defun remove-nth! (li idx)
  -  "Mutate the list LI, removing the value at IDX and returning it."
  +  "Mutate the list LI, removing the value at IDX and returning it.
  +
  +   Example:
  +   ```
  +   > (define list '(1 2 3))
  +   > (remove-nth! list 2)
  +   2
  +   > list
  +   > '(1 3) 
  +   ``` "
     (assert-type! li list)
     (set-idx! li "n" (- (get-idx li "n") 1))
     (lua/table/remove li idx))
   
   (defmacro for-each (var lst &body)
  -  "Perform the set of actions BODY for all values in LST, binding the current value to VAR."
  +  "Perform the set of actions BODY for all values in LST, binding the current value to VAR.
  +  
  +   Example:
  +   ```
  +   > (for-each var '(1 2 3)\
  +       (print! var))
  +   1
  +   2
  +   3
  +   nil
  +   ```"
     (assert-type! var symbol)
     (let* [(ctr' (gensym))
            (lst' (gensym))]
  
positive.code:        (for ,ctr' 1 (# ,lst') 1 (with (,var (get-idx ,lst' ,ctr')) ,@body)))))
  
  (defun append (xs ys)
    "Concatenate XS and YS."
    (cond
      [(nil? xs) ys]
      [true (cons (car xs) (append (cdr xs) ys))]))
  
  (defun flatten (xss)
    "Concatenate all the lists in XSS. XSS must not contain elements which
     are not lists."
    (foldr append '() xss))
  
  (defun range (start end acc)
    "Build a list from START to END. This function is tail recursive, and
     uses the parameter ACC as an accumulator."
    (cond
      [(! (exists? acc)) (range start end '())]
      [(>= start end) (reverse (cons start acc))]
      [true (range (+ 1 start) end (cons start acc))]))
  
  (defun reverse (xs acc)
    "Reverse the list XS, using the accumulator ACC."
    (cond
      [(! (exists? acc)) (reverse xs '())]
      [(nil? xs) acc]
      [true (reverse (cdr xs) (cons (car xs) acc))]))
  
  (defun accumulate-with (f ac z xs)
    "A composition of foldr and map.
     Transform the values of XS using the function F, then accumulate them
     starting form Z using the function AC."
    (assert-type! f function)
    (assert-type! ac function)
    (foldr ac z (map f xs)))
  
negative.code: "List manipulation functions.
   These include several often-used functions for manipulation of lists,
   including functional programming classics such as [[map]] and [[foldr]]
   and useful patterns such as [[accumulate-with]].
  
   Most of these functions are tail-recursive unless noted, which means they
   will not blow up the stack. Along with the property of tail-recursiveness,
   these functions also have favourable performance characteristics.
  
   Glossary:
   - **Constant time** The function runs in the same time regardless of the
     size of the input list.
   - **Linear time** The runtime of the function is a linear function of the
     size of the input list.
   - **Logarithmic time** The runtime of the function grows logarithmically
     in proportion to the size of the input list.
   - **Exponential time** The runtime of the function grows exponentially in
     proportion to the size of the input list. This is generally a bad thing."
  
  (import base (defun defmacro when let* set-idx!
                get-idx cons for gensym -or
                pretty print error tostring  -and
                unpack debug if # + - >= = ! with))
  (import base)
  (import lua/table)
  (import type (list? nil? assert-type! exists? falsey?))
  
  (defun car (x)
    "Return the first element present in the list X. This function operates
     in constant time.
     
     Example:
     ```
     > (car '(1 2 3))
     1
     ```"
    (assert-type! x list)
    (base/car x))
  
  (defun cdr (x)
    "Return the list X without the first element present. In the case that
     X is nil, the empty list is returned. Due to the way lists are represented
     internally, this function runs in linear time.
     
     Example:
     ```
     > (cdr '(1 2 3))
     '(2 3)
     ```"
    (assert-type! x list)
    (if (nil? x)
      '()
      (base/cdr x)))
  
  (defun snoc (xss &xs)
    "Return a copy of the list XS with the element XS added to its end.
     This function runs in linear time over the two input lists: That is,
     it runs in O(n+k) time proportional both to `(# XSS)` and `(# XS)`.
  
     Example:
     ```
     > (snoc '(1 2 3) 4 5 6)
     '(1 2 3 4 5 6)
     ``` "
    `(,@xss ,@xs))
  
  (defun foldr (f z xs)
    "Accumulate the list XS using the binary function F and the zero element Z.
     This function is also called `reduce` by some authors. One can visualise
     (foldr f z xs) as replacing the [[cons]] operator in building lists with F,
     and the empty list with Z.
  
     Consider:
     - `'(1 2 3)` is equivalent to `(cons 1 (cons 2 (cons 3 '())))`
     - `(foldr + 0 '(1 2 3))` is equivalent to `(+ 1 (+ 2 (+ 3 0)))`.
     
     Example:
     ```
     > (foldr append '() '((1 2) (3 4)))
     ; equivalent to (append '(1 2) (append '(3 4) '()))
     '(1 2 3 4)
     ```"
    (assert-type! f function)
    (assert-type! xs list)
    (let* [(accum z)]
      (for i 1 (# xs) 1
        (set! accum (f accum (nth xs i))))
      accum))
  
  (defun map (f xs acc)
    "Apply the function F to every element of the list XS, collecting the
     results in a new list.
     
     Example:
     ```
     > (map succ '(0 1 2))
     '(1 2 3)
     ```"
    (assert-type! f function)
    (assert-type! xs list)
    (cond
  