Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Optimizations and Efficiency

by bobione (Pilgrim)
on Jun 30, 2001 at 14:38 UTC ( [id://92893]=note: print w/replies, xml ) Need Help??


in reply to Optimizations and Efficiency

Monk dimmesdale,
I don't understand your first exemple...
It appear to me that it's not the same things:
This...

for($i = 0; $i <= 10_000; $i++) { $ary[$i] = init_val($i); }

means...

$ary[0] = init_val(0) $ary[1] = init_val(1) $ary[2] = init_val(2) ...

and...

$idx = 0; for($i = 0; $i < 10_000; $i += 10) { $ary[$idx++] = init_val($i); $ary[$idx++] = init_val($i); $ary[$idx++] = init_val($i); ... }

means...

$ary[0] = init_val(0) $ary[1] = init_val(0) $ary[2] = init_val(0) ... $ary[10] = init_val(10) $ary[11] = init_val(10) $ary[12] = init_val(10) ...

It should be :

$idx = 0; for($i = 0; $i < 10_000; $i += 10) { $ary[$idx++] = init_val($idx); $ary[$idx++] = init_val($idx); $ary[$idx++] = init_val($idx); ... }

Am I wrong ?

BobiOne KenoBi ;)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (4)
As of 2024-04-24 11:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found