Re: rethinking printf

2002-03-10 Thread Vicki Brown
Listmom tries to keep this a self-moderating list, but alas, Listmom has had a complaint. This thread started out as fun ("How Would YOU Do It?" is an acceptable topic for FWP) but has become more meta discussion and less fun with Perl. Please move any further design to [EMAIL PROTECTED] Thanks

Re: rethinking printf

2002-03-10 Thread ianb
On 10 Mar 02 at 11:14:26PM, Uri Guttman wrote: > i really think that the printf format spec is so standard and ingrained > that changing it with # for % or requiring \% is not a good idea. > > but then again, backwards compatibility is not a rule you must always > obey. i just think in this case

Re: rethinking printf

2002-03-10 Thread Uri Guttman
> "PS" == Peter Scott <[EMAIL PROTECTED]> writes: PS> At 01:39 AM 3/11/02 +0100, Eugene van der Pijll wrote: >> Why not replace the escape character '%' with '#'? No new quoting >> operators or functions to learn. PS> Beat me to it. >> And introduce a warning if there are >> no

Re: Perl Golf as a sport

2002-03-10 Thread Andrew . Savige
En op 10 maart 2002 sprak Dave Hoover: > Reminiscent of my football days, I often find myself jumping > around like a buffoon after discovering a better algorithm. Already, Perl golf is showing potential as a TV spectator sport. Imitating the all-conquering Aussie cricket team, I myself indulge

Re: Perl Golf as a sport

2002-03-10 Thread Ronald J Kimball
On Mon, Mar 11, 2002 at 12:31:25PM +1100, [EMAIL PROTECTED] wrote: > > I know, from bitter experience with Acme::EyeDrops, just how flaky > the (?{}) construct is; normally you cannot use regular expressions > inside it at all "because Perl's regex engine is not reentrant". > And yet, mysteriousl

Re: Perl Golf as a sport

2002-03-10 Thread Rick Klement
[EMAIL PROTECTED] wrote: > > En op 10 maart 2002 sprak Eugene van der Pijll: > > Actually, I did look for other solutions; I just could not find them. > > I did not try the s///eg within s///eg way, as I was sure that > > couldn't work. Earlier, I had tried things like m#___(?{___/./___})___#, >

Re: rethinking printf

2002-03-10 Thread Peter Scott
At 01:39 AM 3/11/02 +0100, Eugene van der Pijll wrote: >Why not replace the escape character '%' with '#'? No new quoting >operators or functions to learn. Beat me to it. >And introduce a warning if there are >no #'s in the format string. Maybe if it's a constant, but not if you're doing someth

Re: Perl Golf as a sport

2002-03-10 Thread Andrew . Savige
En op 10 maart 2002 sprak Eugene van der Pijll: > Actually, I did look for other solutions; I just could not find them. > I did not try the s///eg within s///eg way, as I was sure that > couldn't work. Earlier, I had tried things like m#___(?{___/./___})___#, > which produced an error message abou

Re: rethinking printf

2002-03-10 Thread Uri Guttman
> "BD" == Brent Dax <[EMAIL PROTECTED]> writes: BD> Uri Guttman: BD> # $prec = %hash{width} ; BD> # sprintf( qf"%${prec}s", $string); BD> # BD> # sprintf( "\%${prec}s", $string); BD> # BD> # is one of your alternatives. :-/ BD> You forgot one. BD> sprintf('%'_%hash{width

RE: rethinking printf

2002-03-10 Thread Brent Dax
Uri Guttman: # > "BD" == Brent Dax <[EMAIL PROTECTED]> writes: # # BD> I think qn counts as weird syntax. I ask again, what's # wrong with one # BD> of: # # BD> sprintf("%hash\%s", $string); # # BD> sprintf(%hash.'%s', $string); # BD> sprintf('%s%s', _%hash,

Re: rethinking printf

2002-03-10 Thread Eugene van der Pijll
Why not replace the escape character '%' with '#'? No new quoting operators or functions to learn. And introduce a warning if there are no #'s in the format string. Eugene

