Re: yet another noob question

2006-08-15 Thread Jason Nordwick
That isn't what I meant. If there was a a point (and I'm not really sure that I'm even trying to make one), the point was that Google makes heavy use of reduce-like functionality, essentially implementing a distributed reduce across a cluster. From what I hear, they use a lot of Python and hired

Re: yet another noob question

2006-08-15 Thread Steve Holden
Jason Nordwick wrote: > I use reduce to also do indexing, hashing with upsert semantics of lists of > key-value pairs, transitioning through a state table, etc... > > Somebody else pointed out to me how odd it is of Python to be ditching reduce > when Guido van Rossum was hired by Google, and Go

Re: yet another noob question

2006-08-15 Thread Jason Nordwick
I use reduce to also do indexing, hashing with upsert semantics of lists of key-value pairs, transitioning through a state table, etc... Somebody else pointed out to me how odd it is of Python to be ditching reduce when Guido van Rossum was hired by Google, and Google is literally built on map

Re: yet another noob question

2006-08-14 Thread starGaming
Jason Nordwick wrote: > *mouth agape* > > Wow. That really sucks. I make extensive use of reduce. It seems to run more > than twice as fast as a for loop. > > >>> t = Timer('bino.reduceadd(bino.bits)', 'import bino') > >>> s = Timer('bino.loopadd(bino.bits)', 'import bino') > >>> t.timeit(10) > 1

Re: yet another noob question

2006-08-14 Thread Stargaming
Jason Nordwick wrote: > > [EMAIL PROTECTED] wrote: > >> Jason Nordwick: >> >>> Stargaming wrote: >>> Also note that reduce will be removed in Python 3000. >>> >>> What will replace it? >> >> >> Nothing, I presume. You will have to write a function to find another >> way to solve problems. >

Re: yet another noob question

2006-08-14 Thread AlbaClause
mike_wilson1333 wrote: > I would like to generate every unique combination of numbers 1-5 in a 5 > digit number and follow each combo with a newline. So i'm looking at > generating combinations such as: (12345) , (12235), (4) and so on. > What would be the best way to do this? So, basically i

Re: yet another noob question

2006-08-14 Thread Jason Nordwick
*mouth agape* Wow. That really sucks. I make extensive use of reduce. It seems to run more than twice as fast as a for loop. >>> t = Timer('bino.reduceadd(bino.bits)', 'import bino') >>> s = Timer('bino.loopadd(bino.bits)', 'import bino') >>> t.timeit(10) 1.2373670396656564 >>> s.timeit(10) 2.64

Re: yet another noob question

2006-08-14 Thread bearophileHUGS
Jason Nordwick: > Stargaming wrote: > > Also note that reduce will be removed in Python 3000. > What will replace it? Nothing, I presume. You will have to write a function to find another way to solve problems. Bye, bearophile -- http://mail.python.org/mailman/listinfo/python-list

Re: yet another noob question

2006-08-14 Thread Jason Nordwick
Stargaming wrote: > > Also note that reduce will be removed in Python 3000. What will replace it? -j -- http://mail.python.org/mailman/listinfo/python-list

Re: yet another noob question

2006-08-14 Thread Jason Nordwick
Somehow my other response to the list got lost. I'm still learning Python, but this seems much better than my first attempt: def pr(x): print x def cross(x,y): return [a+b for a in x for b in y] x=map(pr, reduce(cross, [map(str,range(1,6))]*5)) -j Stargaming wrote: > Jason Nordwick schrieb: >>

Re: yet another noob question

