summaryrefslogtreecommitdiff
path: root/testcode/test.hs
diff options
context:
space:
mode:
Diffstat (limited to 'testcode/test.hs')
-rw-r--r--testcode/test.hs19
1 files changed, 19 insertions, 0 deletions
diff --git a/testcode/test.hs b/testcode/test.hs
new file mode 100644
index 0000000..de874df
--- /dev/null
+++ b/testcode/test.hs
@@ -0,0 +1,19 @@
+
+-- This literate program prompts the user for a number
+-- and prints the factorial of that number:
+
+{- This is a comment. -}
+{- This is a comment,
+ too -}
+
+{-# this is a pragma, COUNT IT -}
+
+ main :: IO ()
+ main = do putStr "Enter a number: "
+ l <- readLine
+ putStr "n!= "
+ print (fact (read l))
+ fact :: Integer -> Integer
+ fact 0 = 1
+ fact n = n * fact (n-1)
+