I’m learning ML, can somebody please explain what does it mean exhaustive patterns?
I’m learning ML, can somebody please explain what does it mean exhaustive patterns?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
A pattern match is exhaustive if it can not fail. I.e. all cases that could possibly occur are covered by a pattern.
For example the following pattern match is not exhaustive because it doesn’t cover the case that the list is empty:
The following is exhaustive because both cases are covered:
Generally a pattern match on an algebraic data type is exhaustive if and only if there is a default case or there is a case for all constructors and the match for each sub-pattern is exhaustive.