Exercises that use bitwise operations

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?

I’m hesitating about it because the topic is not a concept of the language, it’s about something missing from the language.

I don’t think it’s worth adding. It’s not part of jq. Just because it can be done doesn’t mean it should be :wink: It’s not a jq concept.

1 Like

I’ve ported secret-handshake, just cuz 48in24.

1 Like