Re: Perl Golf as a sport

2002-03-10 Thread Ton Hospel
In article <[EMAIL PROTECTED]>, Eugene van der Pijll <[EMAIL PROTECTED]> writes: > > Turn off the computer and go do something else that does not require > much thinking. I get most ideas in the shower, in bed just before I go > to sleep, or while riding a bike to/from work. (If anyone on

Re: Perl Golf as a sport

2002-03-10 Thread Ton Hospel
In article <[EMAIL PROTECTED]>, Rick Klement <[EMAIL PROTECTED]> writes: >> Turn off the computer and go do something else that does not require >> much thinking. I get most ideas in the shower, in bed just before I go >> to sleep, or while riding a bike to/from work. (If anyone on fwp liv

Re: Perl Golf as a sport

2002-03-10 Thread Eugene van der Pijll
En op 10 maart 2002 sprak Rick Klement: > That split$& was a brilliant move, not ugly at all. I look at that one as > asking the right question: "do you want to count items, or the gaps > between items?" Sometimes it's not finding a good answer that's important, > it's finding a good question! Y

Re: rethinking printf

2002-03-10 Thread Uri Guttman
> "BD" == Brent Dax <[EMAIL PROTECTED]> writes: BD> I think qn counts as weird syntax. I ask again, what's wrong with one BD> of: BD> sprintf("%hash\%s", $string); BD> sprintf(%hash.'%s', $string); BD> sprintf('%s%s', _%hash, $string); what if you want to use %hash{width}

Re: rethinking printf

2002-03-10 Thread Uri Guttman
> "YS" == Yitzchak Scott-Thoennes <[EMAIL PROTECTED]> writes: YS> Uri Guttman <[EMAIL PROTECTED]> wrote: >> i disagree. but we shall see if larry is listening to this thread and >> will back away from hash interpolation or take some of our suggestions >> that make it work without kil

Re: Perl Golf as a sport

2002-03-10 Thread Rick Klement
Eugene van der Pijll wrote: > > En op 10 maart 2002 sprak [EMAIL PROTECTED]: > > > Rick is a brilliant golfer and I feel sure he would have found the > > same "ugly" improvement from s/$&/$&/g to split$& had he not been > > suffering from the giggles. > > That was NOT an ugly improvement, IMNSH

Re: Sort is lazy?!? (as in Haskell)

2002-03-10 Thread Andrew Pimlott
On Sun, Mar 10, 2002 at 11:11:00PM +, Jonathan E. Paton wrote: > > > A lazy sort can be done in n time, easily: > > > > > > @highest; > > > foreach element { > > >if (element > lowest in @highest) { > >^^ > > You haven't kept @highest sorted, so there i

Re: Sort is lazy?!? (as in Haskell)

2002-03-10 Thread Jonathan E. Paton
> > The Big Oh of that is n. > > No, it's not. It's O (n log X). Okay, I was working from the original example of just taking the first element - hence log X = O(1). Yes, using O(n log X) is more accurate. Arg!!! We're back into arguing over the finer points little and Big Oh. That ain't fun

Re: Sort is lazy?!? (as in Haskell)

2002-03-10 Thread Jonathan E. Paton
> > A lazy sort can be done in n time, easily: > > > > @highest; > > foreach element { > >if (element > lowest in @highest) { >^^ > You haven't kept @highest sorted, so there is another > factor of n. Nope, not so. @highest is of a fixed size, and hence r

Re: Sort is lazy?!? (as in Haskell)

2002-03-10 Thread abigail
On Sun, Mar 10, 2002 at 10:16:05PM +, Jonathan E. Paton wrote: > > > PS With a truly lazy sort you'd be able to do... > > > > > > ($first) = sort { $a wibble $b } @big_list; # in O(n) > > time. > > > > Not necessarely - it would depend on the underlaying > > sorting mechanism. > > It woul

Re: Perl Golf as a sport

2002-03-10 Thread Eugene van der Pijll
En op 10 maart 2002 sprak [EMAIL PROTECTED]: > Rick is a brilliant golfer and I feel sure he would have found the > same "ugly" improvement from s/$&/$&/g to split$& had he not been > suffering from the giggles. That was NOT an ugly improvement, IMNSHO. When I thought up the idea of counting the

Re: rethinking printf

2002-03-10 Thread Rich Morin
Earlier, I mentioned the idea of replacing overly complicated "printf"s with a "print" and some "f" function calls, as: { $a=1828; $b=45; print f("pi=%8.6f, ",355/113), f("e=2.7$a$a$b%d$b\n", $b*2); } Now, "f" is really just shorthand for "sprintf", but cr

Re: Sort is lazy?!? (as in Haskell)

2002-03-10 Thread Andrew Pimlott
On Sun, Mar 10, 2002 at 10:16:05PM +, Jonathan E. Paton wrote: > A lazy sort can be done in n time, easily: > > @highest; > foreach element { >if (element > lowest in @highest) { ^^ You haven't kept @highest sorted, so there is another factor of n. >

Re: Sort is lazy?!? (as in Haskell)

2002-03-10 Thread Jonathan E. Paton
> > PS With a truly lazy sort you'd be able to do... > > > > ($first) = sort { $a wibble $b } @big_list; # in O(n) > time. > > Not necessarely - it would depend on the underlaying > sorting mechanism. It wouldn't be lazy then, would it? > Shell sort and heap sort for instance don't get the >

Re: rethinking printf

2002-03-10 Thread Yitzchak Scott-Thoennes
In article <[EMAIL PROTECTED]>, "Brent Dax" <[EMAIL PROTECTED]> wrote: > >There's only a clash if you double-quote the format string anyway, which >is a rare thing to need to do at all. I'd expect that a hefty percentage of format strings have a \n.

RE: rethinking printf

2002-03-10 Thread Brent Dax
Abigail: # I'd think it would be much better that '%' followed by a word *not* # followed by a { isn't interpolated. Granted, you cannot do # interpolation # of hashes (well, one could always write "@{[%hash]}", just # like in perl5, # and there's little change of clashing with printf formats. # T

RE: rethinking printf

2002-03-10 Thread Brent Dax
Uri Guttman: # i disagree. but we shall see if larry is listening to this thread and # will back away from hash interpolation or take some of our suggestions # that make it work without killing format strings. i hate to see a # special call or wierd syntax for that. my qn (or qf) # suggestion seem

Re: rethinking printf

2002-03-10 Thread Rafael Garcia-Suarez
I just wrote : > > qc// ? (Mnemonic : "Quote like in C") Couldn't resist to implement this ;-) There are probably bugs (not speaking about trigraphs) but this package makes available a qc// operator that should do this. package QC; use strict; use warnings; use Exporter; use Sub::Quotelike; o

Re: rethinking printf

2002-03-10 Thread Rafael Garcia-Suarez
Keith C. Ivey wrote in perl.fwp: > Uri Guttman <[EMAIL PROTECTED]> wrote: > >> i hate to see a >> special call or wierd syntax for that. my qn (or qf) suggestion seems >> to have some backing and it is clean and unobtrusive. > > Your qn() suggestions seems weird itself. It's too strange to have

Re: rethinking printf

2002-03-10 Thread Yitzchak Scott-Thoennes
<[EMAIL PROTECTED]> <[EMAIL PROTECTED]> <[EMAIL PROTECTED]> Lines: 17 In article <[EMAIL PROTECTED]>, Uri Guttman <[EMAIL PROTECTED]> wrote: >i disagree. but we shall see if larry is listening to this thread and >will back away from hash interpolation or take some of our suggestions >that make

Re: Perl Golf as a sport

2002-03-10 Thread Dave Hoover
Andrew wrote: > It is clear from recent games that Perl Golf is a sport, Yes, but I think more importantly, it is a vehicle to help the participants learn more about Perl and how to let go of one's "bright ideas". > 1) Don't get too emotional. Aim for a mental state of relaxed >indifference.

Re: rethinking printf

2002-03-10 Thread Keith C. Ivey
Uri Guttman <[EMAIL PROTECTED]> wrote: > i hate to see a > special call or wierd syntax for that. my qn (or qf) suggestion seems > to have some backing and it is clean and unobtrusive. Your qn() suggestions seems weird itself. It's too strange to have a special quoting method that allows inter

Re: TPR1 post-mortem

2002-03-10 Thread Rick Klement
Ian Phillipps wrote: > > On Fri, 08 Mar 2002 at 18:27:00 +, Stephen Turner wrote: > > I've looked quickly at all the entries up to 55 strokes, and identified the > > following methods for difficult bits of the problem. Apologies for errors > > and omissions! > > > Methods for pulling off all

Re: TPR1 post-mortem

2002-03-10 Thread Ian Phillipps
On Fri, 08 Mar 2002 at 18:27:00 +, Stephen Turner wrote: > I've looked quickly at all the entries up to 55 strokes, and identified the > following methods for difficult bits of the problem. Apologies for errors > and omissions! > Methods for pulling off all pairs of characters: > > /(?=(..).

Re: rethinking printf

2002-03-10 Thread Uri Guttman
> "a" == abigail <[EMAIL PROTECTED]> writes: a> On Wed, Mar 06, 2002 at 11:15:30PM -0500, Uri Guttman wrote: >> >> good point. $() can still wrap that but then there has to be a balance >> between printf strings and double quoters. how about this wacky idea: >> >> make a new ty

Re: rethinking printf

2002-03-10 Thread abigail
On Wed, Mar 06, 2002 at 11:15:30PM -0500, Uri Guttman wrote: > > "BL" == Bart Lateur <[EMAIL PROTECTED]> writes: > > BL> On Wed, 6 Mar 2002 17:57:07 -0500, Uri Guttman wrote: > >> how often will you need to interpolate a hash? > > BL> A whole hash: quite rarely. A hash item: a LOT. Don

Re: Sort is lazy?!? (as in Haskell)

2002-03-10 Thread abigail
On Sun, Mar 03, 2002 at 01:13:32PM -0500, Michael G Schwern wrote: > PS With a truly lazy sort you'd be able to do... > > ($first) = sort { $a wibble $b } @big_list; # in O(n) time. Not necessarely - it would depend on the underlaying sorting mechanism. Shell sort and heap sort for instance

Re: Perl Golf as a sport

2002-03-10 Thread Rick Klement
"Jonathan E. Paton" wrote: > > > > > It is clear from recent games that Perl Golf is > > > > a sport > > > > > > Yep, put it in the Olympics, gotta be better than > > > some of the stuff they try! > > > > No, no, no... it's too violent and painful a sport > > to watch... > > It's definately not

Re: Perl Golf as a sport

2002-03-10 Thread Jonathan E. Paton
> > > It is clear from recent games that Perl Golf is > > > a sport > > > > Yep, put it in the Olympics, gotta be better than > > some of the stuff they try! > > No, no, no... it's too violent and painful a sport > to watch... It's definately not for the kids. > All that hair pulling, and heads

Re: Perl Golf as a sport

2002-03-10 Thread Rick Klement
Owen Cook wrote: > > On Sun, 10 Mar 2002 16:05:01 +1100, you penned: > > >It is clear from recent games that Perl Golf is a sport > > Yep, put it in the Olympics, gotta be better than some of the stuff they try! > > Owen No, no, no... it's too violent and painful a sport to watch... All that

Re: Perl Golf as a sport

2002-03-10 Thread F . Xavier Noria
On Sun, 10 Mar 2002 16:05:01 +1100 [EMAIL PROTECTED] wrote: : It is clear from recent games that Perl Golf is a sport, : not so different from chess, or real golf for that matter. : There is strategy there, and tactics too -- with tactics : predominant, in my opinion. Thank you very much for sha