Skip to content


Find where list items change value

differ x    differ[x]

Returns a boolean list indicating where consecutive pairs of items in x differ. It applies to all data types.

It is a uniform function. The first item of the result is always 1b:

    r[i]=1b                 for i=0
    r[i]=not A[i]~A[i-1]    otherwise
q)differ 1 3 3 4 5 6 6

Split a table with multiple dates into a list of tables with distinct dates.

q)d:2009.10.01+asc 100?30
q)i:where differ t[`date]    / indices where dates differ
q)tlist:i _ t                / list of tables with one date per table
q)tlist 0
date       sym  price    size
2009.10.01 IBM  37.95179 710
2009.10.01 CSCO 52.908   594
2009.10.01 MSFT 32.87258 250
2009.10.01 CSCO 75.15704 592
q)tlist 1
date       sym  price   size
2009.10.02 MSFT 18.9035 26
2009.10.02 CSCO 12.7531 760

Binary use deprecated

As of V3.6 the keyword is variadic. Binary application is deprecated and may disappear in future versions. The keyword cannot be applied infix.

For a binary version, use Match Each Prior: ~:'.

Basics: Comparison

Back to top