2006-08-14 Thread bearophileHUGS
Gerard Flanagan: > mod5 = ['1','2','3','4','5'] > X = [ ''.join([a,b,c,d,e]) > for a in mod5 > for b in mod5 > for c in mod5 > for d in mod5 > for e in mod5 ] A modified version of your one is the faster so far: v = "12345" r = [a+b+c+d+e for a in v for b in v for c

Re: yet another noob question

2006-08-14 Thread Gerard Flanagan
mike_wilson1333 wrote: > I would like to generate every unique combination of numbers 1-5 in a 5 > digit number and follow each combo with a newline. So i'm looking at > generating combinations such as: (12345) , (12235), (4) and so on. > What would be the best way to do this? So, basically i

Re: yet another noob question

2006-08-14 Thread bearophileHUGS
Stargaming: > Also note that reduce will be removed in Python 3000. Then let's use it until it lasts! :-) bearophile -- http://mail.python.org/mailman/listinfo/python-list

Re: yet another noob question

2006-08-14 Thread Stargaming
Jason Nordwick schrieb: > Or without filter: > > from operator import add > def pr(x): print x > def cross(x,y): return reduce(add, [[a+b for b in y] for a in x]) > x=map(pr, reduce(cross, [map(str,range(1,6))]*5)) > [...] reduce(add, list) is the same as sum(list) and is only half as fast as su

Re: yet another noob question

2006-08-13 Thread Jason Nordwick
better (sorry, still learning Python): def cross(x,y): return [a+b for a in x for y in b] Jason Nordwick wrote: > Or without filter: > > from operator import add > def pr(x): print x > def cross(x,y): return reduce(add, [[a+b for b in y] for a in x]) > x=map(pr, reduce(cross, [map(str,range(1,6)

Re: yet another noob question

2006-08-13 Thread Jason Nordwick
Or without filter: from operator import add def pr(x): print x def cross(x,y): return reduce(add, [[a+b for b in y] for a in x]) x=map(pr, reduce(cross, [map(str,range(1,6))]*5)) mike_wilson1333 wrote: > I would like to generate every unique combination of numbers 1-5 in a 5 > digit number and

Re: yet another noob question

2006-08-13 Thread Jason Nordwick
def pr(x): print(x) >>> x=map(pr,[x for x in xrange(11,56) if '1'<=min(str(x)) and >>> max(str(x))<='5']) 11 12 13 14 15 21 22 23 24 25 31 32 33 34 35 41 42 43 44 45 51 52 53 54 55 mike_wilson1333 wrote: > I would like to generate every unique combination of numbers 1-5 in a 5 > digit number an

Re: yet another noob question

2006-08-13 Thread [EMAIL PROTECTED]
Sybren Stuvel wrote: > mike_wilson1333 enlightened us with: > > I would like to generate every unique combination of numbers 1-5 in a 5 > > digit number and follow each combo with a newline. So i'm looking at > > generating combinations such as: (12345) , (12235), (4) and so on. > > Count fro

Re: yet another noob question

2006-08-13 Thread Cameron Laird
In article <[EMAIL PROTECTED]>, Alex Martelli <[EMAIL PROTECTED]> wrote: >mike_wilson1333 <[EMAIL PROTECTED]> wrote: > >> I would like to generate every unique combination of numbers 1-5 in a 5 >> digit number and follow each combo with a newline. So i'm looking at .

Re: yet another noob question

2006-08-13 Thread Paul Rubin
Paul Rubin writes: > Now you can use the function to print the list you wanted: > > for i in xrange(1234,1333): >print base5x(i, 5) Whoops, pasted the wrong thing from my test window. Sorry. That was supposed to say: for i in xrange(5**5): p

Re: yet another noob question

2006-08-13 Thread Paul Rubin
"mike_wilson1333" <[EMAIL PROTECTED]> writes: > I would like to generate every unique combination of numbers 1-5 in a 5 > digit number and follow each combo with a newline. So i'm looking at > generating combinations such as: (12345) , (12235), (4) and so on. > What would be the best way to do

Re: yet another noob question

2006-08-13 Thread bearophileHUGS
Simon Forman: > I originally meant this as a joke and was going to say not to use it. > But on my old, slow computer it only takes about a second or two. Another possibility, still using a filter: nodig = set("06789") r = [i for i in xrange(1, 5+1) if not (set(`i`) & nodig)] Bye, bearoph

Re: yet another noob question

2006-08-13 Thread Alex Martelli
mike_wilson1333 <[EMAIL PROTECTED]> wrote: > I would like to generate every unique combination of numbers 1-5 in a 5 > digit number and follow each combo with a newline. So i'm looking at > generating combinations such as: (12345) , (12235), (4) and so on. > What would be the best way to do t

Re: yet another noob question

2006-08-13 Thread Simon Forman
Stargaming wrote: > Stargaming schrieb: > > mike_wilson1333 schrieb: > > > >> I would like to generate every unique combination of numbers 1-5 in a 5 > >> digit number and follow each combo with a newline. So i'm looking at > >> generating combinations such as: (12345) , (12235), (4) and so on

Re: yet another noob question

2006-08-13 Thread Stargaming
Stargaming schrieb: > mike_wilson1333 schrieb: > >> I would like to generate every unique combination of numbers 1-5 in a 5 >> digit number and follow each combo with a newline. So i'm looking at >> generating combinations such as: (12345) , (12235), (4) and so on. >> What would be the best w

Re: yet another noob question

2006-08-13 Thread Rene Pijlman
Stargaming: >Generally, it is range(1, 5) Minus all numbers whose decimal string representation matches [0-9]*[06-9][0-9]* Briljant! -- René Pijlman -- http://mail.python.org/mailman/listinfo/python-list

Re: yet another noob question

2006-08-13 Thread Rene Pijlman
mike_wilson1333: >I would like to generate every unique combination of numbers 1-5 in >a 5 digit number [...] What would be the best way to do this? Ask the Java newsgroup to design a clever algorithm and post it here for pythonification. Ask for the pseudocode, not the Java code. -- René Pijlm

Re: yet another noob question

2006-08-13 Thread Simon Forman
mike_wilson1333 wrote: > I would like to generate every unique combination of numbers 1-5 in a 5 > digit number and follow each combo with a newline. So i'm looking at > generating combinations such as: (12345) , (12235), (4) and so on. > What would be the best way to do this? So, basically i'

Re: yet another noob question

2006-08-13 Thread Stargaming
mike_wilson1333 schrieb: > I would like to generate every unique combination of numbers 1-5 in a 5 > digit number and follow each combo with a newline. So i'm looking at > generating combinations such as: (12345) , (12235), (4) and so on. > What would be the best way to do this? So, basically

yet another noob question

2006-08-13 Thread mike_wilson1333
I would like to generate every unique combination of numbers 1-5 in a 5 digit number and follow each combo with a newline. So i'm looking at generating combinations such as: (12345) , (12235), (4) and so on. What would be the best way to do this? So, basically i'm looking for a list of all com