Popular recipes tagged "reduce" but not "fold"http://code.activestate.com/recipes/tags/reduce-fold/2013-01-05T05:49:27-08:00ActiveState Code RecipesTraverse dotted attribute of an object using built-in function reduce (Python) 2013-01-05T05:49:27-08:00Chaobin Tang (唐超斌)http://code.activestate.com/recipes/users/4174076/http://code.activestate.com/recipes/578398-traverse-dotted-attribute-of-an-object-using-built/ <p style="color: grey"> Python recipe 578398 by <a href="/recipes/users/4174076/">Chaobin Tang (唐超斌)</a> (<a href="/recipes/tags/attributes/">attributes</a>, <a href="/recipes/tags/bif/">bif</a>, <a href="/recipes/tags/recursive/">recursive</a>, <a href="/recipes/tags/reduce/">reduce</a>). </p> <p>Making good use of reduce() to traverse dotted attribute of an object.</p> Finding the GCD of a list of numbers (a.k.a. Reducing numbers in a list) (Python) 2010-07-06T18:52:55-07:00Stephen Akikihttp://code.activestate.com/recipes/users/4172143/http://code.activestate.com/recipes/577282-finding-the-gcd-of-a-list-of-numbers-aka-reducing-/ <p style="color: grey"> Python recipe 577282 by <a href="/recipes/users/4172143/">Stephen Akiki</a> (<a href="/recipes/tags/common/">common</a>, <a href="/recipes/tags/denominator/">denominator</a>, <a href="/recipes/tags/gcd/">gcd</a>, <a href="/recipes/tags/greatest/">greatest</a>, <a href="/recipes/tags/lisst/">lisst</a>, <a href="/recipes/tags/reduce/">reduce</a>). </p> <p><a href="http://akiscode.com/articles/gcd_of_a_list.shtml" rel="nofollow">http://akiscode.com/articles/gcd_of_a_list.shtml</a></p> <p>This python code snippet allows you to find the GCD of a list of numbers, after this it is a simple matter of diving all the numbers in the list by the GCD to reduce it.</p> <p>Why this works...</p> <p>The GCD of a list of numbers [a, b, c] is GCD(GCD(a, b), c). The reduce function does exactly this and thus gives you the GCD of all the numbers in the list.</p> Functional selection sort (Python) 2009-09-29T13:34:35-07:00pavelhttp://code.activestate.com/recipes/users/4171837/http://code.activestate.com/recipes/576917-functional-selection-sort/ <p style="color: grey"> Python recipe 576917 by <a href="/recipes/users/4171837/">pavel</a> (<a href="/recipes/tags/algorithm/">algorithm</a>, <a href="/recipes/tags/algorithms/">algorithms</a>, <a href="/recipes/tags/functional/">functional</a>, <a href="/recipes/tags/lambda/">lambda</a>, <a href="/recipes/tags/reduce/">reduce</a>, <a href="/recipes/tags/selection/">selection</a>, <a href="/recipes/tags/sort/">sort</a>, <a href="/recipes/tags/sorting/">sorting</a>). Revision 3. </p> <p>This is a variant of selection sort without using for-statements. Do you like it? :-)</p>