Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re^2: Array iterator factory

by Roy Johnson (Monsignor)
on Mar 16, 2005 at 19:30 UTC ( #440107=note: print w/ replies, xml ) Need Help??


in reply to Re: Array iterator factory
in thread Array iterator factory

If I took a list, I'd have to make and store a copy of its contents. It would be expensive, and it would not see subsequent changes to the original array. I wanted a lightweight iterator tied to a user-modifiable array.

The user can create an anonymous array and slap an iterator on it, if he so desires: array_iterator(@{[1..10]}). That makes it obvious that this iterator can't give you the free lunch that for (1..10) does.


Caution: Contents may have been coded under pressure.


Comment on Re^2: Array iterator factory
Select or Download Code
Re^3: Array iterator factory (&)
by tye (Cardinal) on Mar 17, 2005 at 03:25 UTC

    Don't forget the power of &array_iterator([1..10]).

    - tye        

        Ah, it's related to ihb's post.

        No, not directly. ihb's post is about avoiding using ampersand without parens to call subroutines except for "advanced purposes" (if you don't know what those are, then you shouldn't be doing them). Using ampersand with parens is great for bypassing prototypes and/or for ensuring you call a user-defined function even if there might be a built-in function by the same name.

        - tye        

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (8)
As of 2014-12-25 08:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

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





    Results (159 votes), past polls