
12 Dec
2021
12 Dec
'21
12:14 a.m.
This code myTakePM :: Int -> [a] -> [a] myTakePM 0 _ = [] myTakePM n (x:xs) = x : myTakePM (n-1) xs is bad because it allows myTakePM 4 [1,2,3] [1,2,3*** Exception: <interactive>:(395,1)-(396,41): Non-exhaustive patterns in function myTakePM I knew it would not work, but why is it calling this essentially a partial function? How does it know this? Again, I expected an error, but what is this Non-exhaustive patterns in function myTakePM saying? Or, said another way, what exactly is non-exhaustive about this? -- ⨽ Lawrence Bottorff Grand Marais, MN, USA borgauf@gmail.com