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

Alexander Kotelnikov sacha at myxomop.com
Sun Aug 8 15:23:15 EDT 2010


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.




More information about the Haskell-Cafe mailing list