Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re^4: Overcoming addiction to Lisp

by Anonymous Monk
on Jun 16, 2005 at 20:01 UTC ( [id://467423]=note: print w/replies, xml ) Need Help??


in reply to Re^3: Overcoming addiction to Lisp
in thread Overcoming addiction to Lisp

Maybe I missed it, but why would dostrings need to be a macro, instead of a function? And if you don't like making up non-sense names, just use perl's default name, $_. Besides, it really sounds like you should be using the builtin list traversal operators like grep, map, and foreach instead of rolling your own.

Replies are listed 'Best First'.
Re^5: Overcoming addiction to Lisp
by runrig (Abbot) on Jun 16, 2005 at 20:20 UTC
    ...it really sounds like you should be using the builtin list traversal operators...

    The code is not traversing a list. It is creating an iterator, and executing a block of code for each item returned by the iterator. You might argue that a foreach{...} is an iterator, but that would require generating the entire list first, which may not be appropriate here. In perl it would be more like:

    my $nxt_str = make_strings($n); while (my $str = $nxt_str->()) { #..do stuff with $str }

      Or else you could use a tied array, and that way you'll get to use all the standard array goodies, without reinventing the wheel.
        A tied array would require more infrastructure (i.e. it's more cumbersome to make, which is just MHO and an arguable point), and I don't see that creating a simple iterator is reinventing the wheel, especially seeing as how there's a pretty decent book out with chapters on this very thing.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (5)
As of 2024-04-24 18:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found