So basically i have a question for ym homework that says: "Create a function that checks if a list is not empty using prelude functions" I saw the null function and i wanted to use it and print the message. So i tried the following:
notEmpty :: [Int] -> [Char]
notEmpty [x] = if (null[x]) then "False" else "True"
If i call notEmpty [ ], it gives me this error: Non.Exhaustive patterns in function notEmpty after several learning i came up with this:
notEmpty :: [Int] -> [Char]
notEmpty [] = "False"
notEmpty [x] = if (null[x])then "False" else "True"
but after this, i tried the following input: notEmpty[1,2] and it gave me the same error.
My question is, when i run null [1,2] it gives me False, so what am i doing wrong?
Aucun commentaire:
Enregistrer un commentaire