[(a,b) | a <- [1..5], b <- [1..5], a+b <- [1..10] ]
Trying to define define a list that follows these rules. I know it doesn’t allow the way I am adding a and b but I don’t understand why.
Edited forgot the “<-“
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.
Maybe you want this?
Or this?
Haskell doesn’t solve equations for you, it performs calculations.
This declares the values which a variable takes:
This is a request for Haskell to solve an equation, which it doesn’t do… the left side has to be a valid pattern.
Of course, patterns can be more sophisticated,