"Jeremy Howard" writes:-

> Yes, I like it too, but the problem is that $end may not be reached:
> 
>   @weird = (0..5: ^0 mod 2);
> 
> is an infinite loop under this proposal. That's not necessarily a dead-end,
> but it seems pretty dangerous. 

Like for (;;) ?  Or 1:11:-1 !

> The $num_steps proposal could be a lot faster
> too, because a fast loop could be generated (particularly if we define some
> functions that are easily optimised, like ufuncs in Numeric Python):
> 
>   http://starship.python.net/~da/numtut/array.html#SEC13

Yes, I agree that $num_steps is needed somewhere, and should at least
be flagged in the `efficiency' section of the Camel.  I just don't
like $start..&gen:$num_steps, unless 1..11:2 gives (1,11) not
(1,3,5,7,9,11)...but would rather 1..11:2 gave (1,3,5,7,9,11)...

Recursion is also a performance hit, of course, if you're ever likely
to want only the 1000th element of the Fibonnacci series, etc.

> > @start : &test : &inc

> Yes, when I had the $end notation, I was planning to provide an &test syntax
> too--I think if you had one you'd want both. BTW, the element number is
> always available as the first argument to the list generation function.

Maybe easily optimized &test-s could implement $num_steps...?
 
> > o Or even
> > 2 x 10 : &gen
> > -- at least, I'd _expect_ to get 10 things here!  2x10 <=> 2..sub{0}:10
> > as TMTOWTDI seems a tad curious, on reflection.
> >
> Hmmm... an interesting one. Starting to look more Perlish and less
> Matlabish, which may be a good or a bad thing depending on where you're
> coming from...

A desire for `analogic' is probably a form of laziness, at least ;-)
[...but I meant to keep the matlabish $start:$end:&gen as well!]

        Robin

Reply via email to