I’m using DrRacket as scheme compiler. When I’m trying to use the fold-right function, I got “fold-right: unbound identifier in module in: fold-right.” Do I need to include some library before calling this function?
Thank you!
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.
I think you are looking for
foldr. foldr is the racket implementation of fold-right.From the documentation:
[…]
Edit:
You may also want to use the srfi/1 library as suggested by Chris, particularily if you are expecting fold-right to work like the srfi/1 recommendation. There are some subtle differences:
Output:
Note:
fold-rightdoes not error on different size lists, but you still only get the 1, 2, 3 atoms from the second list. This matches the srfi/1 spec:foldrdoes error.