on bfaa358 help sign in
54 lines 740 B history raw
1### `++mix`
3Binary XOR
5Produces the bit-wise logical XOR of `a` and `b`, producing an atom.
7Accepts
8-------
10`a` is an atom
12`b` is an atom
14Produces
15--------
17An atom.
19Source
20------
22 ++ mix :: binary xor
23 ~/ %mix
24 |= {a/@ b/@}
25 ^- @
26 =+ [c=0 d=0]
27 |-
28 ?: ?&(=(0 a) =(0 b)) d
29 %= $
30 a (rsh 0 1 a)
31 b (rsh 0 1 b)
32 c +(c)
33 d (add d (lsh 0 c =((end 0 1 a) (end 0 1 b))))
34 ==
36Examples
37--------
39 ~zod/try=> `@ub`2
40 0b10
41 ~zod/try=> `@ub`3
42 0b11
43 ~zod/try=> `@ub`(mix 2 3)
44 0b1
45 ~zod/try=> (mix 2 3)
46 1
47 ~zod/try=> `@ub`(mix 2 2)
48 0b0
49 ~zod/try=> (mix 2 2)
50 0
54***