Re: doseq destructuring - weird behaviour

2009-10-27 Thread Abhijith
On Oct 27, 12:24 am, Meikel Brandmeyer wrote: > Hi, > > Am 26.10.2009 um 18:55 schrieb Abhijith: > > > (defn foobar [arr--of-arr] > >  (let [ acc (transient {}) ] > >    (doseq [ [i e] (indexed arr-of-arr) word e ] > >      (assoc! acc word (if-let [v (acc word)] (conj v i) [i]))) > >    (persist

Re: doseq destructuring - weird behaviour

2009-10-27 Thread Abhijith
> You nailed it.  It's not about destructuring, it's using doseq to > "bash in place" a transient collection.  You won't get correct > results unless you take the return value of 'assoc!' as your new > collection.  Even though most of the time it will return the same > transient you passed in with

Re: doseq destructuring - weird behaviour

2009-10-26 Thread Meikel Brandmeyer
Hi, Am 26.10.2009 um 18:55 schrieb Abhijith: > (defn foobar [arr--of-arr] > (let [ acc (transient {}) ] >(doseq [ [i e] (indexed arr-of-arr) word e ] > (assoc! acc word (if-let [v (acc word)] (conj v i) [i]))) >(persistent! acc))) I think the problem is the wrong use of transients.

Re: doseq destructuring - weird behaviour

2009-10-26 Thread Chouser
On Mon, Oct 26, 2009 at 1:55 PM, Abhijith wrote: > > Hello everyone, >  I am having problems with destructuring in doseq. > > The function below basically takes an array of arrays as its argument > and returns a mapping of the elements to the index in the outer array. > > (use 'clojure.contrib.se

doseq destructuring - weird behaviour

2009-10-26 Thread Abhijith
Hello everyone, I am having problems with destructuring in doseq. The function below basically takes an array of arrays as its argument and returns a mapping of the elements to the index in the outer array. (use 'clojure.contrib.seq-utils) (defn foobar [arr--of-arr] (let [ acc (transient {})