> @u = [..]; # @a contains the univeral set
> works just fine, so I can then say:
> @i = grep {$_=abs($_)} @u; # @i contains the integers
> # See higher-order function and multi-way comparison RFCs
> $s = sum (grep 0<__<=100 @i);
> print "The sum of the 1st 100 integers is: $s";
>
Oops, a correction. [..] should mean 'the set of all integers'. _Not_ the
univeral set. So my code snippet should be:
@i = [..]; # @i contains the integers
$s = sum (grep 0<__<=100 @i);
print "The sum of the 1st 100 integers is: $s";
I still think it would be cool to be able to specify other infinite sets
somehow (with rationals, with complex, etc) but [..] isn't the right way.
Sorry about that.
- RFC 24 (v1) Semi-finite (lazy) lists Perl6 RFC Librarian
- Re: RFC 24 (v1) Semi-finite (lazy) lists Ariel Scolnicov
- Re: RFC 24 (v1) Semi-finite (lazy) lists Chaim Frenkel
- Re: RFC 24 (v1) Semi-finite (lazy) lists Damian Conway
- Re: RFC 24 (v1) Semi-finite (lazy) lists Ted Ashton
- Re: RFC 24 (v1) Semi-finite (lazy) lists Jeremy Howard
- Re: RFC 24 (v1) Semi-finite (lazy) lists Damian Conway
- Re: RFC 24 (v1) Semi-finite (lazy) lists Jeremy Howard
- Re: RFC 24 (v1) Semi-finite (lazy) lists Jeremy Howard
- Re: RFC 24 (v1) Semi-finite (lazy) lists Mike Pastore
- Re: RFC 24 (v1) Semi-finite (lazy) lists Jeremy Howard
- Re: RFC 24 (v1) Semi-finite (lazy) lists Jeremy Howard
- Re: RFC 24 (v1) Semi-finite (lazy) lists Ariel Scolnicov
- Re: RFC 24 (v1) Semi-finite (lazy) lists Jeremy Howard
- Re: RFC 24 (v1) Semi-finite (lazy) li... Ariel Scolnicov
- Re: RFC 24 (v1) Semi-finite (laz... Jeremy Howard
- Re: RFC 24 (v1) Semi-finite ... Ariel Scolnicov
- Infinite lists (was Re: ... Jeremy Howard
- Re: Infinite lists (was ... Ken Fox
