FlattenOnce - Maple Help

ListTools

 FlattenOnce
 flatten a (possible nested) list once

 Calling Sequence FlattenOnce(L)

Parameters

 L - list

Description

 • The FlattenOnce(L) function converts any element in list L which are of type list to expression sequences.
 Note: The procedure ListTools[FlattenOnce](L) is more efficient than a call to ListTools[Flatten](L, 1).

Examples

 > $\mathrm{with}\left(\mathrm{ListTools}\right):$
 > $L≔\left[1,2,3,\left[4,5,6\right]\right]$
 ${L}{≔}\left[{1}{,}{2}{,}{3}{,}\left[{4}{,}{5}{,}{6}\right]\right]$ (1)
 > $\mathrm{FlattenOnce}\left(L\right)$
 $\left[{1}{,}{2}{,}{3}{,}{4}{,}{5}{,}{6}\right]$ (2)
 > $L≔\left[1,\left[2\right],\left[3,\left[4\right]\right],\left[\left[\left[5\right]\right],6\right]\right]$
 ${L}{≔}\left[{1}{,}\left[{2}\right]{,}\left[{3}{,}\left[{4}\right]\right]{,}\left[\left[\left[{5}\right]\right]{,}{6}\right]\right]$ (3)
 > $\mathrm{FlattenOnce}\left(L\right)$
 $\left[{1}{,}{2}{,}{3}{,}\left[{4}\right]{,}\left[\left[{5}\right]\right]{,}{6}\right]$ (4)
 > $\mathrm{Flatten}\left(L\right)$
 $\left[{1}{,}{2}{,}{3}{,}{4}{,}{5}{,}{6}\right]$ (5)