Operator Functions
Standard library operator functions for mathematical and logical operations
and_bool returns the binary AND of the left- and right-hand-side arguments.
| Name | Type | Description |
|---|
lhs | bool | A boolean value |
rhs | bool | A boolean value |
| Name | Type | Description |
|---|
value | bool | The result of a binary AND between the two arguments |
output "my_bool" {
value = false && true
}
// > my_bool: false
or_bool returns the binary OR of the left- and right-hand-side arguments.
| Name | Type | Description |
|---|
lhs | bool | A boolean value |
rhs | bool | A boolean value |
| Name | Type | Description |
|---|
value | bool | The result of a binary OR between the two arguments |
output "my_bool" {
value = false || true
}
// > my_bool: true
div returns the integer division of the left-hand-side argument by the right-hand-side argument, rounding any remainder down to the nearest integer.
| Name | Type | Description |
|---|
lhs | integer | The dividend |
rhs | integer | The divisor |
| Name | Type | Description |
|---|
value | integer | The result of dividing the dividend by the divisor |
output "my_int" {
value = 11 / -3
}
// > my_int: -3
eq returns true if the left- and right-hand-side arguments are equal and false if they are not.
| Name | Type | Description |
|---|
lhs | any | Any value |
rhs | any | Any value |
| Name | Type | Description |
|---|
value | bool | The result of an equality check between the two inputs |
output "is_eq" {
value = "arg" == "arg"
}
// > is_eq: true
gt returns true if the left-hand-side argument is greater than the right-hand-side argument.
| Name | Type | Description |
|---|
lhs | integer | float | string | A comparable value |
rhs | integer | float | string | A comparable value |
| Name | Type | Description |
|---|
value | bool | The result of checking if the left-hand-side argument is greater than the right-hand-side argument |
output "is_gt" {
value = 2 > 1
}
// > is_gt: true
gte returns true if the left-hand-side argument is greater than or equal to the right-hand-side argument.
| Name | Type | Description |
|---|
lhs | integer | float | string | A comparable value |
rhs | integer | float | string | A comparable value |
| Name | Type | Description |
|---|
value | bool | The result of checking if the left-hand-side argument is greater than or equal to the right-hand-side argument |
output "is_gte" {
value = 2 >= 2
}
// > is_gte: true
lt returns true if the left-hand-side argument is less than the right-hand-side argument.
| Name | Type | Description |
|---|
lhs | integer | float | string | A comparable value |
rhs | integer | float | string | A comparable value |
| Name | Type | Description |
|---|
value | bool | The result of checking if the left-hand-side argument is less than the right-hand-side argument |
output "is_lt" {
value = 2 < 1
}
// > is_lt: false
lte returns true if the left-hand-side argument is less than or equal to the right-hand-side argument.
| Name | Type | Description |
|---|
lhs | integer | float | string | A comparable value |
rhs | integer | float | string | A comparable value |
| Name | Type | Description |
|---|
value | bool | The result of checking if the left-hand-side argument is less than or equal to the right-hand-side argument |
output "is_lte" {
value = 2 <= 2
}
// > is_lte: true
neq returns true if the left- and right-hand-side arguments are not equal and false otherwise.
| Name | Type | Description |
|---|
lhs | any | A value to compare |
rhs | any | A value to compare against |
| Name | Type | Description |
|---|
value | bool | The result of a negated equality check between the two inputs |
output "is_neq" {
value = "arg" != "arg"
}
// > is_neq: false
minus returns the result of subtracting the right-hand-side integer argument from the left-hand-side integer argument.
| Name | Type | Description |
|---|
lhs | integer | The minuend |
rhs | integer | The subtrahend |
| Name | Type | Description |
|---|
value | integer | The result of the subtraction operation |
output "my_integer" {
value = 10 - 6
}
// > my_integer: 4
modulo returns the remainder of dividing the left-hand-side integer argument by the right-hand-side integer argument.
| Name | Type | Description |
|---|
lhs | integer | The dividend |
rhs | integer | The divisor |
| Name | Type | Description |
|---|
value | integer | The remainder of the division operation |
output "my_mod" {
value = 10 % 3
}
// > my_mod: 1
multiply returns the product of the left-hand-side integer argument and the right-hand-side integer argument.
| Name | Type | Description |
|---|
lhs | integer | The first operand |
rhs | integer | The second operand |
| Name | Type | Description |
|---|
value | integer | The result of the multiplication operation |
output "my_product" {
value = 10 * 5
}
// > my_product: 50
add returns the sum of the left-hand-side integer argument and the right-hand-side integer argument.
| Name | Type | Description |
|---|
lhs | integer | The first operand |
rhs | integer | The second operand |
| Name | Type | Description |
|---|
value | integer | The result of the addition operation |
output "my_sum" {
value = 10 + 5
}
// > my_sum: 15
Returns the negation of the given integer.
| Name | Type | Description |
|---|
value | integer | An integer value |
| Name | Type | Description |
|---|
value | integer | The negated integer value |
Returns the logical negation of the given boolean value.
| Name | Type | Description |
|---|
value | bool | A boolean value |
| Name | Type | Description |
|---|
value | bool | The logical negation of the input boolean value |