UpTo

UpTo[n]

is a symbolic specification that represents up to n objects or positions. If n objects or positions are available, all are used. If fewer are available, only those available are used.

Examples

open allclose all

Basic Examples  (7)

Take up to the number of elements available:

Drop up to the number of elements available:

Take up to the number of elements available, dropping what remains, if anything:

Partition into blocks that are up to 3 elements long; the last block is shorter:

Give the 10 most common elements, or as many as are available:

Give the order of the 10 smallest elements, or as many as are available:

Give the maximum height and width of a graphic:

Scope  (7)

Take up to 20 characters from a string:

Find the 4 largest eigenvalues in a matrix, or as many as there are if fewer:

Create a "ragged" partition where last elements can be shorter:

Obtain the 6 most common elements, or as many as there are if fewer:

Generate a random sample of up to 6 elements, or as many as there are if fewer:

Obtain the first 4 minimal elements, or as many as are available:

Partition an image so that lengths are up to 36 pixels and heights are up to 28 pixels:

Properties & Relations  (2)

Cases behaves as though it implicitly uses UpTo:

You can give an explicit UpTo specification to Cases:

ImageTake behaves as though it implicitly uses UpTo:

You can give an explicit UpTo specification to ImageTake:

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

Text

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

CMS

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

APA

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

BibTeX

@misc{reference.wolfram_2023_upto, author="Wolfram Research", title="{UpTo}", year="2015", howpublished="\url{https://reference.wolfram.com/language/ref/UpTo.html}", note=[Accessed: 19-March-2024 ]}

BibLaTeX

@online{reference.wolfram_2023_upto, organization={Wolfram Research}, title={UpTo}, year={2015}, url={https://reference.wolfram.com/language/ref/UpTo.html}, note=[Accessed: 19-March-2024 ]}