![]() |
PING
0.9
Statistical data handling and processing in production environment
|
Slice a given list, i.e. extract a sequence of items from the beginning and/or ending positions and/or matching items.
list : a list of blank separated strings;beg : (option) item to look for in the input list; the slicing will 'begin' from the first occurrence of beg; if not found, an empty list is returned;end : (option) ibid, the slicing will 'end' at the first occurrence of end; if not found, the slicing is done till the last item;ibeg : (option) position of the first item to look for in the input list; must be a numeric value >0; if the value is > length of the input list, an empty list is returned; incompatible with beg option (see above); if neither beg nor ibeg is passed, ibeg is set to 1;iend : (option) ibid, position of the last item; must be a numeric value >0; in the case iend<iend, an empty list is returned; in the case, iend=ibeg then the item beg (in position ibeg) is returned; incompatible with end option (see above); if neither end nor iend is passed, iend is set to the length of list;casense : (option) boolean flag (yes/no) set to perform cases sensitive search/matching of beg and end items; default:casense=no, i.e. the pattern beg and/or end are matched without consideration for the case;sep : (option) character/string separator in input list; default: %quote( ), i.e. sep is blank.res : output list defined as the sequence of items extract from the input list list from the ibeg-th position or the first occurrence of beg, till the iend-th position or the first occurrence of end (after the ibeg-th position); in case of no match or no position, an empty list is returned.
returns: res=bb ccc, while
return respectively: res=bb ccc dddd BB fffff, res2=bb ccc dddd and res3=ccc. Note that:
will "fail" and return an empty list res=.
Run macro %_example_list_slice for more examples.
end is necessarily searched for in list after the ibeg-th position (or first occurrence of beg).iend (or first occurrence of end) is not inserted in the output res list.%list_index, %list_compare, %list_count, %list_remove, %list_append.