From 465a2b48039004b4c887847f2af67ad9a9a0b47f Mon Sep 17 00:00:00 2001 From: Aaro Koivukangas Date: Mon, 22 Dec 2025 21:40:05 +0200 Subject: [PATCH] 4b ex6 --- exercises/Set4b.hs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/exercises/Set4b.hs b/exercises/Set4b.hs index 3782cf9..0167a1f 100644 --- a/exercises/Set4b.hs +++ b/exercises/Set4b.hs @@ -108,8 +108,9 @@ largestHelper x acc myHead :: [a] -> Maybe a myHead xs = foldr headHelper Nothing xs -headHelper = todo - +headHelper :: a -> Maybe a -> Maybe a +headHelper x Nothing = Just x +headHelper x (Just a) = Just x ------------------------------------------------------------------------------ -- Ex 7: get the last element of a list with a fold. Define lasthelper -- so that the given definition of myLast works.