Re: Navigators and lenses
Jason Felice writes: > I'm very curious why most lens libraries don't just use fns with arity 1 > and 2. Glad you mentioned it. https://github.com/active-group/active-clojure/commit/51fd8984f2dcebc1af7ee91fc36e3360299c6fed -- Regards, Mike -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com 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 clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Contribute Specter to Clojure core?
I rarely program in Clojure. At work I have to deal with a lot of deeply nested data structures. Specter helps me to navigate those nested data pretty easily. The navigators does looks unlispy for the newcomer. But if you bother to learn it , you don't have to invent your own. Above all, the code is very readable which is unusual from someone like me :) I recommend Specter to be a part Clojure contrib. Thank you, Nathan Marz. - Joe Python On Thursday, March 9, 2017 at 2:59:46 PM UTC-5, Gregg Reynolds wrote: > > > > On Mar 4, 2017 12:35 AM, "Asim Jalis" > > wrote: > > What might be a Clojurey syntax for doing path navigation? In other words > how could get-in be extended so that it could parse nested vectors like it > parses nested maps? Thinking out aloud, an integer in the path when the > data structure at that level is a vector should treat the integer as an > index. > > What about ALL? What would be Clojurey way of doing ALL? How about > asterisk *? Or maybe underscore _? Or nil? > > > looks like identity to me. > > i'm still not very deep into specter, but it looks a lot like xslt, just > with a different syntax and processing strategy. > > gregg > > -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com 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 clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: How to transform deeply nested map into a series of arrays?
Given the recent discussions about specter, I thought I'd add a spectral solution. Disclaimer: I'm still a specter novice. An unrolled solution might look like this: (select [ALL (collect-one FIRST) LAST ALL (collect-one FIRST) LAST ALL (collect-one FIRST) LAST] data) => [[30 4 50 43] [30 4 1000 32] [30 6 40 12] [30 6 90 2] [30 8 777 23] [30 8 9090 1]] Each repetition in that path starts with a map, navigates to each key-value pair (ALL), collects its key (collect-one FIRST), and navigates to its value (LAST). The values are themselves maps, so we repeat. This obviously lends itself to recursive navigation: (def TreePaths (recursive-path [] p (if-path map? [ALL (collect-one FIRST) LAST p] STAY))) (select [TreePaths] data) => [[30 4 50 43] [30 4 1000 32] [30 6 40 12] [30 6 90 2] [30 8 777 23] [30 8 9090 1]] On Wednesday, March 8, 2017 at 12:38:18 PM UTC-5, piast...@gmail.com 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 clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com 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 clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.