Many thanks. I didn't recognize the % symbol is used similarly to the
way it's used in printf and constructing SQL query string.

On Jun 17, 9:07 am, Ken Wesson <kwess...@gmail.com> wrote:
> On Fri, Jun 17, 2011 at 8:57 AM, octopusgrabbus
>
> <octopusgrab...@gmail.com> wrote:
> > I'm trying this in REPL
>
> > timmy=> (def ox [1 2 3 4])
> > #'timmy/ox
> > timmy=> ox
> > [1 2 3 4]
> > timmy=> (map #(reduce str/split (seq ox) #","))
> > java.lang.IllegalArgumentException: Wrong number of args (1) passed
> > to: core$map (NO_SOURCE_FILE:0)
> > t
>
> Yikes.
>
> Well, first of all, you need to
>
> (map #(str/split % #",") some-seq-of-strings)
>
> -- map takes a function and then one or more sequences or collections
> to iterate over. Further, the function needs to have an argument; with
> #() closures you use % to stand in for the element from the sequence.
> So
>
> (map #(* 2 %) ox)
>
> in your case would return
>
> (2 4 6 8)
>
> as a lazy sequence.
>
> Lastly, though, ox doesn't contain strings so str/split can't be used
> on them. And I don't know why you had a "reduce" in there.
>
> --
> Protege: What is this seething mass of parentheses?!
> Master: Your father's Lisp REPL. This is the language of a true
> hacker. Not as clumsy or random as C++; a language for a more
> civilized age.

-- 
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

Reply via email to