Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Schwartzian Transform vs. Building Hash of Function Results, Then Sorting on Function Results

by Limbic~Region (Chancellor)
on Oct 16, 2006 at 19:10 UTC ( #578573=note: print w/ replies, xml ) Need Help??


in reply to Schwartzian Transform vs. Building Hash of Function Results, Then Sorting on Function Results
in thread Schwartzian Transform

davebaker,
In both cases, you are calculating the expensive_func() only once per item and sorting the list based off the result of the expensive_func(). The biggest difference is that in the standard ST, you do it in a single step and have no left over variable.

Cheers - L~R


Comment on Re: Schwartzian Transform vs. Building Hash of Function Results, Then Sorting on Function Results
Left over variable
by davebaker (Monk) on Oct 16, 2006 at 19:35 UTC
    Thanks! I hadn't considered the left over variable. I'd want to add this line before my sorted-hash code snippet:
    my %result_for;
    (That doesn't eliminate any drawbacks to having a left over variable as compared to the ST, but it would be safer coding I think.)

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (14)
As of 2014-12-18 07:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (44 votes), past polls