Boolean | m b. _ 0 0 |
The monad is equivalent to a zero left argument;
that is, m b. y ↔ 0 m b. y |
If f is a dyadic boolean function and d=: 0 1 ,
then d f/ d (or f/~d) is its complete table.
For example the tables for or, nor, and, and
not-and appear as follows:(+./~ ; +:/~ ; *./~ ; *:/~) d=: 0 1 +---+---+---+---+ |0 1|1 0|0 0|1 1| |1 1|0 0|0 1|1 0| +---+---+---+---+If ordered by their tables, each of the sixteen possible boolean dyads can be characterized by its index k ; the phrase k b. produces the corresponding function. Moreover, negative indexing and array arguments may be used. An atom m=16+k specifies bitwise boolean functions on integer arguments. An argument atom is treated as a list of length w of bits, where w is the word size of the underlying machine. For example, 17 b. specifies bitwise and. Finally, 32 b. specifies rotate, 33 b. specifies shift, and 34 b. specifies signed shift. |
m | Ravelled Table |
Function | ||||||
0 | _16 | 16 | 0 0 0 0 | 0 | ||||
1 | _15 | 17 | 0 0 0 1 | x *. y | ||||
2 | _14 | 18 | 0 0 1 0 | x > y | ||||
3 | _13 | 19 | 0 0 1 1 | x | ||||
4 | _12 | 20 | 0 1 0 0 | x < y | ||||
5 | _11 | 21 | 0 1 0 1 | y | ||||
6 | _10 | 22 | 0 1 1 0 | x ~: y | ||||
7 | _9 | 23 | 0 1 1 1 | x +. y | ||||
8 | _8 | 24 | 1 0 0 0 | x +: y | ||||
9 | _7 | 25 | 1 0 0 1 | x = y | ||||
10 | _6 | 26 | 1 0 1 0 | -. y | ||||
11 | _5 | 27 | 1 0 1 1 | x >: y | ||||
12 | _4 | 28 | 1 1 0 0 | -. x | ||||
13 | _3 | 29 | 1 1 0 1 | x <: y | ||||
14 | _2 | 30 | 1 1 1 0 | x *: y | ||||
15 | _1 | 31 | 1 1 1 1 | 1 | ||||
32 | rotate | |||||||
33 | shift | |||||||
34 | signed shift |
(7 b./~ ; 8 b./~ ; 1 b./~ ; 14 b./~) d=: 0 1 +---+---+---+---+ |0 1|1 0|0 0|1 1| |1 1|0 0|0 1|1 0| +---+---+---+---+ (_1 b./~ ; _3 b./~ ; _15 b./~) d NB. negative indexing +---+---+---+ |1 1|1 1|0 0| |1 1|0 1|0 1| +---+---+---+ (<"2) 2 0 1 |: 7 8 1 15 b./~ d NB. array arguments +---+---+---+---+ |0 1|1 0|0 0|1 1| |1 1|0 0|0 1|1 1| +---+---+---+---+ 12345 (17 b.) 67890 NB. bitwise and 48 f=: (32#2)&#: { '.x'"_ f 12345 67890 48 ..................xx......xxx..x ...............x....x..x..xx..x. ..........................xx.... _12345 (23 b.) 67890 NB. bitwise or _12297 f _12345 67890 _12297 xxxxxxxxxxxxxxxxxx..xxxxxx...xxx ...............x....x..x..xx..x. xxxxxxxxxxxxxxxxxx..xxxxxxxx.xxx 20 b./~ i.10 NB. bitwise less than table 0 1 2 3 4 5 6 7 8 9 0 0 2 2 4 4 6 6 8 8 0 1 0 1 4 5 4 5 8 9 0 0 0 0 4 4 4 4 8 8 0 1 2 3 0 1 2 3 8 9 0 0 2 2 0 0 2 2 8 8 0 1 0 1 0 1 0 1 8 9 0 0 0 0 0 0 0 0 8 8 0 1 2 3 4 5 6 7 0 1 0 0 2 2 4 4 6 6 0 0 23 b./\ 2^i.10 NB. cumulative bitwise or 1 3 7 15 31 63 127 255 511 1023 _5 (33 b.) 12345 NB. shift 385 f 12345 385 ..................xx......xxx..x .......................xx......x _5 (33 b.) _12345 NB. shift 134217342 f _12345 134217342 xxxxxxxxxxxxxxxxxx..xxxxxx...xxx .....xxxxxxxxxxxxxxxxxx..xxxxxx. _5 (34 b.) _12345 NB. signed shift _386 f _12345 _386 xxxxxxxxxxxxxxxxxx..xxxxxx...xxx xxxxxxxxxxxxxxxxxxxxxxx..xxxxxx.