Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

Re (tilly) 2: Let's get lazy

by tilly (Archbishop)
on Nov 02, 2001 at 17:07 UTC ( #122795=note: print w/replies, xml ) Need Help??

in reply to Re: Let's get lazy
in thread Let's get lazy

A much better person to ask is Dominus, he is in the process of writing a book on exactly this subject.

Chapter 4 in particular offers direct iterative solutions of the above problem. Once you know the techniques, they are straightforward to apply in any language with proper support for closures. And the techniques are essentially to create utility functions that take one iterator and create new ones out of it. For instance if you like doing stuff procedurally with map, grep, an easy way to produce a range etc, then you can create iterative versions of the same. (For instance a range would return all of the things in that range. An iterative map would take a function and an iterator and give you an iterator that is the result of applying that function to the output of the first iterator.) And then it becomes a mechanical process to write iterative versions of what you can dream up in a list-oriented manner.

Alternately if you want the flavour of a co-routine solution to the problem, and don't want to wait for Perl 6, Ruby offers them now. So, I believe, does the very latest version of Python. (Ruby goes further and people there use them more often.) They don't offer the rest of Perl 6, but they give you the flavour of a Perlish scripting language with yield and (with Ruby or stackless Python) full continuations.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://122795]
[Lady_Aleena]: Well, not much of my code. A few little things people here like. The big things though, the more important to me code, people here seem to loathe.
[atcroft]: Lady_Aleena: My early code was pretty horrible... but somewhere early on I learned not to take criticism of my code personally... which was probably a good thing, considering the kind of code I wrote at the time. :\
[Lady_Aleena]: I am hungry, so I'm going to go make something to eat. I hope you figure it out atcroft. Have a nice night!
[atcroft]: I have one script that I have started re-writing several times over the years, and have yet to get it working in a cleaner/better form. (It is some smelly code-I did not even know about hashes at the time I wrote it.)
[atcroft]: Enjoy, Lady_Aleena!

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (7)
As of 2017-05-27 05:30 GMT
Find Nodes?
    Voting Booth?