>
>
> this seemed like a clean, nice way to merge to sorted lists into one
> sorted list.  I'm not getting clojure syntax, it seems:
>
>
> (defn listmerge [l1 l2]
>  (let [l1first (first l1) l2first (first l2)]
>    (if (= l1first nil) l2)
>    (if (= l2first nil) l1)
>    (if (< l1first l2first)
>      (cons l1first (listmerge (rest l1) l2))
>      (cons l2first (listmerge (rest l2) l1)))
>    ))
>
> psuedocode:
>
> listmerge (list l1, list l2):
>   if l1 is empty, return l2
>   if l2 is empty return l1
>   if l1[0] is less than l2[0],
>        return l1[0] + listmerge(rest(l1), l2)
>   otherwise return l2[0] + listmerge(rest(l2), l1)
>

Read James' answer first. I just wish to add something.

When you say (let [bindings...] expr1 expr2 expr3) the result is the return
value of expr3. expr1 and expr2 return values are relevant, so the only
reason to have expr1 and expr2 is if they have side-effects, such as
changing the value of a Ref or updating a database or printing to the
terminal.

-- 
Education is what survives when what has been learned has been forgotten.

                   - B. F. Skinner

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to