TakeDrop
Details
- TakeDrop uses the standard sequence specification:
-
All all elements None no elements n elements 1 through n UpTo[n] elements 1 up to at most n, as available -n last n elements {n} element n only {m,n} elements m through n inclusive {m,n,s} elements m through n in steps of s - TakeDrop can be used on an object with any head, not necessarily List.
- Applying TakeDrop to a SparseArray object normally yields a pair of SparseArray objects.
- Applying TakeDrop to an Association object yields a pair of Association objects containing elements from the specified positions.
Examples
open all close allBasic Examples (2)
Scope (5)
TakeDrop uses the standard sequence specification:
TakeDrop[{a, b, c, d, e, f, g}, 3]TakeDrop[{a, b, c, d, e, f, g}, -3]TakeDrop[{a, b, c, d, e, f, g}, {3}]TakeDrop[{a, b, c, d, e, f, g}, {2, 4}]TakeDrop[{a, b, c, d, e, f, g}, {2, 6, 2}]TakeDrop[{a, b, c, d, e, f, g}, All]TakeDrop[{a, b, c, d, e, f, g}, None]Take up to 8 elements in the first list, or as many as are available:
TakeDrop[{a, b, c, d, e, f, g}, UpTo[8]]Use expressions with arbitrary heads:
TakeDrop[h[a, b, c, d, e, f, g], 3]Use TakeDrop with sparse arrays:
TakeDrop[SparseArray[{2 -> a, 7 -> b}, 10], 4]Use TakeDrop with associations:
TakeDrop[<|a -> α, b -> β, c -> γ, d -> δ, e -> ϵ|>, 2]Applications (1)
See Also
Take Drop StringTakeDrop FoldPair FoldPairList Part Partition ArrayReshape Split Flatten
Function Repository: KeyTakeDrop SplitAtPositions
Related Guides
Text
Wolfram Research (2015), TakeDrop, Wolfram Language function, https://reference.wolfram.com/language/ref/TakeDrop.html (updated 2015).
CMS
Wolfram Language. 2015. "TakeDrop." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2015. https://reference.wolfram.com/language/ref/TakeDrop.html.
APA
Wolfram Language. (2015). TakeDrop. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/TakeDrop.html
BibTeX
@misc{reference.wolfram_2026_takedrop, author="Wolfram Research", title="{TakeDrop}", year="2015", howpublished="\url{https://reference.wolfram.com/language/ref/TakeDrop.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_takedrop, organization={Wolfram Research}, title={TakeDrop}, year={2015}, url={https://reference.wolfram.com/language/ref/TakeDrop.html}, note=[Accessed: 13-June-2026]}