3.12 Belong to & Contain: check whether a set contains another set based on order

 

At times a set needs to have same and continuous order as members of the subset to be said to contain it.

We have some data here:

id v
1 3
2 15
3 23
4 7
5 11
6 19
7 23
8 7
9 6

And trying to find v value of the next record of continuous records whose v values are 23, 7 and 11 respectively by id in ascending order.

SPL script:

A
1 =T(“data.xlsx”)
2 [23,7,11]
3 =A1.(v)
4 =A3.pos@c(A2)
5 =if(A4>0,A3.m(A4+A2.len()))

A2 Define a sequence of target values.
A4 Find the start and end positions of members in A3 that are same as A2’s members in both value and order.

Execution result: 19