Oops, I should never type code straight into an email window, without 
REPLing it first...  X_X

I left in the "links" argument to map.  This is probably closer to what I 
meant:

(defn listen-to
  [links]
  (doseq [link links]
    (.log js/console link)))

On Wednesday, January 23, 2013 8:39:51 PM UTC-8, Evan Mezeske wrote:
>
> When you want to iterate over things and perform a side-effecty action for 
> each one (logging is a side effect, as would be adding event listeners to 
> DOM nodes, changing CSS classes, etc), doseq is usually the clearest thing 
> to do:
>
> (defn listen-to
>   [links]
>   (doseq [link links]
>     (.log js/console link) links))
>
> You almost never want to use map for side effects.  A good rule of thumb 
> is that if you don't use the return value from map, you probably want doseq 
> instead.
>

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