On Jan 25, 2009, at 8:05 PM, wubbie wrote:
Wait... I just tried (first (list (+ 1 2) (+ 3 4))) and got 3! So (list a b c) is different than '( a b c)? I thought they are equivalent!
Right, as your experiment shows, the ' in '(a b c) quotes both the list itself and all of its contents.
Using vectors to hold your data can be a convenient way to experiment because you don't have to worry about avoiding the special evaluation rules for lists.
user=> [(+ 1 2) (+ 3 4)] [3 7] One strategy for working with Clojure is to favor using: - lists mostly for function calls, - vectors, maps, and sets mostly for collecting data, and - seqs (and the seq functions) mostly for manipulating data.Clojure's rich set of literal syntax for collections other than lists is very helpful in keeping code readable while following that strategy.
--Steve
smime.p7s
Description: S/MIME cryptographic signature