1 vector swap(float x, float y) {
3 // everyone knows this trick
32 print("commutative\n");
35 if (x ^ (y ^ z) == (x ^ y) ^ z)
36 print("assocative\n");
38 // elements are their own inverse?
44 // are legal in constant expressions (currently)
48 print("vv: ", vtos(v1 ^ v2), "\n");
49 print("vf: ", vtos(v1 ^ 10), "\n");
51 const vector v3 = '5 2 5' ^ '3 10 3';
52 const vector v4 = '5 2 5' ^ 10;
54 print("vv: ", vtos(v3), "\n");
55 print("vf: ", vtos(v4), "\n");
57 // good olde xor swap test too
60 vector swaps = swap(swap_x, swap_y);
61 print("100:200 swapped is: ", ftos(swaps.x), ":", ftos(swaps.y), "\n");
63 // good olde xor swap test too
64 vector swap_u = '1 2 3';
65 vector swap_v = '4 5 6';
69 print("'1 2 3':'4 5 6' swapped is: ", vtos(swap_u), ":", vtos(swap_v), "\n");
71 // the one that showed us overlap bugs
72 print(vtos('1 2 3' ^ f('3 2 1') ^ f('1 1 1')), "\n");
73 print(vtos('1 2 3' ^ f('3 2 1') ^ 3), "\n");
74 print(vtos('1 2 3' ^ 6 ^ 3), "\n");
75 print(vtos('1 2 3' ^ 6 ^ f('1 1 1')), "\n");
76 print(vtos('1 2 3' ^ 5), "\n");