Bits (Booleans)
Type signatures are provisional and may contain errors.
Sire has an incomplete type system. No type checks are enforced at this point. Type signatures are provided for the intended behavior.
Constants
TRUE
Represents the boolean value true.
TRUE == 1FALSE
Represents the boolean value false.
FALSE == 0Conditionals
if
(if x t e)
> x : Bool
> t : a
> e : a
> aConditional operation. If the condition is true (non-zero), returns the second argument, otherwise returns the third argument.
if 1 {yes} {no} == %yes
if 0 {yes} {no} == %no
if TRUE 1 2 == 1
if FALSE 1 2 == 2ifNot
(ifNot x t e)
> x : Bool
> t : a
> e : a
> aInverted conditional. If the condition is false (zero), returns the second argument, otherwise returns the third argument.
ifNot 1 {yes} {no} == %no
ifNot 0 {yes} {no} == %yes
ifNot TRUE 1 2 == 2
ifNot FALSE 1 2 == 1ifz
(ifz x t e)
> x : a
> t : a
> e : a
> aConditional based on zero. If the first argument is zero, returns the second argument, otherwise returns the third argument.
ifz 0 b#zero b#nonzero == b#zero
ifz 1 b#zero b#nonzero == b#nonzero
ifz 42 b#zero b#nonzero == b#nonzeroifNonZero
(ifNonZero x t e)
> x : a
> t : a
> e : a
> aConditional based on non-zero. If the first argument is non-zero, returns the second argument, otherwise returns the third argument.
ifNonZero 0 b#zero b#nonzero == b#nonzero
ifNonZero 1 b#zero b#nonzero == b#zero
ifNonZero 42 b#zero b#nonzero == b#zeroelse
Identity function, used to improve readability in conditional expressions.
else 10 == 10Bit Operations
bit
(bit x)
> x : Bool
> BoolConverts a value to a bit (0 or 1).
bit 0 == 0
bit 1 == 1
bit 42 == 1
bit FALSE == 0
bit NIL == 0not
(not x)
> x : Bool
> BoolLogical NOT operation.
not 0 == 1
not 1 == 0
not 42 == 0
not FALSE == 1
not TRUE == 0and
(and x y)
> x : Bool
> y : Bool
> BoolLogical AND operation.
and 0 0 == 0
and 0 1 == 0
and 1 0 == 0
and 1 1 == 1
and TRUE FALSE == 0
and TRUE TRUE == 1or
(or x y)
> x : Bool
> y : Bool
> BoolLogical OR operation.
or 0 0 == 0
or 0 1 == 1
or 1 0 == 1
or 1 1 == 1
or TRUE FALSE == 1
or FALSE FALSE == 0xor
(xor x y)
> x : Bool
> y : Bool
> BoolLogical XOR (exclusive OR) operation.
xor 0 0 == 0
xor 0 1 == 1
xor 1 0 == 1
xor 1 1 == 0
xor TRUE FALSE == 1
xor TRUE TRUE == 0nand
(nand x y)
> x : Bool
> y : Bool
> BoolLogical NAND (NOT AND) operation.
nand 0 0 == 1
nand 0 1 == 1
nand 1 0 == 1
nand 1 1 == 0
nand TRUE FALSE == 1
nand TRUE TRUE == 0nor
(nor x y)
> x : Bool
> y : Bool
> BoolLogical NOR (NOT OR) operation.
nor 0 0 == 1
nor 0 1 == 0
nor 1 0 == 0
nor 1 1 == 0
nor TRUE FALSE == 0
nor FALSE FALSE == 1xnor
(xnor x y)
> x : Bool
> y : Bool
> BoolLogical XNOR (NOT XOR) operation.
xnor 0 0 == 1
xnor 0 1 == 0
xnor 1 0 == 0
xnor 1 1 == 1
xnor TRUE FALSE == 0
xnor TRUE TRUE == 1Last updated