Some thoughts on really stupid things that have tripped me up:

- How do I exit Clojure - srsly
C-c

- Whatsa JVM - does this mean Clojure is really just Java with parens?

- Whatsa Classpath?
this answer presents the *ALL* important opportunity to mention that
*nix uses `:' to separate paths whereas windz uses `;'

- How do I access Clojure documentation - e.g. where is `man Clojure'

- Is a Clojure docstring the same as Javadoc?

- Is Clojure stable?

- Where's the Clojure manual?

- What happened to setf?

- Why are Clojure's docstring placements different than other lisps

- Where do I make donations?

- Why are Clojure's defun params passed in a [] vector?

- Does Clojure do TCO?

- Whatsa TCO?

- How do I compile Clojure? OR Where's the Clojure Compiler?

- How does Clojure's nil differ from other Lisps?

- Clojure has a `cons' function and a `conj' function - whats the
difference?

- At what point do calls out to external Java interfaces limit/alter
Clojures' internal handling of sequences
---- How do I avoid  interopearating with Java - e.g. when is Clojure
all I need for task X
---- When should I make use of external Java libraries

- Whatsa Clojure Sequence - how does it corellate to language X
- Whatsa Collection - how does it corellate to language X
- Whatsa Map - how does it corellate to language X

On Dec 19, 12:41 am, "Adrian Cuthbertson"
<adrian.cuthbert...@gmail.com> wrote:
> > Suggestions for entries welcome here.
>
> > > Rich
>
> Here's another that was a "gotcha" for me for an hour or two...
>
> Why after using map/reduce/for to change a java object does the object
> remain unchanged?
>
> (defn initv1 [myseq] (let [v (java.util.Vector.)] (for [x myseq]
> (.addElement v x)) v))
> (initv1 [1 2 3])
> ; => (java.util.Vector. [])
>
> ; or...
>
> (defn initv2 [myseq] (let [v (java.util.Vector.)] (map (fn [x] (.addElement
> v x)) myseq) v))
> (initv2 [1 2 3])
> ; => (java.util.Vector. [])
>
> As map/reduce/for are lazy, the "let" construct does not actually "take" any
> elements from the map/reduce/for. In this case, use doseq...
>
> (defn initv3 [myseq] (let [v (java.util.Vector.)] (doseq [x myseq]
> (.addElement v x)) v))
> (initv3 [1 2 3])
> ; => (java.util.Vector. [1 2 3])
>
> (Actually this happened in a more complex function, but the essence was that
> a new java object was instantiated in a let and I'd used a map to call a
> method on that object with all the items from a sequence. I could not
> understand why the object remained unchanged afterwards until I simplified
> it down to the above example).
>
> Regards, Adrian
--~--~---------~--~----~------------~-------~--~----~
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
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