Sometimes I see code with the following expression:
example = example' []
Or what is the different between these functions?
foldl
foldl'
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.
'is simply another identifier character like any other.foldl'is a completely separate function fromfoldl; it could just as well be calledstrictFold. It’s called that because it’s closely related tofoldl: it’s afoldlwhere the accumulator is evaluated at every step, so that large thunks don’t build up. For instance,foldl (+) 0will overflow the stack on a large list, butfoldl' (+) 0won’t.In general, the suffixing of a
'means one of three things:foo'is either a helper definition made for the purpose of definingfoo, a modified version offoo(that is,state,state', andstate''could be an initial state and two updated versions), or a strict version offoo.