Generic swap: Difference between revisions
→{{header|langur}}
m (→{{header|MiniScript}}: Fixed {{out}} tag) |
Langurmonkey (talk | contribs) |
||
(4 intermediate revisions by 4 users not shown) | |||
Line 863:
B = [1, 2, 3, 4, 5]
</pre>
=={{header|Binary Lambda Calculus}}==
From https://github.com/tromp/AIT/blob/master/rosetta/swap.lam we get the 25-bit swap function
<pre>0001100000000101101101110</pre>
=={{header|BQN}}==
Line 1,590 ⟶ 1,594:
{{FormulaeEntry|page=https://formulae.org/?script=examples/Generic_swap}}
'''Solution'''
Fōrmulæ supports assignments of several symbols (provided as a list) from an expression that reduces to a list of the same cardinality (the expression is first reduced before the actual assignment).
This can be used to do a generic swap as follows:
[[File:Fōrmulæ - Generic swap 01.png]]
'''Test case'''
[[File:Fōrmulæ - Generic swap 02.png]]
[[File:Fōrmulæ - Generic swap 03.png]]
=={{header|Gecho}}==
Line 2,052 ⟶ 2,070:
=={{header|langur}}==
<syntaxhighlight lang="langur">var .abc = [1, 2, 3]
var .def = [5, 6, 7]
Line 2,062 ⟶ 2,079:
writeln .abc
writeln .def</syntaxhighlight>
{{out}}
Line 3,667 ⟶ 3,680:
Both approaches are illustrated below.
<syntaxhighlight lang="
var a = 6
|