[Tutor] Permutations?

Brian van den Broek bvande at po-box.mcgill.ca
Sun Jul 25 19:12:51 CEST 2004


Rich Krauter said unto the world upon 25/07/2004 11:39:

> On Sun, 2004-07-25 at 10:21, Rich Krauter wrote:
> 
> 
>>You could just call your function as-is with a slice of the original 
>>list, and then append the initial list element(s) to the results:
>>
>>lst = [0,1,2,3]
>>results = perm(lst[1:])
>>print map(lambda res,i=lst[0]:[i]+res,results)
>>
> 
> 
> Sorry, Brian. I see you suggested something similar 
> in your first reply. 
> 
> Rich

Hi Rich,

no worries. :-)

I've not made much use of lambda yet; it doesn't naturally occur to me. 
I'm glad I saw your way, too.

But I do feel that my named-function approach is a bit easier to read and 
reuse.

Best,

Brian vdB




More information about the Tutor mailing list