KX Community

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

Home Forums kdb+ Challenge 3 The Runner-Up Re: Challenge 3 The Runner-Up

  • SJT

    Member
    March 19, 2024 at 10:55 am

     

    q)list1:4 7 9 7 2 8 9 
    q)ru:@[;1] desc distinct:: /runner-up 
    q)ru list1 
    8

     

    Using general list notation (items separated by semicolons and embraced by parentheses) suggests a list is general; better to write a vector as a vector literal.

    Composition ru is a sequence of three unaries. In evaluation order: select the distinct items; sort descending; select second item.