-
Notifications
You must be signed in to change notification settings - Fork 5
2) Types and Variables
Any string of uppercase latin letters is a variable identifier, initially not unified to anything. These variables and their possible values are not shared between rules.
?
and .
are special variables which are the Input and the Output of the current rule they are in.
Variables can be unified by using them as inputs or outputs to predicates or by direcly unifying them with other variables. For example, I J
will unify I
with J
(or fail if they cannot be unified).
Any variable with a following superscript is a global variables, which is shared between all predicates. For example, I⁰
is a global variable and the program "Hello, World!"I⁰∧{I⁰w}
will write "Hello, World!"
, even though no input is passed to predicate 1.
The input and output variables can also be superscripted. They will act like normal global variables and will not be linked in any way to the predicate's local input or output.
Constraint variables (uppercase letters with a dot above them) can also be superscripted. They will act like normal global variables but will be constrained like they would if they were not superscripted. For example, Ḋ¹
is a globally shared variable name which is constrained to be a digit.
String constants (uppercase letters with a dot below them) cannot be superscripted (they are constants, so this would be pointless).
Lists are noted in between square brackets [...]
and elements of a list are separated using ,
.
[]
denotes the empty list.
Strings are opened and closed with double quotes "..."
. \
will escape double quotes.
Integers and floats are written using the numbers 0 to 9 as expected. The decimal separator is .
. A floating point number must have at least one digit before and after the decimal separator.
Negative numbers are written using an underscore _
preceeding the number. This underscore is called the low minus in Brachylog.