Generic swap: Difference between revisions
Content added Content deleted
(Generic swap in True BASIC) |
|||
Line 3,128: | Line 3,128: | ||
As with other stack-based languages (e.g. [[Factor]] and [[Joy]]), the solution to this task is a trivial matter of swapping the top two operands on the stack: |
As with other stack-based languages (e.g. [[Factor]] and [[Joy]]), the solution to this task is a trivial matter of swapping the top two operands on the stack: |
||
<lang trith>swap</lang> |
<lang trith>swap</lang> |
||
=={{header|True BASIC}}== |
|||
<lang qbasic>SUB swap(a, b) |
|||
LET temp = a |
|||
LET a = b |
|||
LET b = temp |
|||
END SUB |
|||
LET a = 1 |
|||
LET b = 2 |
|||
PRINT a, b |
|||
CALL swap(a, b) |
|||
PRINT a, b |
|||
END</lang> |
|||
=={{header|TXR}}== |
=={{header|TXR}}== |