I’d like to apply a functions stored in a list
let functions = [(fun () -> print_string "fun 1"); (fun () -> print_string "fun 2")]
with a high-order function like List.iter, to display “fun 1” and “fun 2”
Is there a way to do that ?
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.
Here is the way to do it:
Your list consists of functions with the signature
unit -> unit. Therefore, if you supply()as a parameter for each function, they will returnunitwhich is obvious to use insideList.iter.