haskell - I keep getting "Non-exhaustive patterns in function isPermutation" when I have ALL possible cases? -


i trying create function uses 2 lists. reason, when pass:

ispermutation [] [], or [] [1,2,3] or [1,2,3] [] - i non-exhaustive patterns in function ispermutation

ispermutation :: (eq a)=>[a]->[a]->bool **ispermutaiton** [] [] = true **ispermutaiton** [] ys = false **ispermutation** xs [] = false ispermutation (x:xs) (ys) = true 

i cannot figure out why getting since covering cases!

update *thanks chris taylor : - simple typo. had misspelled 1 of function names "ispermutaiton" instead of "ispermutation" *

be careful on spelling since haskell won't recognize meaning same function(duh) or "declaring" 2 different functions cases meshed up.

you have typo in second , third lines -- ispermutaiton instead of ispermutation.

you have defined

foo [] [] = true       -- both arguments empty foo [] ys = false      -- first argument empty, second argument  bar  xs    [] = false  -- second argument empty, first argument bar (x:xs) ys = true   -- first argument @ least 1 element, second 

so whenever call foo (i.e. ispermutaiton) non-empty first argument error, , whenever call bar (i.e. ispermutation) empty first argument , non-empty second argument error.


Comments

Popular posts from this blog

c++ - CryptStringToBinary API behavior -

c++ - Correct method for redrawing a layered window -

java.util.scanner - How to read and add only numbers to array from a text file -