lt-core/lt-stdlib/bool.lt
2024-12-24 12:51:36 +01:00

31 lines
805 B
Text

/*
*
*/
export {
let bool-norm =
λ { x: Bool ~ machine.Word; }
↦ if(x) {
(1 des machine.Word) as Bool;
} else {
(0 des machine.Word) as Bool;
};
let bool-neg =
λ { x: Bool ~ machine.Word; }
↦ (bit-and (bit-neg (bool-norm x)) 1) as Bool;
let bool-or =
λ { a: Bool ~ machine.Word;
b: Bool ~ machine.Word; }
↦ (bit-or a b) as Bool ~ machine.Word;
let bool-and =
λ{ a: Bool ~ machine.Word;
b: Bool ~ machine.Word; }
↦ (bit-and (bool-norm a) (bool-norm b)) as Bool ~ machine.Word;
let bool-xor =
λ{ a: Bool ~ machine.Word;
b: Bool ~ machine.Word; }
↦ (bit-xor (bool-norm a) (bool-norm b)) as Bool ~ machine.Word;
}