1 vector swap(float x, float y) {
3 // everyone knows this trick
28 print("commutative\n");
31 if (x ^ (y ^ z) == (x ^ y) ^ z)
32 print("assocative\n");
34 // elements are their own inverse?
40 // are legal in constant expressions (currently)
44 print("vv: ", vtos(v1 ^ v2), "\n");
45 print("vf: ", vtos(v1 ^ 10), "\n");
47 const vector v3 = '5 2 5' ^ '3 10 3';
48 const vector v4 = '5 2 5' ^ 10;
50 print("vv: ", vtos(v3), "\n");
51 print("vf: ", vtos(v4), "\n");
53 // good olde xor swap test too
56 vector swaps = swap(swap_x, swap_y);
57 print("100:200 swapped is: ", ftos(swaps.x), ":", ftos(swaps.y), "\n");
59 // good olde xor swap test too
60 vector swap_u = '1 2 3';
61 vector swap_v = '4 5 6';
65 print("'1 2 3':'4 5 6' swapped is: ", vtos(swap_u), ":", vtos(swap_v), "\n");