On Tue, Aug 21, 2012 at 12:04:29PM +0100, Jim - FooBar(); wrote: > Dear all, > > Can anyone redirect me to some 'real code' using reducers? I say > 'real-code' cos I don't consider (r/fold + [1 2 3 4 5]) to be a > realistic example of usage...also, apart from Rich's blogs, I'm > having a hard time finding resources explaining the role of the > combining/reducing fns. THe way I understand it, the entire > reducers lib is only applicable (with benefits) to tree-like > structures and so, the reducing fn is the one applied on the leaves > to make them fewer (reduce them) and the combining fn is the one > that essentially propagates the reductions back up the tree > (combines them)... Can anyone confirm this understanding of mine? > > > Assuming I'm thinking about it the right way, I 'd like to build a > map-tree (nested maps) where the leaves will be reduced using > 'max-key' and combined back up using 'r/cat' , which apparently is > a: "high-performance combining fn that yields the catenation of the > reduced values.". Does that make any sense whatsoever? I'm really > struggling to replace (apply max-key #(...) (:children tree)) with > some form of (r/fold r/cat #(max-key (fn [e] ....)) (:children > tree))... > > I'd love to see some proper usage of reducers so I can understand > what is going on...From all the videos I've watched, I 've > understood that the algorithm I'm implementing (minimax) is an ideal > candidate for reducers - however I've still not managed to tame > them...any help/pointers will be massively appreciated! :-) > > Thanks in advance... > > Jim > > -- > 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
Not sure if you'd consider this "real code", but I recently wrote a scrabble solver (i.e. find the best scoring word given a set of letters) in such a way that it can be used with or without reducers: https://github.com/jballanc/scrabbler Running with reducers cuts runtime to 1/4 the original. - Josh -- Joshua Ballanco ELC Technologies™ 1771 NW Pettygrove Street, Suite 140 Portland, OR, 97209 jballa...@elctech.com P +1 866.863.7365 F +1 877.658.6313 M +1 646.463.2673 T +90 533.085.5773 http://www.elctech.com -- 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