Community Tip - Your Friends List is a way to easily have access to the community members that you interact with the most! X
This is a Mathcad 15 example of a function returning multiple values with different units.
Interesting approach.
You can achieve a similar effect using symbolic evaluation:
The symbolic evaluation of a program may fail though, whereas I think Christian's approach will always work. It's interesting that the second element of the matrix picks up on the local assignment in the program. You can also make the second element a program, and it sees all the local assignments in the program that is in the first element.
Yes, I, too, can imagine the symbolic eval method to fail now and then.
Christians approach is very interesting and may open new possibilities.
I am still not sure if the behaviour really is as it should be - the question being what a local assignment is local to. On the other hand we had often used a simple local variable assigment (= 1 line "program") in an element of a vector and used the assigned variable in the next vector element. Seems to be the same mechanism.
Interestingly the return statement is not allowed, throwing a "bad_pattern" error:
In MC11 you can do this:
In MC12 they broke that by making the assignments parallel, rather than sequential. So in MC13 and later they gave us a compatibility mode (that defaults to MC11) that unbroke it . It seems that when the assignments are in a vector the local program assignments are seen as in scope for all the subsequent assignments in other elements of the vector, but I doubt this was by conscious design. It could be a very useful oversight though. It appears to also work in Prime.