Given a 1D container, such as vector or list, called \(A\), how to find if this sequence is inside another sequence say \(B\) and the indices in \(B\) where the sequence \(A\) is located?
Use ArrayTool in version 2023
A:=[1,3,5]; B:=[1,3,4,5]; status,indices_list := ArrayTools:-IsSubsequence( A, B ,'output' = ['check','indices'],'match'='exact'); if status then print("Sequence ",A," Was found in ",B," At indices ",indices_list); else print("Sequence ",A," Was not found in ",B); fi;
The above gives
If \(A\) was not sequence inside \(B\), then status will be false otherwise.