> > Another win is in evaluation of lists constructed by generator
functions:
> >   # ($start: f(__): $end) == ($start, f($start), f(f($start)), ...)
> >   @powersOf2 = (1:__*2:); # (1, 2, 4, 8, ...)
> >   @first10PowersOf2 = @powersOf2[0..9]; # Calculates 1st 10 powers of 2
> >   # ...interesting manipulation of @first10PowersOf2...
> >   @first20PowersOf2 = @powersOf2[0..19] # Calculates 2nd 10 powers of 2
(1st
> > 10 are already computed!)
>
> This is another straightforward "forwards list"; it has the order type
> of (1..), not of (..-1).
>
> Please post examples of places where "generalised lists" of other
> order types are useful.
>
OK, give me a moment. I'm writing an RFC for list generators with some of
the PDL folk, and I'll make sure there's a "backwards list" example in
there. It's no big deal though, I don't mind writing:
  reverse (map {-$_} (1..));
if I have too.

> > <...>
>
> MJD has a perl5 package which does memoization; this is exactly what
> you want.
>
Yes, very nice it is too:
http://www.plover.com/~mjd/perl/MiniMemoize/memoize.html
http://www.plover.com/~mjd/perl/Memoize/

There seems to be an opportunity to integrate generators, iterators,
memoizaion and lists nicely, with very little new syntax. This is what I'm
trying to investigate here. Also, perl might be able to do some
optimisations for us (such as the 'Orcish maneuver') if it knew about this
stuff.


Reply via email to