Maple Professional
Maple Academic
Maple Student Edition
Maple Personal Edition
Maple Player
Maple Player for iPad
MapleSim Professional
MapleSim Academic
Maple T.A. - Testing & Assessment
Maple T.A. MAA Placement Test Suite
Möbius - Online Courseware
Machine Design / Industrial Automation
Aerospace
Vehicle Engineering
Robotics
Power Industries
System Simulation and Analysis
Model development for HIL
Plant Modeling for Control Design
Robotics/Motion Control/Mechatronics
Other Application Areas
Mathematics Education
Engineering Education
High Schools & Two-Year Colleges
Testing & Assessment
Students
Financial Modeling
Operations Research
High Performance Computing
Physics
Live Webinars
Recorded Webinars
Upcoming Events
MaplePrimes
Maplesoft Blog
Maplesoft Membership
Maple Ambassador Program
MapleCloud
Technical Whitepapers
E-Mail Newsletters
Maple Books
Math Matters
Application Center
MapleSim Model Gallery
User Case Studies
Exploring Engineering Fundamentals
Teaching Concepts with Maple
Maplesoft Welcome Center
Teacher Resource Center
Student Help Center
_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[1]; min := _passed[1]; 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:
See Also
_passed, parameter, procedure
Download Help Document