Prolog “or” operator, query

you can ‘invoke’ alternative bindings on Y this way: Note the parenthesis are required to keep the correct execution control flow. The ;/2 it’s the general or operator. For your restricted use you could as well choice the more idiomatic that on backtracking binds Y to each member of the list. edit I understood with … Read more

Bitwise Less than or Equal to

If x > y, then y – x or (y + (~x + 1)) will be negative, hence the high bit will be 1, otherwise it will be 0. But we want x <= y, which is the negation of this. Even better, drop the shift operator and use a bit mask on the high … Read more

1 = false and 0 = true?

It is common for comparison functions to return 0 on “equals”, so that they can also return a negative number for “less than” and a positive number for “greater than”. strcmp() and memcmp() work like this. It is, however, idiomatic for zero to be false and nonzero to be true, because this is how the … Read more

tech