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

  • gyorokpeter-kx

    Member
    October 12, 2022 at 12:00 am

    Your “q version” is actually a hybrid between k and q. A more q-native interpretation would look like:

    rotate2:{$[0h>type y;'`rank;98h<type y;'`type;count y;raze reverse(0;x mod count y)_y;y]}

    The whole function is a conditional with multiple branches. The part you crossed out is just a check if the list is empty, in which case we don’t bother with calculating the rotated version, we just return the original empty list. You seem to have broken up the conditional in your “q” version even though it is still possible to use the multi-branch version.