On Sun, 05 Apr 2015, Michael Blume wrote:

> your list doesn't contain the records, your list contains the symbols 'a1
> and 'a2. You can't make a list the way you're trying to.

To be specific, you're quoting the list in your def, so the a1 and a2 symbols 
are
not evaluated.

  user=> (defrecord Ape [fname lname])
  user.Ape
  user=> (def a1 (->Ape "test1" "test2"))
  #'user/a1
  user=> (def a2 (->Ape "test3" "test4"))
  #'user/a2

  user=> '(a1 a2)
  (a1 a2)
  user=> (quote (a1 a2))
  (a1 a2)
  user=> (list a1 a2)
  (#user.Ape{:fname "test1", :lname "test2"} #user.Ape{:fname "test3", :lname 
"test4"})

  user=> (def alist (list a1 a2))
  #'user/alist
  user=> (filter #(= "test1" (:fname %)) alist)
  (#user.Ape{:fname "test1", :lname "test2"})

  ;; Clojure idioms tend toward vectors and vector literals rather than
  ;; lists. If you have a background in Common Lisp or Scheme, this can
  ;; take some getting used to. One nice consequence is you don't have
  ;; to worry about quoting most of the time.
  user=> (filter #(= "test1" (:fname %)) [a1 a2])
  (#user.Ape{:fname "test1", :lname "test2"})

Cheers,
Paul

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