PING
0.9
Statistical data handling and processing in production environment
|
Slice a list, i.e. extract a sequence of items from the beginning and/or ending positionsand/or matching items.
clist
: a list of formatted (e.g., comma-separated quote-enhanced) strings;beg
: (option) item to look for in the input list; the slicing will 'begin' from the first occurrence of beg
(with quotes); 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
;mark, sep
: (option) characters/strings used respectively as a "quote" and a separator in the input list; default: mark=
str(%"), and" sep=%quote(,)
, i.e. the input clist
is a comma-separated list of quote-enhanced items; see %clist_unquote for further details.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).
returns: res=("bb","ccc")
, while
return respectively: res=("bb","ccc","dddd","bb","fffff")
, res2=("bb","ccc","dddd")
and res3=("ccc")
.
Run macro %_example_clist_slice
for more examples.
beg
and end
shall be passed without the quotes ".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.res=
instead of () when there is no match.$
appears somewhere in the list. If you need to use $
, you can reset the global macro variable G_PING_UNLIKELY_CHAR
(see _setup_
file) to another dumb (unlikely) character of your own.