Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re (tilly) 6: Golf: Tree searching

by tilly (Archbishop)
on Apr 20, 2001 at 15:18 UTC ( #74133=note: print w/ replies, xml ) Need Help??


in reply to Re^5: Golf: Tree searching
in thread Golf: Tree searching

A tip. Whenever possible go for the one-line looping constructs. The following two are equivalent logically:

for(A;B;C){} A;C while B;
however the second has 3 characters you may be able to drop. So use it. Even if it means using commas etc in C to get it to work, use it. (I am able to drop the 2 spaces.) A technicality, to be sure, but a significant one.

Also while the binding of and can make it better than &&, if you see it used that way, look for a way to move things around to get the && in somewhere and save a character. Watch:

sub f { $t=pop;$t=$$t{$c>0?l:r}while$c=$t&&$$t{d}cmp$_[0];$t }
Not something you would write from scratch, but there you have it...


Comment on Re (tilly) 6: Golf: Tree searching
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (4)
As of 2015-07-30 04:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (269 votes), past polls