TakeList

TakeList[list,{n1,n2,}]

gives the list of results obtained by successively taking ni elements from list.

TakeList[list,{seq1,seq2,}]

successively uses the sequence specifications seqi.

TakeList[list,seqs1,seqs2,]

gives a nested list in which elements specified by the lists seqsi are taken at level i in list.

Details

Examples

open allclose all

Basic Examples  (5)

Take sublists of different lengths from a list of symbols:

Take sublists from the end:

Take two elements, then three elements, and then all the rest:

Take two elements, then three elements, and then up to 10 and five if present:

Take a list of subexpressions from an expression with any head:

Scope  (2)

Take sublists using different sequence specifications:

Take subblocks of different sizes from a matrix:

Properties & Relations  (5)

TakeList[list,seqs] is equivalent to FoldPairList[TakeDrop,list,seqs]:

TakeList[list,{n,,n}] is equivalent to Partition[list,n] for an appropriate number of take specifications:

The equivalent of Partition[list,UpTo[n]] may require an additional take specification:

Subdivide a list in sublists of different lengths using TakeList:

The original list can be reconstructed using Flatten:

Subdivide an array in blocks of different sizes using TakeList:

The original matrix can be reconstructed with ArrayFlatten:

Take a list of expressions with the same head and any lengths:

Join those expressions into a single expression with the common head:

The original list can be reconstructed with TakeList by giving the lengths of the subexpressions:

Wolfram Research (2017), TakeList, Wolfram Language function, https://reference.wolfram.com/language/ref/TakeList.html.

Text

Wolfram Research (2017), TakeList, Wolfram Language function, https://reference.wolfram.com/language/ref/TakeList.html.

CMS

Wolfram Language. 2017. "TakeList." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/TakeList.html.

APA

Wolfram Language. (2017). TakeList. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/TakeList.html

BibTeX

@misc{reference.wolfram_2024_takelist, author="Wolfram Research", title="{TakeList}", year="2017", howpublished="\url{https://reference.wolfram.com/language/ref/TakeList.html}", note=[Accessed: 21-December-2024 ]}

BibLaTeX

@online{reference.wolfram_2024_takelist, organization={Wolfram Research}, title={TakeList}, year={2017}, url={https://reference.wolfram.com/language/ref/TakeList.html}, note=[Accessed: 21-December-2024 ]}