X-Git-Url: https://git.njae.me.uk/?a=blobdiff_plain;f=advent07%2FMainWithCase.hs;fp=advent07%2FMainWithCase.hs;h=e5a181fd6217a43804e9233f71cdd6eb1c99d7fe;hb=c4136e04dca618af23f2bbc30dc1045afb8a6bac;hp=36b4cd86a5178b4db55be5da2de60862907cc016;hpb=3e6691d64d99bf6a3c5ebbf10372d1ea4b864c9e;p=advent-of-code-23.git diff --git a/advent07/MainWithCase.hs b/advent07/MainWithCase.hs index 36b4cd8..e5a181f 100644 --- a/advent07/MainWithCase.hs +++ b/advent07/MainWithCase.hs @@ -40,10 +40,7 @@ enJoker (Hand cards bid) = Hand jCards bid where jCards = replace Jack Joker cards replace :: Eq a => a -> a -> [a] -> [a] -replace _ _ [] = [] -replace f t (x:xs) - | x == f = t : replace f t xs - | otherwise = x : replace f t xs +replace f t = fmap (\x -> if x == f then t else x) classify :: Hand -> ClassifiedHand classify (Hand cards bid) =