Reputation: 19486
q) ({2*x};{3*x})
How can I apply the list of functions to an input, e.g. 4, something like:
({2*x};{3*x})[4]
8 12
Upvotes: 1
Views: 416
Reputation: 880
Alternative approach to apply each left
q)({2*x};{3*x})[;4]
8 12
Upvotes: 2
Reputation: 13657
Just to generalise Michaels answer, if your function takes more than one input/parameter then you'd need to use dot-apply (.
) rather than @
. Dot-apply would work in both cases using:
q)({2*x};{3*x}).\:(),4
8 12
q)({y+2*x};{y+3*x}).\:(),4 100
108 112
Upvotes: 1
Reputation: 226
You should be able to use apply (@
) each left (\:
)
({2*x};{3*x})@\:4
Upvotes: 7