[Date Prev][Date Next][Thread Prev][Thread Next]
[Search]
[Date Index]
[Thread Index]
Re: [FWP] string increment
On Sun, 23 Apr 2000, Ronald J Kimball wrote:
> On Mon, Apr 24, 2000 at 05:39:36AM +0200, Arjen Wiersma wrote:
> >
> > > > perl -e '@a=qw(a a a a); for($i=$#a;-1 < $i; $i--) {
> > > > for($x=0;$x<25;$x++) {$b = ord($a[$i]); $a[$i] = chr(++$b); print
> > > > @a; print "\n"; } }'
> > > >
> > > > since it's 5 am and my mind went to bed at about 3 this morning I'm sure
> > > > there are faster ways of doing this.. maybe even get caps into it too..
> > > >
> > > > Any ideas?
> > >
> > > perl -le 'print for "aaaa" .. "zzzz"'
> > >
> > >
> > > Magical string increment, you know.
> > >
> > >
> > > Ronald
> > >
> >
> > Heh, yeah.. I came up with that too, but that increments each character
> > with the entire alphabet to each character. If you look at the code I
> > wrote it goes it just increments the line, forming the alphabet for
> > each character in the line. One by one.
>
> Oh, your sample output wasn't specific enough. :)
>
Then I apologize for the misperception that you would try the code too :)
>
> > I was wondering if that could be speeded up?
>
> How about:
>
> perl -le '$_ = "aaaa"; for ($i=length($_)-1; $i>=0; --$i) {
> for $c ("a".."z") { substr($_,$i,1) = $c; print } }'
>
Heh... hadn't even thought about doin it that way... could be the
time.. could be my love for doin everything difficult :)...
Any ideas on how to squeez caps in there to?
Once again i send you my kindest regards,
Arjen
==== Want to unsubscribe from Fun With Perl? Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
==== unsubscribe