ex13. hetkeen en ole ollut näin onnellinen <3

This commit is contained in:
Aaro Koivukangas
2024-01-17 14:52:53 +02:00
parent 9dfb904415
commit a02d6d6dee
+6 -1
View File
@@ -278,7 +278,12 @@ multiCompose fs x = foldr (\f x -> f x) x fs
-- multiApp id [head, (!!2), last] "axbxc" ==> ['a','b','c'] i.e. "abc"
-- multiApp sum [head, (!!2), last] [1,9,2,9,3] ==> 6
multiApp = todo
multiApp :: ([b] -> c) -> [a -> b] -> a -> c
multiApp f gs x = f (multiApp' gs x [])
where
multiApp' :: [a -> b] -> a -> [b] -> [b]
multiApp' [] x acc = acc
multiApp' (g:gs) x acc = g x : multiApp' gs x acc
------------------------------------------------------------------------------
-- Ex 14: in this exercise you get to implement an interpreter for a