delete
-- delete the value of an
identifierThe statement delete x
deletes the value of the
identifier x
.
delete x1, x2, ... _delete(x1, x2,
...)
x1, x2, ... |
- | identifiers or indexed identifiers |
the void object of type DOM_NULL
.
:=
, _assign
, assign
, assignElements
, evalassign
x
requires an identifier x
that does not have a value. If
x
has a value, the statement delete x
deletes
the value and x
can be used as a symbolic variable.delete x1, x2, ...
is equivalent to the
function call _delete(x1, x2, ...)
. The values of all
specified identifiers are deleted.delete x[j]
deletes the entry
j
of a list, an array, or a table named
x
. Deletion of elements or entries reduces the size of
lists and tables, respectively.x
is an identifier carrying properties set via assume
, then delete x
detaches all properties from x
, i.e., delete
x
has the same effect as unassume(x)
. Cf. example 3._delete
is a function of the system kernel.The identifiers x
, y
are
assigned values. After deletion, the identifiers have no values any
longer:
>> x := 42: y := 7: delete x: x, y
x, 7
>> delete y: x, y
x, y
More than one identifier can be deleted by one call:
>> a := b := c := 42: a, b, c
42, 42, 42
>> delete a, b, c: a, b, c
a, b, c
delete
can also be used to delete specific
elements of lists, arrays, and tables:
>> L := [7, 13, 42]
[7, 13, 42]
>> delete L[2]: L
[7, 42]
>> A := array(1..3, [7, 13, 42])
+- -+ | 7, 13, 42 | +- -+
>> delete A[2]: A, A[2]
+- -+ | 7, ?[2], 42 |, A[2] +- -+
>> T := table(1 = 7, 2 = 13, 3 = 42)
table( 3 = 42, 2 = 13, 1 = 7 )
>> delete T[2]: T
table( 3 = 42, 1 = 7 )
Note that delete
does not evaluate the
objects that are to be deleted. In the following, an element of the
list U
is deleted. The original value of U
(the list L
) is not changed:
>> U := L: delete U[1]: U, L
[42], [7, 42]
Finally, all assigned values are deleted:
>> delete U, L, A, T: U, L, A, T
U, L, A, T
delete
can also be used to delete
properties of identifiers set via assume
. With the assumption 'x
> 1
', the expression ln(x)
hat the property
'ln(x) > 0
', i.e., its sign is 1:
>> assume(x > 1): sign(ln(x))
1
Without a property of x
, the function
sign
cannot determine the
sign of ln(x)
:
>> delete x: sign(ln(x))
sign(ln(x))
delete
is a new keyword.NIL
to the identifier. In the present
version of MuPAD, NIL
is an ordinary object that may be
assigned as a value. Now, one must use delete
to delete a
value.