 
 (defvar- closure nil
   "Holds the closures of sets. To be rebound.")
+(defvar- minimum nil
+  "Computes the minimum of weights in a given sequence of weights. To
+  be rebound.")
 (defvar- set-weight nil
   "Holds the weights of sets. To be rebound.")
 


;;; Pragmatics

(defn- minimum
  "Returns a random minimal element wrt <= in seq-of-elements."
  [<= seq-of-elements]
  (first (apply partial-min <= seq-of-elements)))

(defmacro- set-val!
  "Sets (via set!) the value for key in map to val."
  [map key val]

(defn titanic
  "Implements the titanic algorithm. weigh must return for a
  collection of sets a hash-map mapping every set to its weight, with
  max-weight being the maximal weight possbile. weight-minimum is a
  function of one argument being a sequence of weights and returning
  the minimal of those."
  [base-set weigh max-weight weight-minimum]
  (binding [closure       {},
            set-weight    (weigh [#{}]),
            subset-weight (memoize (partial subset-weight max-weight)),
            minimum       weight-minimum]

    (loop [key-set    #{#{}},
           candidates (set-of #{m} [m base-set]),
