Return multiple values: Difference between revisions
Content added Content deleted
Jazzedpineda (talk | contribs) (→EasyLang: Changed EasyLang implememtation) |
(Added Euler) |
||
Line 1,024: | Line 1,024: | ||
PRINT("Difference is";DIFF) |
PRINT("Difference is";DIFF) |
||
END PROGRAM |
END PROGRAM |
||
</syntaxhighlight> |
|||
=={{header|Euler}}== |
|||
Euler procedures can return a list (Euler's only data structure), ths is used here to return three values from the getMV procedure. |
|||
<br> |
|||
Procedures are defined by enclosing their text between ` and '. They can then be assigning to a variable for later use. |
|||
<br> |
|||
Lists are constructed by placing the values between ( and ). Once assigned to a variable, the list can be subscripted to access the individual elements (which can themselves be lists). |
|||
<syntaxhighlight lang="euler"> |
|||
begin |
|||
new mv; new getMV; |
|||
getMV <- ` formal v; ( v, v * v, v * v * v ) '; |
|||
mv <- getMV( 3 ); |
|||
out mv[ 1 ]; |
|||
out mv[ 2 ]; |
|||
out mv[ 3 ] |
|||
end $ |
|||
</syntaxhighlight> |
</syntaxhighlight> |
||