2009/9/11 Richard Newman <holyg...@gmail.com>:
>
>>> Where I'm stuck
>>> is how to get access to the particle names, as I would in the above
>>> line of Java code.
>
> The final bit, once you have an iterator over particles, would be:
>
> (fn [p] (.getName p))
>
> To avoid the use of reflection, you might want explicit type
> annotations:
>
> (fn [#^Particle p] (.getName p))

Oh, I'm sorry, completely missed the getName part of the question!

This will give you a list of names:
(let [particles (-> dataLoader .getEnvironmentParticleSet .iterator
iterator-seq)]
  (map #(.getName %) particles))

You can then do things to the names in a 'loop' with map, for, or
doseq (if 'things' has side effects):

;; map
(let [particles (-> dataLoader .getEnvironmentParticleSet .iterator
iterator-seq)
  names (map #(.getName %) particles)]
  (map #(count %) names))

;; for
(let [particles (-> dataLoader .getEnvironmentParticleSet .iterator
iterator-seq)
  names (map #(.getName %) particles)]
  (for [n names] (count n)))

;; doseq
(let [particles (-> dataLoader .getEnvironmentParticleSet .iterator
iterator-seq)
  names (map #(.getName %) particles)]
  (doseq [n names] (println n)))

HTH!

-- 
  ! Lauri

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