 nresults - Maple Help

_nresults

number of results expected to be returned from a procedure Calling Sequence _nresults Description

 • Within a procedure, the special name _nresults has as its value the number of variables on the left-hand side of the expression in which the procedure was called.  If the procedure call did not involve an assignment, then _nresults is given the value undefined.  If the procedure call is nested inside another expression, the value of _nresults is also set to undefined.  Any time the procedure call on the right-side of an assignment is part of an expression more complicated than a simple function call, _nresults will be set to undefined.
 • Do not use _nresults with option remember or option cache. Only the first result computed is stored in the remember table.  Subsequent results with the same input and a different value for _nresults will not respect the current value of _nresults. The Cache package can be used to manually manipulate and simulate a remember table that works with _nresults. Examples

A procedure to find both the minimum and maximum of an arbitrary sequence of numbers could be written as follows.

 > maxmin := proc () local max, min, i;     max := _passed;     min := _passed;     for i from 2 to _npassed do     if _passed[i] > max then             max := _passed[i]     elif _passed[i] < min then             min := _passed[i]         end if     end do;     if _nresults = 2 then     max, min     else     max     end if end proc:
 > $a≔\mathrm{maxmin}\left(1,2,3\right)$
 ${a}{≔}{3}$ (1)
 > $a,b≔\mathrm{maxmin}\left(1,2,3\right)$
 ${a}{,}{b}{≔}{3}{,}{1}$ (2)