Generic swap: Difference between revisions

Content added Content deleted
Line 2,950: Line 2,950:
1
1
</syntaxhighlight>
</syntaxhighlight>

=={{header|RPL}}==
{{works with|Halcyon Calc|4.2.7}}
{| class="wikitable"
! Code
! Comments
|-
|
≪ OVER TYPE 6 == OVER TYPE 6 == 2 * + 1 +
{ ≪ SWAP ≫
≪ OVER EVAL SWAP ROT STO ≫
≪ DUP EVAL ROT ROT STO ≫
≪ OVER EVAL OVER EVAL 4 ROLL STO SWAP STO ≫ }
SWAP GET EVAL
≫ 'GSWAP' STO
1 2 GSWAP
'A' 'B' GSWAP
3 'A' GSWAP
|
":#" means "stack level #"
calculate case index upon types of data at :1 and :2
case 1: swap :2 with :1
case 2: swap content of variable named at :2 with :1
case 3: swap content of variable named at :1 with :2
case 4: swap content of variables named at :1 and :2
select program from case index and execute it
|}


=={{header|Ruby}}==
=={{header|Ruby}}==