Re: [Boston.pm] Combinatorics (Permutations)

2005-12-01 Thread Jeremy Muhlich
On Wed, 2005-11-30 at 02:16 -0500, Aaron Sherman wrote: > Ronald J Kimball wrote: > > >my @indices = (0) x $maxlen; > > > > > I have no idea why, because it's not more efficent or anything, but I > always find myself writing: > > my @indices = map { 0 } 1..$maxlen; I believe the latter is qui

Re: [Boston.pm] Combinatorics (Permutations)

2005-11-30 Thread Gyepi SAM
On Wed, Nov 30, 2005 at 12:34:58PM -0500, Andrew Medico wrote: > The anwser is that there is no such thing as a list of lists in Perl - Don't forget the footnotes: my @lol = map { [ $_ ] } (0 .. 7); my $lol = [map { [ $_ ] } (0 .. 7)]; The former is a list of list refs and the latter is a list r

Re: [Boston.pm] Combinatorics (Permutations)

2005-11-30 Thread Andrew Medico
On Wed, 30 Nov 2005, Federico Lucifredi wrote: > Hello Ron, > > > > > Thanks Ron -- that works, but I don;t understand it... I thought x could > > > be used only on quoted literals, I guess I was wrong there. On top of > > > that, (0) x 4 should yield (0) (0) (0) (0) ... and generate a list of > >

Re: [Boston.pm] Combinatorics (Permutations)

2005-11-30 Thread Federico Lucifredi
Hello Ron, > > Thanks Ron -- that works, but I don;t understand it... I thought x could > > be used only on quoted literals, I guess I was wrong there. On top of > > that, (0) x 4 should yield (0) (0) (0) (0) ... and generate a list of > > lists - or should it ? > > > > Here's a question for

Re: [Boston.pm] Combinatorics (Permutations)

2005-11-30 Thread Ronald J Kimball
On Wed, Nov 30, 2005 at 11:24:24AM -0500, Federico Lucifredi wrote: > On Wed, 2005-11-30 at 00:29 -0500, Ronald J Kimball wrote: > > On Wed, Nov 30, 2005 at 12:24:47AM -0500, Federico Lucifredi wrote: > > > On Wed, 2005-11-30 at 00:13 -0500, Ron Newman wrote: > > > > > > humm, that would give me a

Re: [Boston.pm] Combinatorics (Permutations)

2005-11-30 Thread Federico Lucifredi
On Wed, 2005-11-30 at 00:29 -0500, Ronald J Kimball wrote: > On Wed, Nov 30, 2005 at 12:24:47AM -0500, Federico Lucifredi wrote: > > On Wed, 2005-11-30 at 00:13 -0500, Ron Newman wrote: > > > > humm, that would give me a single element in $indices[0] equal to > > "", while what we really want

Re: [Boston.pm] Combinatorics (Permutations)

2005-11-29 Thread Aaron Sherman
Ronald J Kimball wrote: >my @indices = (0) x $maxlen; > > I have no idea why, because it's not more efficent or anything, but I always find myself writing: my @indices = map { 0 } 1..$maxlen; The nice thing about it is that I tend to think of map even when I want something very slightly diff

Re: [Boston.pm] Combinatorics (Permutations)

2005-11-29 Thread Ronald J Kimball
On Wed, Nov 30, 2005 at 12:24:47AM -0500, Federico Lucifredi wrote: > On Wed, 2005-11-30 at 00:13 -0500, Ron Newman wrote: > > humm, that would give me a single element in $indices[0] equal to > "", while what we really want is @indices[0..3] = (0,0,0,0)... > except, of $maxlen length :) > >

Re: [Boston.pm] Combinatorics (Permutations)

2005-11-29 Thread Federico Lucifredi
On Wed, 2005-11-30 at 00:13 -0500, Ron Newman wrote: > On Nov 30, 2005, at 12:03 AM, Federico Lucifredi wrote: > > > my $maxlen = 4; > > > > my @indices = (0, 0, 0, 0); # how do I init this array so that it is > > $maxlen zeros long ? > humm, that would give me a single element in $indices[0] equ

Re: [Boston.pm] Combinatorics (Permutations

2005-11-29 Thread Federico Lucifredi
On Wed, 2005-11-30 at 00:03 -0500, Federico Lucifredi wrote: [...] > the sub in an Iterator, it did not really answer what I wanted, so I > wrote my own, and I am polishing my own. > your owning own own ? I think a YAWN might be in order. I am going to bed 8) -f

Re: [Boston.pm] Combinatorics (Permutations

2005-11-29 Thread Ron Newman
On Nov 30, 2005, at 12:03 AM, Federico Lucifredi wrote: > my $maxlen = 4; > > my @indices = (0, 0, 0, 0); # how do I init this array so that it is > $maxlen zeros long ? my @indices = 0 x $maxlen; >unless (++$i == $maxlen) >{ last; } # can we get rid of some braces somehow ?!

Re: [Boston.pm] Combinatorics (Permutations

2005-11-29 Thread Federico Lucifredi
Hello William, I have perused HOP, but I find that, besides the gooi idea of wrapping the sub in an Iterator, it did not really answer what I wanted, so I wrote my own, and I am polishing my own. The idea is as following: generating Strings (aka "Permutations with Repetition) can be done using r