So its the calling of first that gives you nil here is some example code
user=> (rest '(2)) () user=> (rest '()) () user=> (first '()) nil 2010/6/7 patrik karlin <patrik.kar...@gmail.com>: > calling rest dosent give you nil it gives you an empty seq > so the if statment never fails > > try > > (defn my-zipmap [keys vals] > (loop [my-map {} > [kf & kr] (seq keys) > [vf & vr] (seq vals)] > (if (and kf vf) > (recur (assoc my-map kf vf) kr vr) > my-map))) > > > > 2010/6/6 Jon Seltzer <seltzer1...@gmail.com>: >> I'm still learning Clojure and doing so by reading everything on >> clojure.org. I ran across this example in the Functional Programming >> section: >> >> (defn my-zipmap [keys vals] >> (loop [my-map {} >> my-keys (seq keys) >> my-vals (seq vals)] >> (if (and my-keys my-vals) >> (recur (assoc my-map (first my-keys) (first my-vals)) >> (rest my-keys) >> (rest my-vals)) >> my-map))) >> >> (my-zipmap [:a :b :c] [1 2 3]) >> >> However, when run, it hangs. >> >> I'm running: >> >> OS: Windows Vista - Business Edition >> Java: 1.6.0_20 >> >> If I had to guess, I'd say it's in an infinite loop, but not sure >> what's wrong exactly. >> >> -- >> 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 >> Note that posts from new members are moderated - please be patient with your >> first post. >> 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 > > > > -- > ------------------------------------------------ > Nick: Korre > Email: patrik.kar...@gmail.com > ------------------------------------------------ > -- ------------------------------------------------ Nick: Korre Email: patrik.kar...@gmail.com ------------------------------------------------ -- 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 Note that posts from new members are moderated - please be patient with your first post. 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