3 ms·
Scroll the linked article down: the lisp “boole” function works the same way i.e. (boole 6 x y) is xor. Lisp has the same thing. But maybe the organisation isn’
by geocar 4y ago
Scroll the linked article down: the lisp “boole” function works the same way i.e. (boole 6 x y) is xor. Lisp has the same thing. But maybe the organisation isn’t clear?
Or is it the numeric value that you fear? There is a fantastic use for this, that if you don’t know, you may want to think about for more than a few seconds.
- rawling 4y ago> There is a fantastic use for this, that if you don’t know, you may want to think about for more than a few seconds. Is it one of the things in the table towards the bottom of the J article? I have to admit, I'm struggling to read the syntax.
- geocar 4y ago> Is it one of the things in the table towards the bottom of the J article? Erm, no. That table suggests using b. as a replacement for other (clearer) algorithms for performance reasons, rather than parameterisation. What I mean by parameterisation is this: if you have a function that takes some arbitrary bitwise operation, instead of taking a lambda, you can pass the truth-table directly. This idea is mentioned only briefly in the J article (More Info, ¶2): 2. Operand m may be an array, in which case each result cell will be the array of the results of the logical functions specified by m. Maybe that is too-obvious to an array programmer and not-enough-obvious to someone who isn't, and so it is hard to properly consider the implications or applications of this. Here's one: Parsing AND/OR operations from an expression (like an SQL expression). You could use a tree of operators and then walk the tree for every row you want to consider or you could store the compositions as a list and do a single reduction. Is that enough for you to get the idea of what is going on here?
- rawling 4y agoAh, ok. I'd got as far as going, you can call "&","|" etc. a number based on its truth table, and then you can extend this to other operators we don't think about so much by completing the number range, but I hadn't got so far as going... what... a = (o >> (x + 2y)) % 2 or something. I'd hoped it might involve adding/multiplying different operators together or something like that.
- mtlmtlmtlmtl 4y agoWouldn't it be more constructive to name this fantastic use, instead of just mentioning it and snarkily suggesting it's obvious?
- 082349872349872 4y agoMaybe geocar is too young to remember ROT13, and doesn't want to spoil things for those of us who did want to think about it first. fbzrgvzrf jr jnag gb pbzcbfr bcrengvbaf