I want to use recursion in Haskell. I define:
pf:: Int -> Int
pf 1 = 1
pf n = pf 1 + sum[pf 1..pf n-1]
But the sum is not correct! What is the proper way to sum a list of functions?
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.
[pf 1..pf (n-1)]is not the same as[pf 1, pf 2, pf 3, ..., pf (n-1)].You probably want
map:And, just as a remark,
pf x = 2^(x-1).