[project @ 1996-01-08 20:28:12 by partain]
[ghc-hetmet.git] / ghc / misc / examples / io / io012 / Main.hs
diff --git a/ghc/misc/examples/io/io012/Main.hs b/ghc/misc/examples/io/io012/Main.hs
new file mode 100644 (file)
index 0000000..9b7fba3
--- /dev/null
@@ -0,0 +1,16 @@
+import LibCPUTime
+
+main = 
+    openFile "/dev/null" WriteMode >>= \ h ->
+    hPutText h (nfib 30) >>
+    getCPUTime >>= \ t ->
+    putText t >>
+    putChar '\n'
+
+nfib :: Integer -> Integer
+nfib n 
+  | n <= 1 = 1
+  | otherwise = (n1 + n2 + 1)
+  where 
+    n1 = nfib (n-1) 
+    n2 = nfib (n-2)