Published
Edited
Jan 10, 2020
Insert cell
Insert cell
Insert cell
// Define an IS_ZERO function
IS_ZERO = qtyFn => qtyFn(dont_care => lib.FALSE)(lib.TRUE)
Insert cell
lib.to_boolean(IS_ZERO(lib.ONE))
Insert cell
Insert cell
// Define an IS_LessThanEqual function
IS_LTE = val1 => val2 => IS_ZERO(lib.SUBTRACT(val1)(val2))
Insert cell
Insert cell
AND = bool1 => bool2 => bool1(bool2)(lib.FALSE)
Insert cell
OR = bool1 => bool2 => bool1(lib.TRUE)(bool2)
Insert cell
NOT = bool => bool(lib.FALSE)(lib.TRUE)
Insert cell
XOR = bool1 => bool2 => bool1(NOT(bool2))(bool2)
Insert cell
Insert cell
{
// Check the NOT function
return {
NOT_false : lib.to_boolean(NOT(lib.FALSE)),
NOT_true : lib.to_boolean(NOT(lib.TRUE))
}
}
Insert cell
{
// Check the AND function
return {
false_AND_false : lib.to_boolean(AND(lib.FALSE)(lib.FALSE)),
true_AND_false : lib.to_boolean(AND(lib.TRUE)(lib.FALSE)),
false_AND_true : lib.to_boolean(AND(lib.FALSE)(lib.TRUE)),
true_AND_true : lib.to_boolean(AND(lib.TRUE)(lib.TRUE))
}
}
Insert cell
{
// Check the OR function
return {
false_OR_false : lib.to_boolean(OR(lib.FALSE)(lib.FALSE)),
true_OR_false : lib.to_boolean(OR(lib.TRUE)(lib.FALSE)),
false_OR_true : lib.to_boolean(OR(lib.FALSE)(lib.TRUE)),
true_OR_true : lib.to_boolean(OR(lib.TRUE)(lib.TRUE))
}
}
Insert cell
{
// Check the XOR function
return {
false_XOR_false : lib.to_boolean(XOR(lib.FALSE)(lib.FALSE)),
true_XOR_false : lib.to_boolean(XOR(lib.TRUE)(lib.FALSE)),
false_XOR_true : lib.to_boolean(XOR(lib.FALSE)(lib.TRUE)),
true_XOR_true : lib.to_boolean(XOR(lib.TRUE)(lib.TRUE))
}
}
Insert cell
Insert cell
IS_LT = val1 => val2 => NOT(IS_LTE(val2)(val1))
Insert cell
// Check that our IS_LT function behaves correctly
{
return {
is_5_LT_8: lib.to_boolean(IS_LT(lib.FIVE)(lib.EIGHT)),
is_7_LT_4: lib.to_boolean(IS_LT(lib.SEVEN)(lib.FOUR)),
is_6_LT_6: lib.to_boolean(IS_LT(lib.SIX)(lib.SIX))
}
}
Insert cell
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more