Plan 9 from Bell Labs’s /usr/web/sources/contrib/fernan/nhc98/tests/conformance98/N+K/Main.hs

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


import System

fib :: Integer -> Integer

fib 0 = 1
fib 1 = 1
fib (n+2) = fib (n+1) + fib n
--fib n = fib (n-1) + fib (n-2)

main = do args <- getArgs
          if null args then
            putStrLn ("fib 10 = " ++ show (fib 10))
           else
            mapM_ (\arg-> putStrLn ("fib "++arg++" = " ++ show (fib (read arg))))
                  args

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.