changed
changed, process
def process changed(a: _typ): boolean
Returns true
if the current value a
is different from the previous value; always returns true
for the first element. This process aggregator must be used with an ordering option (sort
or scan
).
a
: The input value to compare with the previous element (generic type).
Examples
table T = with
[| as Val |]
[| "a" |] // changed = true
[| "a" |]
[| "b" |] // changed = true
[| "b" |]
[| "b" |]
[| "c" |] // changed = true
show table "" a1b6 with
T.Val
changed(T.Val) scan auto
This process aggregator is useful for skipping unchanged lines when persisting sequential data, such as historical prices.
Remarks
This aggregator could be manually reimplemented.
def process changed_bis(next: number) default false with
keep prev = 0
changed = prev != next
prev = next
return argfirst() or changed