Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Rex4: pluralization

by Vynce (Friar)
on Sep 09, 2005 at 03:11 UTC ( [id://490417]=note: print w/replies, xml ) Need Help??


in reply to Re: Rere: pluralization
in thread pluralization

well, the abs() call is only there for the case of -1 -- you can take it out to compare against your case, or put some other check in to your case such that -1 == $count behaves the same as 1 == $count. otherwise you're comparing apples & oranges.

also, my snippet used two interpolations where yours reduced it to one ($noun versus the constant iteration) which doesn't make a huge difference, but again, them citrus fruits... time for me to run home. if you haven't rebenched, I'll set one up that's as parallel as possible except for x vs. ?:

ps: I don't know how the x operator is implemented, which is why i said "theoretically" faster -- as far as i can tell, there is no need for it to include a branch.

UP-dilly-DATE : OK, i didn't do it last night, but I did it. I made this small change:

sub sub1() { for my $count (0..2) { my $declension = 's' x ($count != 1); my $result = sprintf "$count iteration$declension so far...\n" +; } }

and got ... actually, quite similar results:

timethis 2000000: 52 wallclock secs (26.95 usr + 0.39 sys = 27.34 CPU +) @ 73152.89/s (n=2000000) timethis 2000000: 38 wallclock secs (25.47 usr + 0.34 sys = 25.81 CPU +) @ 77489.35/s (n=2000000)

Which is interesting, to me.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://490417]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (3)
As of 2024-04-26 06:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found