3 ms·
The order is implementation-specific. For the values I cared to sample below, CLISP seems to have sane values that reflect the truth tables: [1]> boole-clr
by kazinator 4y ago
The order is implementation-specific. For the values I cared to sample below, CLISP seems to have sane values that reflect the truth tables:
[1]> boole-clr
0
[2]> boole-set
15
[3]> boole-and
8
[4]> boole-ior
14
[5]> boole-nand
7
Obviously, values with this property are not unique; they depend on the bit combination order. boole-and and boole-ior could plausibly be 1 and 7.
IMHO, the latitude in the spec should be interpreted as accommodating this truth table ordering variation, and not as an invitation for arbitrarily enumerating the functions so that the values don't make sense as truth tables.
That is to say, it should be possible to perform logical operations on the values whose interpretation is that the truth tables are combined accordingly, such that these two are equivalent:
(boole (logior boole-xxx boole-yyy) a b)
<-->
(logior (boole boole-xxx a b) (boole boole-yyy a b))
No matter how boole-and is defined, (logior boole-and boole-nand) should produce 15, which should be the value of boole-set.
The vector indexing trick recommended in the boole function's example should only be necessary for a program which needs the operators to have concrete values corresponding to a particular choice of truth table bit order. It should not be necessary for obtaining indexing which has the above good behavior with respect to being able to use logical operators on the truth tables in order to combine them.
Indeed, the implementation from which you are reporting seems to have a broken numbering. For the boole-xor function, we need to see a value that has two zeros and two ones. If it's not one of the values 2, 5, 9, 6, 10, 12, then the numbering is broken. It is inescapable that boole-clr and boole-set must be 0 and 15.