lab08: init

This commit is contained in:
2026-03-02 11:14:28 -08:00
parent 278f9dce2e
commit 8a13b621bf
6 changed files with 187 additions and 0 deletions

21
lab08/doit.hs Normal file
View File

@@ -0,0 +1,21 @@
mydiv x y =
x >>= (\numer ->
y >>= (\denom ->
if denom > 0
then Just $ numer `div` denom
else Nothing))
mydiv' x y = do
numer <- x
denom <- y
if denom > 0
then return $ numer `div` denom
else Nothing
test1 = (Just 99) `mydiv` (Just 11)
test1' = (Just 99) `mydiv'` (Just 11)
test2 = (Just 9) `mydiv` (Just 0)
test2' = (Just 9) `mydiv'` (Just 0)