Okay, first, I create an atom that holds a set:

user> (def visitors (atom #{}))
#'user/visitors

user> (swap! visitors conj "stu")
user> (swap! visitors conj "mary")
user> (swap! visitors conj "mary")
user> (swap! visitors conj "lawrence")

#{"stu" "lawrence" "mary"}

Then I turn this into a string:

user> (apply str @visitors)
"stulawrencemary"
user> (apply str (reverse @visitors))
"marylawrencestu"

So far, everything is working as I thought. But I also thought that apply 
let me run a function on everything in a sequence. Other than "str", I 
could not get this to work: 

user> (apply #(println %1) @visitors)

This got me a "Wrong number of args" error. So did this:

 (apply #([] println %) @visitors)

When I use 'map', I got what I expected: 

user>  (map #(println " we love this user: " %) @visitors)
(stu
lawrence
nil mary
nil nil)


But why does apply work with str, but not with any anonymous function I 
write? 

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