KX Community

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

Home Forums kdb+ How to remove or add items from a list Re: How to remove or add items from a list

  • Laura

    Administrator
    April 21, 2022 at 12:00 am

    If Im following you, your two lists L1 and L2 are the same length. You want a list A of the same length in which item A[i] is the greater of L1[i] and L2[i].

    The Greater operator  | is atomic, so iterates implicitly.

     

    q)show L1:10?10. 3.927524 5.170911 5.159796 4.066642 1.780839 3.017723 7.85033 5.347096 7.111716 4.11597 
    q)show L2:10?10. 4.931835 5.785203 0.8388858 1.959907 3.75638 6.137452 5.294808 6.916099 2.296615 6.919531 
    q)show A:L1|L2 / Greater 4.931835 5.785203 5.159796 4.066642 3.75638 6.137452 7.85033 6.916099 7.111716 6.919531

    A good deal of vector programming is just letting go of loops and tests. (Just takes practice.)