KX Community

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

Home Forums kdb+ rotate function differences between k and q Re: rotate function differences between k and q

  • Laura

    Administrator
    October 12, 2022 at 12:00 am

    Huh  now I see what youre up to: implementing rotate in q.

    This reminds me of a category of puzzle that used to be popular in qs ancestor language APL, called dead key questions. The premise was always that a certain key on your keyboard was not working; how do you code around it?

    APL primitives are mostly variadic: they can be applied as either unaries or binaries, usually with related semantics. And they are (almost) all single characters, which is what gives the dead key problem its bite. For example, rotate and reverse in q are in APL the binary and unary forms of ?

     

    l?2 3 5 7 11 
    ?l 11 7 5 3 2 
    2?l 5 7 11 2 3

     

    In k, operators are similarly variadic; q replaces the unary forms with keywords. Like k itself, the unary forms of the operators are considered exposed infrastructure: use the q keywords instead. The (#) you asked about is, as P鴥r advises, in q written as count.