Home › Forums › kdb+ › Function composition using common argument › Re: Function composition using common argument
-
Q doesnt really offer built-in combinators as liberally as its ancestor language APL does. An elegant way to compose the projections of
f1
andf2
? You can lose the parensq)c: f1[;a] f2[;a]@ q)c 3 0n 0.5 0.5 0.3333333 0.25 0.2 0.1666667 0.1428571 0.125 0.1111111
Of course, if you have to do this often, you can write your own combinator. Call itcr
for curry right:q)cr:{x[;y]} q)c:('[;])over(f1;f2)cr:a / Compose over (f1[;a];f2[;a]) q)c 3 0n 0.5 0.5 0.3333333 0.25 0.2 0.1666667 0.1428571 0.125 0.1111111
Compose over a list of functions as many as you need.