I know the “xs” can be used for expressing the rest elements in a list
but I totally have no idea what the “ls” mean in Haskell?
I know the xs can be used for expressing the rest elements in a
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.
lsis not a predefined thing. It is whatever you bind it to, just likexs.For instance, I think you’ve seen examples like this:
The variable
xs, that you just defined here, gets bound (will have the value of) the rest of the list because of the pattern(x:xs). But this could equally well have been written as:We prefer not to call a variable
lthough, because it is easily confused with the digit1(or even the pipe symbol|on really messed up fonts).We could even write:
where we reuse the names of the built-in prelude functions
headandtail, but this is bound to lead to confusion.