KX Community

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

Home Forums kdb+ Five easy pieces #4: Little Six Re: Five easy pieces #4: Little Six

  • rolf

    Member
    June 4, 2022 at 12:00 am

    i think this is what you are after

    q)f:{abs(til[x]div 2)-x#(x-1),0} 
    
    q)f each 2*1+til 5 
    
    1 0 
    3 0 2 1 
    5 0 4 1 3 2 
    7 0 6 1 5 2 4 3 
    9 0 8 1 7 2 6 3 5 4

    i cannot claim authorship