Typo or on purpose? http://haskell.org/ghc/docs/6.12.2/html/users_guide/lang-parallel.html

This + 1 in (n1 + n2 + 1) what is it doing there? import Control.Parallel nfib :: Int -> Int nfib n | n <= 1 = 1 | otherwise = par n1 (pseq n2 (n1 + n2 + 1)) where n1 = nfib (n-1) n2 = nfib (n-2) BTW, same code can be found in "Seq no more: Better Strategies for Parallel Haskell" article.

On 8 Aug 2010, at 20:23, Alexander Kotelnikov wrote:
This + 1 in (n1 + n2 + 1) what is it doing there?
import Control.Parallel
nfib :: Int -> Int nfib n | n <= 1 = 1 | otherwise = par n1 (pseq n2 (n1 + n2 + 1)) where n1 = nfib (n-1) n2 = nfib (n-2)
The nfib function, by convention, counts the number of function calls needed in an evaluation of the fibonacci number, rather than evaluating the fibonacci number itself. Hence the +1. Regards, Malcolm
participants (2)
-
Alexander Kotelnikov
-
Malcolm Wallace