ListTools - Maple Programming Help

Home : Support : Online Help : Programming : Data Types : Tables, lists, and sets : ListTools Package : ListTools/Split

ListTools

 Split
 split a list into an expression sequence of lists

 Calling Sequence Split(f, L, opts, ...) Split[N](f, opt[1], ..., opt[N-1], L, opts, ...)

Parameters

 L - list f - procedure N - positive integer opts - (optional) options to procedure f

Description

 • The Split(f, L) function splits list L at positions where procedure f returns true. The value of procedure f is determined by the expression $f\left(x\right)$ evaluated for each element x of list L.
 The Split(f, L, opts) function performs in a similar manner, except that the value of procedure f is determined by the expression $f\left(x,\mathrm{opts}\right)$.
 • If Split is indexed by a positive integer N, the expression $f\left({\mathrm{opt}}_{1},...,{\mathrm{opt}}_{N-1},x,\mathrm{opts}\right)$ is evaluated for each list element x.

Examples

 > $\mathrm{with}\left(\mathrm{ListTools}\right):$
 > $L≔\left["a",",","bc","d","e",",","f"\right]$
 ${L}{≔}\left[{"a"}{,}{","}{,}{"bc"}{,}{"d"}{,}{"e"}{,}{","}{,}{"f"}\right]$ (1)
 > $\mathrm{Split}\left(\mathrm{=},L,","\right)$
 $\left[{"a"}\right]{,}\left[{"bc"}{,}{"d"}{,}{"e"}\right]{,}\left[{"f"}\right]$ (2)
 > $\mathrm{Digits}≔5$
 ${\mathrm{Digits}}{≔}{5}$ (3)
 > $\mathrm{Split}\left(\mathrm{>},\left[\mathrm{seq}\left(\mathrm{sin}\left(2.0x\right),x=1..12\right)\right],-\frac{1}{2}\right)$
 $\left[{}\right]{,}\left[{-}{0.75680}\right]{,}\left[{}\right]{,}\left[{-}{0.54402}{,}{-}{0.53657}\right]{,}\left[{}\right]{,}\left[{-}{0.75099}\right]{,}\left[{}\right]{,}\left[{-}{0.90558}\right]$ (4)
 > $\mathrm{Split}[2]\left(\mathrm{verify},-\frac{1}{2},\left[\mathrm{seq}\left(\mathrm{sin}\left(2x\right),x=1..12\right)\right],\mathrm{less_than}\right)$
 $\left[{}\right]{,}\left[{\mathrm{sin}}{}\left({4}\right)\right]{,}\left[{}\right]{,}\left[{\mathrm{sin}}{}\left({10}\right){,}{\mathrm{sin}}{}\left({12}\right)\right]{,}\left[{}\right]{,}\left[{\mathrm{sin}}{}\left({18}\right)\right]{,}\left[{}\right]{,}\left[{\mathrm{sin}}{}\left({24}\right)\right]$ (5)