
level - sets the substitution depth for evaluation

Calling sequence:
level(expr)
level(expr, integer)

Parameter:
expr      --  expression
integer   --  non-negative integer

Overloading:

2

Summary:

level sets the substitution depthfor the evaluation of the expression expr.
More exactly, an expression in the form level(expr, n) is evaluated, by
expr being evaluated with the substitution depth n and the result of this
evaluation is returned. With an exression in the form level(expr), expr is
evaluated with the substitution depth 231-1.

In practice, level temporarily overwrites the environment variableLEVEL .
The variable MAXLEVEL  remains unchanged.  When the substitution depth
MAXLEVEL is reached an error message is given.

Please remember that in MuPAD on the interactive level an expression is
usually completely substituted. In contrast, in a procedure it is only substitued
to a depth of one. The most important use of level is the multiple substitution
of expressions in procedures.  If, for instance, x := y; and y := 1; are

entered on the interactive level then x is evaluated to 1; i.e. x is completely
evaluated.

If the assignments x := y; and y := 1; are contained in a procedure then
only a one-step substitution is carried out, i.e. x is evaluated to y. If the user
needs a complete substitution in a procedure then level(x) must be given
which is then, as on the interactive level, evaluated to 1.

In contrast to most other functions, arguments which are expression sequences,
are not flattened. level is a kernel function.

>>  a:=b: b:=c: c:=13: a, level(a,2);

      13, c

>>  p:=proc() local a, b, c; begin
        a:= b; b:= c; c:= 13;
        a, level(a, 2), level(a)
    end_proc:
    p();

      b, c, 13

See also:  eval, hold, LEVEL , val

