RosettaCodeData/Task/Generic-swap/RLaB/generic-swap.rlab
2023-07-01 13:44:08 -04:00

22 lines
246 B
Text

swap = function(x,y)
{
if (!exist($$.[x]))
{ return 0; }
if (!exist($$.[y]))
{ return 0; }
local (t);
t = $$.[x];
$$.[x] = $$.[y];
$$.[y] = t;
return 1;
};
>> a=1
1
>> b = "fish"
fish
>> swap( "a" , "b" );
>> a
fish
>> b
1