eadrogue at gmx.net
Thu Mar 4 05:35:37 EST 2010
4/03/10 @ 11:19 (+0100), thus spake Ernest Adrogué:
> Hello everybody,
> Suppose I want to find all 2-digit numbers whose first digit
> is either 4 or 5, the second digit being 7, 8 or 9.
> Is there a Numpy/Scipy function to calculate that kind of
> I came up with this function, the problem is it uses recursion:
> def g(sets):
> if len(sets) < 2:
> return sets
> return [[i] + j for i in sets for j in f(sets[1:])]
Sorry, this is a mistake... it calls f() instead of g().
This is the one:
if len(sets) < 2:
return [[i] for i in sets]
return [[i] + j for i in sets for j in f(sets[1:])]
> In : g([[4,5],[7,8,9]])
> Out: [[4, 7], [4, 8], [4, 9], [5, 7], [5, 8], [5, 9]]
> Is important that it works with more than two sets too.
> Any idea is appreciated.
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
More information about the NumPy-Discussion