develooper Front page | perl.perl6.language | Postings from January 2009

Writing to an iterator

Thread Next
From:
Jon Lang
Date:
January 7, 2009 10:42
Subject:
Writing to an iterator
I was just reading through S07, and it occurred to me that if one
wanted to, one could handle stacks and queues as iterators, rather
than by push/pop/shift/unshift of a list.  All you'd have to do would
be to create a stack or queue class with a private list attribute and
methods for reading from and writing to it.  The first two parts are
easy: "has @!list;" handles the first, and "method prefix:<=> { .pop
}" handles the second (well, mostly).

How would I define the method for writing to an iterator?

-- 
Jonathan "Dataweaver" Lang

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About