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

19 lines
507 B
Text

// user-defined swap verb -- parms are passed by alias, not value, so they can be updated:
'<==> [_a] @FN [_b] { _a _b = _b _a } by_alias: ;
// test out swap verb
@VAR a = 12345;
@VAR b = "*****";
@SAY "a=" a " b=" b;
\b <==> \a; // "\" verb prevents evaluation of a and b here,
// so they can be passed by alias to <==>
@SAY "a=" a " b=" b;
a b = b a; // swap them back, just using the usual = verb
@SAY "a=" a " b=" b;