Thanks, Gary and Justin, for spotting my code mistakes. Serves me right for 
not double-checking the outputs at my REPL. :-P

Anyway, my examples with vectors, maps, and sets were all correct using 
into. I goofed on lists, because the new elements are naturally always 
applied to the front of the list since that is the only way to do it 
efficiently. This really just reinforces what others have already said 
above that Clojure's standard library doesn't make it easy for you to do 
something inefficient (like adding elements to the end of a list.

Anyway, having said that, I guess I'd just make the following adjusted 
recommendation then:

1. When appending/prepending to vectors, maps, or sets, use into as 
demonstrated above.
2. When appending/prepending to lists, use concat with the same syntax as 
was shown with into above.

Note, of course, that concat returns a lazy sequence not a true linked 
list, but for the purposes of beginner instruction, this should probably be 
fine since it will print to the REPL like a list and provides the same API 
as a list going forward.

Once again, good luck with your Clojure teaching, and happy hacking!

~Gary

-- 
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
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to