swap two variables
1
Name:
Anonymous
2007-09-30 7:55
ID:F38kBPKI
hi
(setq x (prog2 0 y (setq y x)))
i bet your language can't do it.
2
Name:
Anonymous
2007-09-30 8:00
ID:WpfVZsy4
in b4 xor swap
3
Name:
Anonymous
2007-09-30 8:01
ID:Heaven
x, y = y, x
4
Name:
Anonymous
2007-09-30 8:08
ID:Heaven
what about FP languages? ha-ha!
5
Name:
Anonymous
2007-09-30 9:05
ID:IBdREupD
(psetq x y y x)[/code]
6
Name:
Anonymous
2007-09-30 9:05
ID:IBdREupD
(psetq x y y x)
7
Name:
Anonymous
2007-09-30 9:06
ID:IBdREupD
(rotatef x y)
(rotatef x y)
(rotatef x y)
(rotatef x y)
(rotatef x y)
8
Name:
Anonymous
2007-09-30 9:18
ID:UUbzqcbb
xchg ax, bx
9
Name:
Anonymous
2007-09-30 9:18
ID:hE8wpkfa
>>3
ONE WORD: FORCED SWAPDENTATION OF TWO VARIABLES. THREAD OVER.
10
Name:
Anonymous
2007-09-30 11:11
ID:1JrzmVq4
stack-based languages are superior.
swap
11
Name:
Anonymous
2007-09-30 11:11
ID:Heaven
($x,$y)=($y,$x);
12
Name:
Anonymous
2007-09-30 11:37
ID:yovt1Pqa
Recursion is superior.
asd a b = if cond a b then asd b a else proc a b
13
Name:
Anonymous
2007-09-30 11:44
ID:QBVbiUkN
Storing intermediate values in registers is superior.
LDA VAR1
LDX VAR2
STX VAR1
STA VAR2
RTS
14
Name:
Anonymous
2007-09-30 13:11
ID:hE8wpkfa
PLEASE SWAP #31 #30
DO NOT COMEFROM
PLEASE GIVE UP
15
Name:
Anonymous
2007-09-30 14:46
ID:7xqwMdmd
list($y, $x) = array($x, $y);
16
Name:
Anonymous
2007-09-30 14:56
ID:Heaven
(define (swap a b) (swap b a))
17
Name:
Anonymous
2007-09-30 15:06
ID:1ZJW5oNL
swap(a,b);
18
Name:
Anonymous
2007-09-30 15:23
ID:mDpLCdcY
>>16
What is this, some Jewish infinite loop?
19
Name:
Anonymous
2007-09-30 15:37
ID:Heaven
>>14
I want to have sex with you.
20
Name:
Anonymous
2007-09-30 16:35
ID:wthgDb+g
21
Name:
Anonymous
2007-09-30 18:14
ID:lCxVKh3C
template<class T>
void swap(T& a, T& b)
{
T c = a;
a = b;
b = c;
}
22
Name:
Anonymous
2007-09-30 18:27
ID:uwUvcSY+
map{(($a&(2**$_))!=($b&(2**$_)))?do{$a^=(2**$_);$b^=(2**$_)}:{}}(0..7);
23
Name:
Anonymous
2007-10-01 0:02
ID:Heaven
>>22
stack-based languages rule
totally readable
24
Name:
Anonymous
2007-10-01 2:58
ID:fuyh8dKA
x;y;x:y:
25
Name:
Anonymous
2007-10-01 2:58
ID:fuyh8dKA
x;y;x:y:
26
Name:
Anonymous
2007-10-01 6:54
ID:NwejOrEu
appletalk script for swapping two ``variables''
---
Boot up Computer and login to my user account.
Close all applications.
Prompt user "variable a is?" and store in 'a'
Prompt user "variable b is?" and store in 'b'
Store a in c
Set a to b
Set b to c
Print a = 'a' and b = 'b' to the screen
Turn off computer
27
Name:
Anonymous
2007-10-01 7:33
ID:3yKxsij9
!swap_ab enter
move a to c.
move b to a.
move c to b.
exit.
28
Name:
Anonymous
2007-10-01 7:50
ID:LS/bx+lZ
public static void swap(object a, object b)
{object c = a;a=b;b=c;
}
29
Name:
Anonymous
2007-10-01 8:01
ID:BjIIjE7l
>>28
ewwwwwwwwwwwwwwwwwwwwwwwwwww
30
Name:
Anonymous
2007-10-01 8:02
ID:BjIIjE7l
Swap.
Chapter 1.
Actors A, B.
Props tmp.
There once was a variable named tmp, It assumed the value of A and then A did of B, Shortly after B assumed the value of tmp and all was well.
The End.
31
Name:
Anonymous
2007-10-01 8:05
ID:BjIIjE7l
(define (swap-car-with-other-car x-y) (cons (cdr x-y) (car y-x)))
32
Name:
Anonymous
2007-10-01 9:10
ID:ol5XRPTU
>>31
my other car is swapped
33
Name:
Anonymous
2007-10-01 9:14
ID:iyKz9AWu
Impure!
34
Name:
Anonymous
2007-10-01 15:50
ID:L/B/4lQP
for all a: b
for all b: a
end of thread
35
Name:
Anonymous
2007-10-01 15:58
ID:Heaven
a=tmp
a=b
b=tmp
36
Name:
Anonymous
2007-10-01 16:03
ID:BjIIjE7l
37
Name:
Anonymous
2007-10-01 18:34
ID:RKLvApQy
#include <stdio.h>
int main(){
int x = 2;
int y = 1;
printf("x: %d, y: %d", y, x);
return 0;
}
38
Name:
anonymous
2007-10-01 18:37
ID:YmbcxbHS
std::swap(a,b);
39
Name:
Anonymous
2007-10-02 1:57
ID:2fzzAXBu
HAHAHAHA
XCHG EAX, EBX
how did I wroted programming language?
40
Name:
Anonymous
2007-10-02 2:51
ID:ef4s2UwK
swap (w1:w2:ws) = w2:w1:ws
41
Name:
Anonymous
2007-10-02 4:33
ID:Heaven
10 LET TEMP$=A$
20 LET A$=B$
30 LET B$=A$
42
Name:
Anonymous
2009-02-25 7:57
Chapter It has a good introduction on.
44
Name:
Anonymous
2011-01-31 20:27
<-- check em dubz
45
Name:
Anonymous
2011-02-04 14:49
46
Name:
Anonymous
2011-02-04 17:48