Displaying 1 result from an estimated 1 matches for "haaskel".
Did you mean:
haskel
2011 Apr 08
1
R and lazy evaluation
Haskell is the prototypical lazy evaluation language. One can compute a
Fibonacci sequence by the Haaskell equivalent of the following R code.
> fibs <- c(0, 1, rep(0, 8))
> fibs[3:10] <- fibs + fibs[-1]
This works as follows.
fibs = 0, 1, 0, 0, 0, 0, 0, 0, 0, 0
fibs = 0, 1, 0, 0, 0, 0, 0, 0, 0, 0
When one adds fibs to fibs[-1], one is effectively adding diagonally:
fibs[3] <- fibs[1...