Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

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.

Replies are listed 'Best First'.
Re^3: Array iterator factory (&)
by tye (Sage) 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?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://440107]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (6)
As of 2018-06-21 01:00 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (117 votes). Check out past polls.