represents the first argument supplied to a pure function.
represents the n argument.
represents the value associated with key "name" in an association in the first argument.
- # is used to represent arguments or formal parameters in pure functions of the form body& or Function[body].
- # is equivalent to Slot.
- #n is equivalent to Slot[n]. n must be a non‐negative integer.
- #0 gives the head of the function, i.e. the pure function itself.
- When applied to an association, #name is equivalent to #["name"] and picks out elements in the association.
- In the form #name, the characters in name can be any combination of alphanumeric characters not beginning with digits.
Background & Context
- Slot represents the first argument supplied to a pure function. The expression Slot may be compactly denoted with the hash character , or more explicitly as . The argument to a pure function is represented by Slot[n], commonly denoted . The zeroth slot of a pure function is its head.
- Slot is typically used inside Function. In pure functions of the form , # is used as part of the to represent arguments or formal parameters. An example application of Slot is given by , which evaluates to .
- A sequence of arguments to be supplied to a pure function is represented using SlotSequence (written in shorthand as ##n).
- When pure functions are nested, the meaning of slots may become ambiguous, in which case parameters must be specified using an explicit Function construction with named parameters.
Examplesopen allclose all
Basic Examples (3)
# is short for #1, the first argument:
#name is effectively a short form of #["name"]:
#name is interpreted as Slot["name"]:
#name always refers to the association in the first argument:
Properties & Relations (3)
Possible Issues (3)
Wolfram Research (1988), Slot, Wolfram Language function, https://reference.wolfram.com/language/ref/Slot.html (updated 2014).
Wolfram Language. 1988. "Slot." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2014. https://reference.wolfram.com/language/ref/Slot.html.
Wolfram Language. (1988). Slot. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/Slot.html