If your asking this as an exercise for manipulating clojure datastructure, then a solution could be :
(def d {:apple "green", :cherry "red", :banana "yellow"}) (apply str (interpose "&" (map (fn [[k v]] (str (name k) "=" v)) d))) Of course, there's more to URI than that, e.g. name and values should be appropriately encoded => so for real world usage, I'd use whatever library is already available in your context. The idiomatic way above leverages higher order functions. It's generally the more concise way. Of course, it uses seqs under the cover : X seq objects for the innermost map, X seq objects as a result of interpose, not to say X vectors creations as the result of map applying (seq) to d (to be able to consume the map as a seq of key/value pairs). It could also be written (apply str (interpose "&" (for [[k v] d] (str (name k) "=" v)))) which seems even more readable But anyway, it would probably be considered premature optimization to use recur in the first place. I generally tend to use recur in the first place when I give up with finding a cleaner way to write code with higher order functions. 2010/10/9 Paul <paul_bow...@yahoo.com> > Hi all, > > I'm trying to parse a map unto a URI string, e.g: > > {:apple "green", :cherry "red", :banana "yellow"} into > "apple=green&cherry=red&banana=yellow" > > I've almost got there by several routes, but is there a 'preferred' > idiomatically correct way to perform this? > > What are the advantages of, say, using recursion over sequences? > > Many thanks, > > P. > > -- > 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<clojure%2bunsubscr...@googlegroups.com> > For more options, visit this group at > http://groups.google.com/group/clojure?hl=en -- 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