summaryrefslogtreecommitdiff
path: root/lec04/hw.hs
diff options
context:
space:
mode:
authorEdoardo La Greca2025-07-06 17:43:04 +0200
committerEdoardo La Greca2025-07-06 17:46:15 +0200
commit7b6930dc1597aa29ed43ef21b8e9981cea962a6c (patch)
tree841a9f1a0f0f5513cf17dd6bb6923486aa834e47 /lec04/hw.hs
parent3345b6ff7434d383166e110afbbb8467ec1c8b5b (diff)
add first exercise of lecture 4
Diffstat (limited to 'lec04/hw.hs')
-rw-r--r--lec04/hw.hs8
1 files changed, 8 insertions, 0 deletions
diff --git a/lec04/hw.hs b/lec04/hw.hs
new file mode 100644
index 0000000..1fbdd48
--- /dev/null
+++ b/lec04/hw.hs
@@ -0,0 +1,8 @@
+-- Exercise 1
+
+fun1 :: [Integer] -> Integer
+fun1 = product . map (\n -> n-2) . filter even
+
+-- not tested
+fun2 :: Integer -> Integer
+fun2 = until (== 1) fun2 . last . takeWhile odd . iterate (\n -> 3*n + 1) . sum . takeWhile even . iterate (`div` 2)