initial commit

This commit is contained in:
2026-02-01 22:33:08 -08:00
commit 14461fa7ef
4 changed files with 77 additions and 0 deletions

14
lab01/max.hs Normal file
View File

@@ -0,0 +1,14 @@
maxNum :: [Integer] -> Integer
maxNum [] = error "empty list"
maxNum [x] = x
maxNum (x:xs) = let m = maxNum xs in if x > m then x else m
main :: IO ()
main = do
print (maxNum [1,2,3])
print (maxNum [4])
print $ maxNum [7, 12, 0, 99, 46, 12349, 82] -- note the use of the '$' here
print $ maxNum [-4, -1, -99, -2]
print $ maxNum [7, -9, 12, 0, 99, -3, 46, 12349, 82, -7, 8]
print $ maxNum []