I want to declare a function that takes in a function(the function also takes a element as parameter) and a list as parameters in Scheme
but the is line of code gives me error
(define (function funct(x),l)
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.
In Scheme, functions are first-class citizens. Thus, you can pass a function as a parameter to another function, just like you do with any other symbol. There’s no such thing as the
functionkeyword.For example, to define a function called
mapthat takes a function as an argument, and applies it to every member of the list, you could use:Then, if you had a function called
add1that you wanted to pass tomap:The result would be
(2 3 4).DEMO.