On Wed, Dec 29, 2010 at 9:31 PM, Mark Engelberg
<[email protected]> wrote:
> So here's the answer to the puzzle I posed earlier....
I just realized that the "append" function in my code was unnecessary,
since into serves the same purpose. Thus my solution could be
rewritten as:
(defn insert [n alon]
(loop [alon (seq alon), traversed nil]
(cond
(nil? alon) (into (list n) traversed)
(<= n (first alon)) (into (cons n alon) traversed)
(> n (first alon)) (recur (next alon) (conj traversed (first alon))))))
(defn isort [alon]
(loop [alon (seq (reverse alon)), sorted nil]
(if alon
(recur (next alon) (insert (first alon) sorted))
sorted)))
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
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