Re: [Tutor] Higher-Order Function Examples

2011-02-14 Thread Steven D'Aprano
Walter Prins wrote: 2011/2/14 Rafael Durán Castañeda Could we consider sorted as an high order function? sorted_list = sorted(list_strings, key = str.lower) No because sorted() returns a list as a result. A higher order function produces another function as a result, or takes one or more

Re: [Tutor] Higher-Order Function Examples

2011-02-14 Thread Alan Gauld
"Rafael Durán Castañeda" wrote Could we consider sorted as an high order function? sorted_list = sorted(list_strings, key = str.lower) Yes, there are lots of them All the GUI building functions in Tkinter that take command arguments are higher order functions too. And many functions in pro

Re: [Tutor] Higher-Order Function Examples

2011-02-14 Thread Walter Prins
2011/2/14 Rafael Durán Castañeda > In the example I gave: > > > sorted_list = sorted(list_strings, key = str.lower) > > sorted takes str.lower as a parameter, doesn't it? So, it should be a high > order function > My apologies! Yes, you are of course quite correct! :) Walter __

Re: [Tutor] Higher-Order Function Examples

2011-02-14 Thread Walter Prins
2011/2/14 Rafael Durán Castañeda > Could we consider sorted as an high order function? > > sorted_list = sorted(list_strings, key = str.lower) > > No because sorted() returns a list as a result. A higher order function produces another function as a result, or takes one or more functions as a p

Re: [Tutor] Higher-Order Function Examples

2011-02-14 Thread Rafael Durán Castañeda
In the example I gave: sorted_list = sorted(list_strings, key = str.lower) sorted takes str.lower as a parameter, doesn't it? So, it should be a high order function El 14 de febrero de 2011 21:06, Walter Prins escribió: > > > 2011/2/14 Rafael Durán Castañeda > > Could we consider sorted as an

Re: [Tutor] Higher-Order Function Examples

2011-02-14 Thread Rafael Durán Castañeda
Could we consider sorted as an high order function? sorted_list = sorted(list_strings, key = str.lower) 2011/2/14 Steven D'Aprano > Steven D'Aprano wrote: > > An example might help. Back in the old days, before Python had a sum() >> function, the easiest way to add up a list of numbers was to

Re: [Tutor] Higher-Order Function Examples

2011-02-14 Thread Steven D'Aprano
Steven D'Aprano wrote: An example might help. Back in the old days, before Python had a sum() function, the easiest way to add up a list of numbers was to use reduce and a small function to add two numbers: def add(x, y): return x+y total = filter(add, [2, 4, 5, 9, 1]) Arh! Of cour

Re: [Tutor] Higher-Order Function Examples

2011-02-14 Thread Steven D'Aprano
Carla Jenkins wrote: Hello everyone: I am new to Python and am looking for higher-order function programming examples. The programming codes do not feature the corresponding equation so I am lost. Please help me. The first thing you need to understand is the difference between *code* and *da

Re: [Tutor] Higher-Order Function Examples

2011-02-14 Thread Alan Gauld
"Carla Jenkins" wrote I am new to Python and am looking for higher-order function programming examples. This sounds like homework, if not I apologize, but as such I can only gicve you some pointers As with all concept type stuff wikipedia is a good place to start. Just search for "higher

[Tutor] Higher-Order Function Examples

2011-02-13 Thread Carla Jenkins
Hello everyone: I am new to Python and am looking for higher-order function programming examples.  The programming codes do not feature the corresponding equation so I am lost. Please help me.   Sincerely, Carla Jenkins ___ Tutor maillist - Tu