KX Community

Find answers, ask questions, and connect with our KX Community around the world.
KX Community Guidelines

Home Forums kdb+ Function composition using common argument Re: Function composition using common argument

  • cillianreilly

    Member
    October 27, 2022 at 12:00 am

    You can do this using iteration over a list of the functions to apply.

    q){z .(y;x)}[a]/[3;(f2;f1)] 
    0n 0.5 0.5 0.3333333 0.25 0.2 0.1666667 0.1428571 0.125 0.1111111

    Adding another function:

    q)f3:+ 
    q){z .(y;x)}[a]/[3;(f2;f1;f3)] 
    0n 1.5 2.5 3.333333 4.25 5.2 6.166667 7.142857 8.125 9.111111