KX Community

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

Home Forums kdb+ each-both creating a projection Re: each-both creating a projection

  • davidcrossey

    Member
    July 18, 2023 at 12:00 am

    Your usage of square brackets has created the projection on the right-hand side, which is expecting an x argument:

    q).my.func:{[x;y;z] (x;y;z)} q)tab col1 col2 ——— a 1 b 2 c 3 / projection q){.my.func[x;y;`field]}'[flip value exec col1,col2 from tab] {.my.func[x;y;`field]}'[((`a;1);(`b;2);(`c;3))] q)type {.my.func[x;y;`field]}'[flip value exec col1,col2 from tab] 104h / right-hand side projection; note .’ as type (‘[x]) will return 106 q)type .'[flip value exec col1,col2 from tab] 104h / using apply-each without square brackets q)type {.my.func[x;y;`field]}.’flip value exec col1,col2 from tab 0h q){.my.func[x;y;`field]}.’flip value exec col1,col2 from tab `a 1 `field `b 2 `field `c 3 `field

    Note the usage of apply-each .’

    Here is a simplier example of your projection syntax:

    / missing x arg q)@'[1 2] @'[1 2] q)type @'[1 2] 104h / providing x arg q)@'[10+;1 2] 11 12 q)type @'[10+;1 2] 7h

    Hope this helps