functional programming - Concise Lisp code to apply a list of functions all to the same argument(s) and get a list of the return values? -
Suppose i have an element, and i have a list of predictions. I want to implement each of these predictions for each element and get the same list of return values. I know that the same function can apply to each of the map
and the friends' logic list, but is there any short syntax to implement any of the arguments?
Of course I
(mapcar (lambda pred single-element) list
but it would be good
(single-element of test-prediction-paradox-list-list)
Obviously I just cancel it
, But I wanted to know that there is an acceptable method to do this.
This operation is not common And in addition to actually writing this, in general Lisp, a predetermined way of doing this Many people like a small syntax and enhanced syntax elements which will help in all types of lisps in such a case. In mango liz, write any such function you want (instead of adding syntax).
(defun fmap (functions and rest of the arguments) (declare (dynamic-bound args)) "Applys each function to arguments, returns a list of results." Lambda (f Function (apply function ARGs)) CL-USER 1 & gt; FMAP (list # '+ #' - # '* #' /) 42 17) (59 25 714 42/17)
Comments
Post a Comment