Perl 6 Perl 6 Lists and Arrays vivified #32

Infinite arrays

A Fibonacci example:

> my @a = 1, 1, *+* ... *;
1 1 2 3 ...
> say @a[10]
89
> say @a[3]
3
> say @a[^8]
1 1 2 3 5 8 13 21
> say @a[12]
233

Memoization is effectively "built-in", computing each new number in the sequence only occurs once.

Copyright © 2012
http://www.pmichaud.com/2012/pres/