How would you implement the Hofstadter Male and Female sequences
*elegantly* in Clojure? Here's a starting point:
(declare h-male h-female)
(defn h-male [n]
(if (= n 0)
0
(- n (h-female (h-male (dec n))))))
(defn h-female [n]
(if (= n 0)
1
(- n (h-male (h-female (dec n))))))
(def h-male (memoize h-male))
(def h-female (memoize h-female))
(def h-male-seq (map h-male (iterate inc 0)))
(def h-female-seq (map h-female (iterate inc 0)))
Stuart
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---