Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Add = numericalBinary(func(env envs.Environment, num1 types.XNumber, num2 types.XNumber) types.XValue { return types.NewXNumber(num1.Native().Add(num2.Native())) })
Add adds two numbers.
@(2 + 3) -> 5 @(fields.age + 10) -> 33
@operator add
var Concatenate = textualBinary(func(env envs.Environment, text1 types.XText, text2 types.XText) types.XValue { var buffer strings.Builder buffer.WriteString(text1.Native()) buffer.WriteString(text2.Native()) return types.NewXText(buffer.String()) })
Concatenate joins two text values together.
@("hello" & " " & "bar") -> hello bar @("hello" & null) -> hello
@operator concatenate
var Divide = numericalBinary(func(env envs.Environment, num1 types.XNumber, num2 types.XNumber) types.XValue { if num2.Equals(types.XNumberZero) { return types.NewXErrorf("division by zero") } return types.NewXNumber(num1.Native().Div(num2.Native())) })
Divide divides a number by another.
@(4 / 2) -> 2 @(3 / 2) -> 1.5 @(46 / fields.age) -> 2 @(3 / 0) -> ERROR
@operator divide
var Equal = textualBinary(func(env envs.Environment, text1 types.XText, text2 types.XText) types.XValue { return types.NewXBoolean(text1.Equals(text2)) })
Equal returns true if two values are textually equal.
@("hello" = "hello") -> true @("hello" = "bar") -> false @(1 = 1) -> true
@operator equal
var Exponent = numericalBinary(func(env envs.Environment, num1 types.XNumber, num2 types.XNumber) types.XValue { return types.NewXNumber(num1.Native().Pow(num2.Native())) })
Exponent raises a number to the power of a another number.
@(2 ^ 8) -> 256
@operator exponent
var GreaterThan = numericalBinary(func(env envs.Environment, num1 types.XNumber, num2 types.XNumber) types.XValue { return types.NewXBoolean(num1.Compare(num2) > 0) })
GreaterThan returns true if the first number is greater than the second.
@(2 > 3) -> false @(3 > 3) -> false @(4 > 3) -> true
@operator greaterthan
var GreaterThanOrEqual = numericalBinary(func(env envs.Environment, num1 types.XNumber, num2 types.XNumber) types.XValue { return types.NewXBoolean(num1.Compare(num2) >= 0) })
GreaterThanOrEqual returns true if the first number is greater than or equal to the second.
@(2 >= 3) -> false @(3 >= 3) -> true @(4 >= 3) -> true
@operator greaterthanorequal
var LessThan = numericalBinary(func(env envs.Environment, num1 types.XNumber, num2 types.XNumber) types.XValue { return types.NewXBoolean(num1.Compare(num2) < 0) })
LessThan returns true if the first number is less than the second.
@(2 < 3) -> true @(3 < 3) -> false @(4 < 3) -> false
@operator lessthan
var LessThanOrEqual = numericalBinary(func(env envs.Environment, num1 types.XNumber, num2 types.XNumber) types.XValue { return types.NewXBoolean(num1.Compare(num2) <= 0) })
LessThanOrEqual returns true if the first number is less than or equal to the second.
@(2 <= 3) -> true @(3 <= 3) -> true @(4 <= 3) -> false
@operator lessthanorequal
var Multiply = numericalBinary(func(env envs.Environment, num1 types.XNumber, num2 types.XNumber) types.XValue { return types.NewXNumber(num1.Native().Mul(num2.Native())) })
Multiply multiplies two numbers.
@(3 * 2) -> 6 @(fields.age * 3) -> 69
@operator multiply
var Negate = numericalUnary(func(env envs.Environment, num types.XNumber) types.XValue { return types.NewXNumber(num.Native().Neg()) })
Negate negates a number
@(-fields.age) -> -23
@operator negate
var NotEqual = textualBinary(func(env envs.Environment, text1 types.XText, text2 types.XText) types.XValue { return types.NewXBoolean(!text1.Equals(text2)) })
NotEqual returns true if two values are textually not equal.
@("hello" != "hello") -> false @("hello" != "bar") -> true @(1 != 2) -> true
@operator notequal
var Subtract = numericalBinary(func(env envs.Environment, num1 types.XNumber, num2 types.XNumber) types.XValue { return types.NewXNumber(num1.Native().Sub(num2.Native())) })
Subtract subtracts two numbers.
@(3 - 2) -> 1 @(2 - 3) -> -1
@operator subtract
Functions ¶
This section is empty.
Types ¶
type BinaryOperator ¶
BinaryOperator is an operator which takes two arguments
type UnaryOperator ¶
UnaryOperator is an operator which takes a single argument