anchor.diff:  
   (defun permutations (list)
     "Generate all the different permutations of LIST, accounting for reoccurring terms."
  -  (
  +  (if list
  +      (mapcar (lambda (item)
  +                (mapcar (lambda (perm) (cons item perm))
  +                        (permutations (remove-item item list))))
  +              (remove-duplicates list))
  +      (list NIL)))
  +      
  +(defun remove-item (item list)
  +  "Remove all instances of ITEM from LIST."
  +  (when list
  +    (if (eq item (car list))
  +        (remove-item (cdr list))
  +        (cons (car list)
  +              (remove-item (cdr list))))))
  +
  +(defun remove-duplicates (list)
  +  "Remove all duplicate elements from LIST."
  +  (when list
  +    (cons (car list)
  +          (remove-duplicates 
  +            (remove-item (car list) (cdr list))))))
  +
  +;;; p28
  +
  +(defun lsort (list)
  +  "Sorting a list of lists according to length of sublists
  +a) We suppose that a list contains elements that are lists themselves. 
  +The objective is to sort the elements of this list according to their length. 
  +E.g. short lists first, longer lists later, or vice versa.
  +
  +Example:
  +* (lsort '((a b c) (d e) (f g h) (d e) (i j k l) (m n) (o)))
  +((O) (D E) (D E) (M N) (A B C) (F G H) (I J K L))"
  +  (sort list (lambda (s1 s2) (< (length s1) (length s2)))))
  +      
  +(defun lfsort (list)
  +  "b) Again, we suppose that a list contains elements that are lists themselves. 
  +  But this time the objective is to sort the elements of this list according to their length frequency;
  +  i.e., in the default, where sorting is done ascendingly, lists with rare lengths are placed first, 
  +  others with a more frequent length come later.
  +
  +Example:
  +* (lfsort '((a b c) (d e) (f g h) (d e) (i j k l) (m n) (o)))
  +((i j k l) (o) (a b c) (f g h) (d e) (d e) (m n))"
  +  (let ((freqs (mapcar #'reverse (encode (mapcar #'length list))))) ;p10
  +    (sort list (lambda (s1 s2) (< (assoc (length s1) freqs) 
  +                                  (assoc (length s2) freqs))))))
  +
  +(defun sort (list pred)
  +  "Sort list according to the ordering defined by PRED, assumed analogous to <."
  +  (when list
  +    (let ((partition (partition (cdr list)
  +                                (lambda (item) (funcall pred item (car list))))))
  +      (append (sort (car partition) pred) (cons (car list) (sort (cdr partition) pred))))))
  +
  +(defun partition (list pred)
  +  "Separate list into two sublists, the first one containing elements that verify PRED, the second one containing the rest."
  +  (if list
  +      (let ((res (partition (cdr list) pred)))
  +        (if (funcall pred (car list))
  +            (cons (cons (car list) (car res)) (cdr res))
  +            (list (car res) (cons (car list) (cadr res)))))
  +      (list NIL NIL)))
  
positive.code:                         (1- k))))))
                          
  ;;; p24
  (defun lotto-select (n m)
    "Lotto: Draw N different random numbers from the set 1..M.
  The selected numbers shall be returned in a list.
  
negative.code:               n)) ;p23
  
  ;;; p25
  
  (defun rnd-permu (list)
    "Generate a random permutation of the elements of a list.
  Example:
  