Re: Destructuring noob question

2010-11-22 Thread Mark Rathwell
Probably would have been more clear if I showed an example in a function argument vector also: (defn foo {:count 2 :name "billy"}) (defn print-foo [{c :count n :name}] (println "count:" c "name:" n)) (print-foo foo) On Mon, Nov 22, 2010 at 9:30 AM, Mark Rathwell wrote: > > as for replacing

Re: Destructuring noob question

2010-11-22 Thread Mark Rathwell
as for replacing accessor methods: java: class Foo { private int count; private String name; public Foo(String name) { this.name = name; } public String getName() { return this.name; } public String getCount() { return this.count; }

Re: Destructuring noob question

2010-11-22 Thread nickik
as for first and next: You can do this (let [fst (first [1 2 3 4 5 6]) rst (rest [1 2 3 4 5 6])] (println "first: " fst) (println "rest: "rst)) or (let [[fst & rst] [1 2 3 4 5 6]] (println "first: " fst) (println "rest: "rst)) both print this: first: 1 rest: (2 3 4 5 6) --

Destructuring noob question

2010-11-22 Thread Andreas Kostler
Hi All, I'm currently ploughing my way through Michael Fogus and Chris Housers "The Joy of Clojure". I am currently reading up on destructuring. The authors sum up the chapter by concluding that destructuring is the idiomatic clojure replacement for accessor methods in OO languages. Can someone exp