27 Aug
2002
27 Aug
'02
7:40 p.m.
Oren Tirosh
Hmmm, in other words, cartesian() is a lazy version of zip().
Nope.
zip([1, 2], ['a', 'b']) [(1, 'a'), (2, 'b')]
list(cartesian([1, 2], ['a', 'b'])) [(1, 'a'), (1, 'b'), (2, 'a'), (2, 'b')]
Sorry, BrainError. In that case, it's probably faster to use the nested loops -- unless cartesian() were implemented in C. Greg Ewing, Computer Science Dept, +--------------------------------------+ University of Canterbury, | A citizen of NewZealandCorp, a | Christchurch, New Zealand | wholly-owned subsidiary of USA Inc. | greg@cosc.canterbury.ac.nz +--------------------------------------+