Skip to content

AppendTo ​

Appends an element to a bound variable's value, and reassigns it in place.

✓ checked against that system · ! checked, with disagreements (hover a chip)Wolfram LanguageAppendTo✓
AppendTo(s, elem)Reads ss's current value, appends elemelem, reassigns ss to the result, and returns it.
Typed signatures
TypePackageApplies
(symbol, any) -> anycombinatoricsalways

Domain: Collections

Details
  • ss is held — its NAME, not its value, is the first operand — so it can be reassigned. Works for any symbol already carrying a value (via a plain assignment, or a Module local).

Examples

Basic #

bind a list, then append to it

live ↗
In[appendToDemoList:−[1,2,3],AppendTo(appendToDemoList,4)]\bigl\lbrack\mathrm{appendToDemoList}\coloneq\bigl\lbrack1, 2, 3\bigr\rbrack, \mathrm{AppendTo}(\mathrm{appendToDemoList}, 4)\bigr\rbrackOut[[1,2,3],[1,2,3,4]]\bigl\lbrack\bigl\lbrack1, 2, 3\bigr\rbrack, \bigl\lbrack1, 2, 3, 4\bigr\rbrack\bigr\rbrack
Applications #
live ↗
InAppendTo(m,[a,b])\mathrm{AppendTo}(m, \bigl\lbrack a, b\bigr\rbrack)OutAppendTo(m,[a,b])\mathrm{AppendTo}(m, \bigl\lbrack a, b\bigr\rbrack)
About
Examples2
Checked againstWolfram Language 1 agree
CrosswalkWolfram Language

See also: Module