Return multiple values: Difference between revisions

add BLC solution
imported>Thebeez
(Added uBasic/4tH version)
imported>Tromp
(add BLC solution)
 
(2 intermediate revisions by 2 users not shown)
Line 472:
<syntaxhighlight lang="qbasic">a = FUNC (_MulDiv (33, 11))
b = Pop()
 
Print "a * b = ";a, "a / b = ";b
 
Push 33, 11 : Proc _MulDiv
a = Pop() : b = Pop()
 
Print "a * b = ";a, "a / b = ";b
Line 483 ⟶ 488:
{{Out}}
<pre>a * b = 363 a / b = 3
a * b = 363 a / b = 3
 
0 OK, 0:75226 </pre>
 
=={{header|Binary Lambda Calculus}}==
0 OK, 0:75 </pre>
In the lambda calculus, one can return a tuple, which when applied to a function f, applies f to all the tuple elements. For example, <A,B,C> is <code>\f.f A B C</code>. Alternatively, one can use continuation-passing-style (cps), in which the function f is not applied the tuple return value, but instead is passed as an extra initial argument, and then the function can return f applied to the multiple values.
 
=={{header|BQN}}==
Line 3,425 ⟶ 3,434:
=={{header|Wren}}==
In Wren, one would return multiple values from a function or method by using some sort of Sequence object, usually a List though a Map could be used if you needed ''named'' returns.
<syntaxhighlight lang="ecmascriptwren">var splitName = Fn.new { |fullName| fullName.split(" ") }
 
var names = splitName.call("George Bernard Shaw")
Anonymous user