jq lacks any bitwise operators/functions. This is why secret-handshake
and allergies
are foregone
They are possible to implement.
However, these exercises really only need “shift-right” and “and 1” operations to test if a bit is set in the number. These are easily implementable with division/modulo by a power of 2.
I’m wondering, though, if a “bitwise operations” concept is worth writing – it would basically expand upon what I just said. The exercise would have the students write, perhaps, shift_left
, shift_right
, bit_at
functions. At the end of it, the students will have a little library of bitwise functions they can go back to.
Full and
and or
functions can be left as extra homework.
Thoughts?