Re: [Tutor] Difference between filter and map

2007-01-24 Thread Alan Gauld
"vanam" <[EMAIL PROTECTED]> wrote > Yes i did a mistake in expressing my problem below are the instances > of the > script and its corresponding output,for each instance its giving > contrasting > result i want explanation for that > [1]:def squ(n): > return n*n > filter(squ,rang

Re: [Tutor] Difference between filter and map

2007-01-24 Thread Kent Johnson
vanam wrote: > Yes i did a mistake in expressing my problem below are the instances of > the script and its corresponding output,for each instance its giving > contrasting result i want explanation for that This has pretty much been explained already. Do you have some question with the explanat

Re: [Tutor] Difference between filter and map

2007-01-23 Thread vanam
Yes i did a mistake in expressing my problem below are the instances of the script and its corresponding output,for each instance its giving contrasting result i want explanation for that [1]:def squ(n): return n*n filter(squ,range(3))>output is not seen on the interpreter ma

Re: [Tutor] Difference between filter and map

2007-01-23 Thread Chris Calloway
vanam wrote: > ya i am sure about that i am using python editor which has python > intrepreter attached to it i got the same output for both filter and map > def squ(n): >y = n*n > print y > filter(y,range(3))->0 1 4 > map(y,range(3))->0 1 4 You are not printing the result of either the fi

Re: [Tutor] Difference between filter and map

2007-01-23 Thread Chris Calloway
vanam wrote: > i want to know the difference between filter(function,sequence) and > map(function,sequence). >>> print filter.__doc__ filter(function or None, sequence) -> list, tuple, or string Return those items of sequence for which function(item) is true. If function is None, return the ite

Re: [Tutor] Difference between filter and map

2007-01-23 Thread Kent Johnson
vanam wrote: > ya i am sure about that i am using python editor which has python > intrepreter attached to it i got the same output for both filter and map > def squ(n): >y = n*n > print y > filter(y,range(3))->0 1 4 > map(y,range(3))->0 1 4 This is quite different that what you posted the

Re: [Tutor] Difference between filter and map

2007-01-23 Thread Danny Yoo
On Tue, 23 Jan 2007, vanam wrote: > i want to know the difference between filter(function,sequence) and > map(function,sequence). Hi Vanam, They may both take functions as input, but the intention of the functions is different. In the case of filter(), the input function is used to cull the

Re: [Tutor] Difference between filter and map

2007-01-23 Thread vanam
ya i am sure about that i am using python editor which has python intrepreter attached to it i got the same output for both filter and map def squ(n): y = n*n print y filter(y,range(3))->0 1 4 map(y,range(3))->0 1 4 On 1/23/07, Kent Johnson <[EMAIL PROTECTED]> wrote: vanam wrote: > i want t

Re: [Tutor] Difference between filter and map

2007-01-23 Thread Kent Johnson
vanam wrote: > i want to know the difference between filter(function,sequence) and > map(function,sequence).I tried for a simple script with an function > which finds the square of the number,after including separately filter > and map in the script i am getting the same results for instance > d