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
> 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
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.
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
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 {})