ListTools
Group
group a list into an expression sequence of lists
Calling Sequence
Parameters
Description
Examples
Group(f, L, opts, ...)
Group[N](f, opt[1], ..., opt[N-1], L, opts, ...)
L
-
list
f
procedure
N
positive integer
opts
(optional) options to procedure f
The Group(f, L) function groups list L into sublists where procedure f returns either true or false. The value of procedure f is determined by the expression f⁡x evaluated for each element x of list L.
The Group(f, L, opts) function performs in a similar manner, except that the value of procedure f is determined by the expression f⁡x,opts.
If Group is indexed by a positive integer N, the expression f⁡opt1,...,optN−1,x,opts is evaluated for each list element x.
with⁡ListTools:
L≔`$`⁡1..10
L≔1,2,3,4,5,6,7,8,9,10
Group⁡isprime,L
1,2,3,4,5,6,7,8,9,10
Group⁡type,L,even
Digits≔5
Group⁡`>`,seq⁡sin⁡2.0⁢x,x=1..12,−12
0.90930,−0.75680,−0.27942,0.98936,−0.54402,−0.53657,0.99061,−0.28790,−0.75099,0.91295,−0.0088513,−0.90558
Group⁡evalb@`>`,seq⁡sin⁡2.0⁢x,x=1..12,−12
Group2⁡verify,−12,seq⁡sin⁡2⁢x,x=1..12,less_than
sin⁡2,sin⁡4,sin⁡6,sin⁡8,sin⁡10,sin⁡12,sin⁡14,sin⁡16,sin⁡18,sin⁡20,sin⁡22,sin⁡24
See Also
map
type[list]
Download Help Document