KX Community

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

Home Forums kdb+ right to left evaluation

  • right to left evaluation

    Posted by wesleyklhk on February 18, 2024 at 12:00 am

    Hi, I’m new to q and array programming language. I’m having trouble understanding what it means to be right to left evaluation.

    I was expecting the 2nd output should be 11 154 but this is not the case. I’m confused when the left operand of * operator can be list or atom. how does q determine when to stop? under what situation, q can treat 22*3+4 as one block and get 11 154?

    wesleyklhk replied 3 months, 1 week ago 2 Members · 1 Reply
  • 1 Reply
  • pawhewitt

    Member
    February 18, 2024 at 12:00 am

    I believe the confusion here is just based on the syntax, to the q interpreter ( 11 22 ), 11 22 or indeed ( 11; 22 ) all resolve to the same list, * being atomic is applied to each item.

    To obtain your result vector of 11 154 you’d need to explicitly demarcate 11 from 12 either via parantheses as in

    q) (11;22*3+4)

    or via joining 11 to the result of 22*3+4

    q) 11 , 22*3+4

     

     

Log in to reply.