in clojure i have vector [“myfn1” “myfn2” “myfn3”]
how can i call functions named “myfn1” … using strings from that vector
in clojure i have vector [myfn1 myfn2 myfn3] how can i call functions named
Share
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.
To call a function bound to Var
myfn1given the string"myfn1", you could do something like this:So, given your example vector and assuming that you don’t need to pass any additional arguments to your functions (it’s straighforward enough to modify this code if you do), you could do the following:
E.g.
(The
nils are the return values from the printing functions; note how there’s no linebreak after theasdfproduced byprintand theasdfproduces byprnis quoted.)