listlib::sublist -- search
sublists
Introductionlistlib::sublist(list1, list2) determines,
whether the list list1 contains another list
list2.
Call(s)listlib::sublist(list1, list2 <, index> <,
option>)
Parameterslist1, list2 |
- | MuPAD list |
index |
- | integer, that determines the first search position |
option |
- | option Consecutive |
OptionsConsecutive |
- | determines that the sublist list2 is
containing coherent in list1 |
Returnsthe position of the first element of the containing sublist or zero
Related
Functions
Detailslistlib::sublist the position of the first
appearance of a list in another list can be determined.sublist, the number
0 is returned.
Example
1The sublist is a part of the list, but not in one piece:
>> listlib::sublist([1, 2, 3, 4, 5, 6, 7, 8], [2, 3, 5, 6])
2
>> listlib::sublist([1, 2, 3, 4, 5, 6, 7, 8], [2, 3, 5, 6], Consecutive)
0
The list contains the sublist, coherent and incoherent:
>> listlib::sublist([1, 2, 3, 4, 5, 1, 3, 5], [1, 3, 5])
1
>> listlib::sublist([1, 2, 3, 4, 5, 1, 3, 5], [1, 3, 5], Consecutive)
6
Example
2Find the last occurence of the sublist inside of the list:
>> POS:= 0:
while listlib::sublist([1, 2, 3, 1, 3, 1, 2, 3], [1, 2, 3], POS + 1) > 0 do
POS:= listlib::sublist([1, 2, 3, 1, 3, 1, 2, 3], [1, 2, 3], POS + 1)
end_while:
POS
6
>> delete POS:
listtools::sublist