diff options
| author | Eugen Wissner <belka@caraus.de> | 2025-12-11 10:28:11 +0100 |
|---|---|---|
| committer | Eugen Wissner <belka@caraus.de> | 2025-12-11 10:28:11 +0100 |
| commit | 98329e0a3dd4f78b5d815ac3896272ec70904901 (patch) | |
| tree | 80f9c56cfe2ac20232358f236d32e84bd683be1b /Haskell-book/27 | |
| parent | 3624c712d72d246f21d4e710cec7c11e052e0326 (diff) | |
| download | book-exercises-98329e0a3dd4f78b5d815ac3896272ec70904901.tar.gz | |
Add remaining haskell book exercises
Diffstat (limited to 'Haskell-book/27')
| -rw-r--r-- | Haskell-book/27/BottomExpression.hs | 7 | ||||
| -rw-r--r-- | Haskell-book/27/StrictList.hs | 20 |
2 files changed, 27 insertions, 0 deletions
diff --git a/Haskell-book/27/BottomExpression.hs b/Haskell-book/27/BottomExpression.hs new file mode 100644 index 0000000..0f0d71d --- /dev/null +++ b/Haskell-book/27/BottomExpression.hs @@ -0,0 +1,7 @@ +{-# LANGUAGE Strict #-} +module BottomExpression where + +!x = undefined +y = "blah" +main = do + print $ snd $ seq x (x, y) diff --git a/Haskell-book/27/StrictList.hs b/Haskell-book/27/StrictList.hs new file mode 100644 index 0000000..f75bb05 --- /dev/null +++ b/Haskell-book/27/StrictList.hs @@ -0,0 +1,20 @@ +{-# LANGUAGE Strict #-} + +module StrictList where + +data List a = + Nil + | Cons ~a ~(List a) + deriving (Show) + +take' n _ | n <= 0 = Nil +take' _ Nil = Nil +take' n (Cons x xs) = (Cons x (take' (n - 1) xs)) + +map' _ Nil = Nil +map' f (Cons x xs) = (Cons (f x) (map' f xs)) + +repeat' x = xs where xs = (Cons x xs) + +main = do + print $ take' 10 $ map' (+1) (repeat' 1) |
