SetDelayed
SetDelayed(expr, value)
expr := value
assigns
value
toexpr
, without evaluatingvalue
.
Examples
SetDelayed
is like Set
, except it has attribute HoldAll
, thus it does not evaluate the right-hand side immediately, but evaluates it when needed.
>> Attributes(SetDelayed){HoldAll}
>> a = 11
>> x := a>> x1
Changing the value of a
affects x
:
>> a = 22
>> x2
Condition
(/;
) can be used with SetDelayed
to make an assignment that only holds if a condition is satisfied:
>> f(x_) := p(x) /; x>0>> f(3)p(3)
>> f(-3)f(-3)
Related terms
Implementation status
- ✅ - full supported