Codebits

Compute the 5th Fibonacci number using the Curry programming language:
fibolist x0 x1 = x0 : fibolist x1 (x0+x1)
nth n (x:xs) = if n==1 then x else nth (n-1) xs
nth 5 (fibolist 0 1)

The first line, along with the expression (fibolist 0 1) defines an infinite-length list of Fibonacci numbers. This list is lazilly evaluated so as not to consume all RAM. The second line declares a function that returns the nth element of a provided list. "nth" is applied to the list of Fibonacci numbers on the third line.

Source: Curry: A Tutorial Introduction .

An analogous thing may be done in Perl as such

use Tie::LazyList;
tie my @fibolist, 'Tie::LazyList', [1, 1],
    sub { my($arrayref, $n) = @_;  $arrayref->[$n-2] + $arrayref->[$n-1] };
print $fibolist[5-1];