News for hackers. Stuff that matters.
Re:Is it possible to write c...r in lisp, for any combinatio... by rincewind on Sunday October 11, 2009 @07:02AM (#874628)
In Clojure: possible but ugly. Use destructuring in production instead.

  (defn make-xrs [n]
    (if (= n 0) {"ar" first, "dr" rest}
	(let [last (make-xrs (dec n))]
	  (into last (for [[name fun] last [name2 fun2] {"d" rest "a" first}]
		       [(str name2 name) (comp fun2 fun)])))))

  (for [[name fun] (make-xrs 10)]
    (eval `(def ~(symbol (str "c" name)) ~fun)))
Re:Is it possible to write c...r in lisp, for any combinatio... by philh on Sunday October 11, 2009 @08:09AM (#874667)
That lets you write c[ad]{1,10}r, or c[ad]{1,n}r with O(2^n) initialisation time. OP wanted to be able to write c[ad]+r.

Also, that eval could be replaced with (untested)

    (intern *ns* (symbol (str "c" name)) fun)