Can we have a SWAP command? It interchange the value of 2 variables:
function swap: a,b
local temp
temp=a
a=b
b=temp
endfunction
=D
Yeah, Im lazy
Hmm . . . now if we had function overloading this could be possible to do on our own . . . ! :D
Even for TYPES!
Truth is, you now have that command.
*Directed by M. Night Shyamalan* :P
OK, I'll add a SWAP command.
Will it impact code? I mean "SWAP" might have been used as a variable in old code).
Quote from: Kitty Hello on 2011-Oct-14OK, I'll add a SWAP command.
lol really? was sure this was just joking... A new command for something you can do with 3 lines of code? Will your command be faster than doing this by myself? Otherwise I wont see a reason for adding such a command, werent you always trying to keep the number of available commands as low as possible?
Actually I think it would make for neater code, especially if you were doing card shuffling in a loop, save calling a function. Not that it would be quicker but would be neater :~)
This is cool for not using a temp variable...
a% = bXOR(a%,b%) ; b% = bXOR(b%,a%) ; a% = bXOR(a%,b%)
as a function...
FUNCTION Swap: BYREF SwapValue1%, BYREF SwapValue2%
SwapValue1% = bXOR(SwapValue1%,SwapValue2%)
SwapValue2% = bXOR(SwapValue2%,SwapValue1%)
SwapValue1% = bXOR(SwapValue1%,SwapValue2%)
ENDFUNCTION
FUNCTION swap: BYREF a, BYREF b
LOCAL temp
temp = a
a = b
b=temp
ENDFUNCTION
Should work, right? Having a fewer so might be thinking strange. Untested :-)
my SWAP command is a template, working for any object type.