Thank you so much! Your solution was almost perfect. It gave me: 

#{[[:positive :false 30 8 9090] 1] [[:negative :true 30 4 50] 43] 
[[:positive :false 30 4 1000] 32] [[:positive :true 30 8 9090] 1] 
[[:positive :false 30 4 50] 43] [[:negative :true 30 8 9090] 1] [[:negative 
:false 30 4 50] 43] [[:positive :true 30 4 50] 43] [[:negative :true 30 4 
1000] 32] [[:positive :true 30 6 90] 2] [[:negative :false 30 6 90] 2] 
[[:positive :false 30 6 40] 12] [[:positive :false 30 8 777] 23] 
[[:negative :false 30 4 1000] 32] [[:positive :true 30 8 777] 23] 
[[:negative :true 30 6 90] 2] [[:negative :true 30 6 40] 12] [[:positive 
:true 30 4 1000] 32] [[:positive :true 30 6 40] 12] [[:negative :true 30 8 
777] 23] [[:negative :false 30 8 777] 23] [[:positive :false 30 6 90] 2] 
[[:negative :false 30 6 40] 12] [[:negative :false 30 8 9090] 1]}

I changed this: 

                [[ path v]]))))

to this:
                [(conj path v)]))))

and got: 

#{[:positive :false 30 6 40 12] [:positive :false 30 4 50 43] [:negative 
:false 30 4 1000 32] [:negative :false 30 6 90 2] [:negative :true 30 8 777 
23] [:positive :false 30 6 90 2] [:negative :false 30 8 9090 1] [:negative 
:false 30 6 40 12] [:negative :true 30 6 90 2] [:positive :true 30 8 9090 
1] [:negative :true 30 4 50 43] [:positive :true 30 6 90 2] [:negative 
:true 30 6 40 12] [:positive :true 30 8 777 23] [:positive :true 30 4 1000 
32] [:negative :true 30 8 9090 1] [:positive :true 30 4 50 43] [:negative 
:false 30 8 777 23] [:positive :false 30 4 1000 32] [:positive :true 30 6 
40 12] [:positive :false 30 8 777 23] [:negative :false 30 4 50 43] 
[:positive :false 30 8 9090 1] [:negative :true 30 4 1000 32]}

You saved me many hours of stumbling around in the dark!

--- lawrence



On Wednesday, March 8, 2017 at 12:49:16 PM UTC-5, lvh ‌ wrote:
>
> Hi!
>
>
> Suggested recursive impl:
>
> (defn path-entries
>   ([obj]
>    (path-entries [] obj))
>   ([prefix obj]
>    (into #{}
>          (mapcat
>           (fn [[k v]]
>             (let [path (conj prefix k)]
>               (if (map? v)
>                 (entries path v)
>                 [[path v]]))))
>          obj)))
>
>
> You could do this with an explicit stack, too, I'm sure.  For the size of 
> data you're suggesting it doesn't seem to matter much -- and I'm sure 
> someone clever could turn this into a TCO-able version too :)
>
>
> On Wed, Mar 8, 2017 at 11:38 AM, <[email protected] <javascript:>> wrote:
>
>>
>> Given this: 
>>
>> {:positive :true {30 {4 {50 43, 1000 32}, 6 {40 12, 90 2}, 8 {777 23, 
>> 9090 1}}}
>>
>> I'd like a series of arrays that I can feed into (reduce) so I can easily 
>> sum them:
>>
>> [ 30 4 50 43 ]
>>
>> [ 30 4 1000 32 ]
>>
>> [ 30 6 40 12 ]
>>
>> [ 30 6 90 2 ]
>>
>> [ 30 8 777 23 ]
>>
>> [ 30 8 9090 1 ]
>>
>> I've been trying to work this out using "walk" recursively, but then I 
>> wondered if perhaps I am missing something obvious? Does Clojure offer a 
>> straightforward way to do this?
>>
>>
>>
>>
>>
>> -- 
>> You received this message because you are subscribed to the Google
>> Groups "Clojure" group.
>> To post to this group, send email to [email protected] 
>> <javascript:>
>> Note that posts from new members are moderated - please be patient with 
>> your first post.
>> To unsubscribe from this group, send email to
>> [email protected] <javascript:>
>> 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 [email protected] <javascript:>.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
[email protected]
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to