Prepend

Prepend[expr,elem]

gives expr with elem prepended.

Prepend[elem]

represents an operator form of Prepend that can be applied to an expression.

Details

  • Prepend works on SparseArray objects, returning ordinary lists if necessary.
  • Prepend can be used on Association objects. Single new elements are specified in the form key->value. New values replace older ones if their keys are the same.
  • Multiple elements to prepend to an association can be specified in the form {key1->value1,key2->value2, }.
  • Prepend[elem][expr] is equivalent to Prepend[expr,elem].

Examples

open allclose all

Basic Examples  (3)

Prepend to an Association:

Prepend several rules to an Association:

Generalizations & Extensions  (1)

Use a head other than List:

Applications  (4)

Prepend a row to a matrix:

Prepend to each row in a matrix:

Prepend a vector to a matrix:

Successively prepend to a list:

Possible Issues  (1)

Wolfram Research (1988), Prepend, Wolfram Language function, https://reference.wolfram.com/language/ref/Prepend.html (updated 2014).

Text

Wolfram Research (1988), Prepend, Wolfram Language function, https://reference.wolfram.com/language/ref/Prepend.html (updated 2014).

CMS

Wolfram Language. 1988. "Prepend." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2014. https://reference.wolfram.com/language/ref/Prepend.html.

APA

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

BibTeX

@misc{reference.wolfram_2024_prepend, author="Wolfram Research", title="{Prepend}", year="2014", howpublished="\url{https://reference.wolfram.com/language/ref/Prepend.html}", note=[Accessed: 14-October-2024 ]}

BibLaTeX

@online{reference.wolfram_2024_prepend, organization={Wolfram Research}, title={Prepend}, year={2014}, url={https://reference.wolfram.com/language/ref/Prepend.html}, note=[Accessed: 14-October-2024 ]}