Tip 91. One-line-program

Fig. 91. One-line-program

For increase the compactness of Mathcad-programs (for decrease the number of lines in it) it was recommended in tip 33 to write on one line a few operators putting them on the place of the vector-lines elements (matrixes with one line[1]).

It was impossible to place a few operators on returnable line of the program[2], as since in this case the program returns the values of a few operators united in array but not the value of the last operator. This disadvantage can be the advantage: the apotheosis of the technology of decrease the number of line we can consider the program with one line -array one-line-program. Such program-function that solves our old problem about the volume of a cone (see tip 30, 35, 36, 37, 69 and etc.), which returns the values of all its local variables and commentaries to them is showed in the fig. 91. It is very convenient during program debugging. If it is necessary that the on-line-function returned only one (the last) value then it is enough to call it with specifying of necessary element of the matrix V(10, 15)3, 1 = 370.24.



[1] Alternative method is placing the operators on one program line on the place of products efficients. Apart in Mathcad 7 Pro it is possible to place a few operators on one line dividing them by commas.

[2] As rule this is the last line of the program. But exclusions can be when the operator is taken out of the program by the operator return, for example.