Sha256: d45e02880d17bfd548383fe54ef09ffa366a6e52e1c5b902bb95041be1bf8a63

Contents?: true

Size: 618 Bytes

Versions: 10

Compression:

Stored size: 618 Bytes

Contents

HCL doesn't have an exponentiation operator and even integer division is contrived as shown in the code, but at least it prints the output variables alphabetically without any effort.......

#Aamrun, 15th August 2022

variable "a" {
  type = number
}

variable "b" {
  type = number
}

output "Sum" {
  value = var.a + var.b
}

output "Difference" {
  value = var.a - var.b
}

output "Product" {
  value = var.a * var.b
}

output "Quotient" {
  value = floor(var.a / var.b)
}

output "Remainder" {
  value = var.a % var.b
}

The floor function rounds to the closest lowest integer. Invocation and output are as below :

Version data entries

10 entries across 7 versions & 1 rubygems

Version Path
zettacode-0.1.7 files.zettacode/arithmetic.integer/terraform.txt
zettacode-0.1.6 files.zettacode/arithmetic.integer/terraform.txt
zettacode-0.1.6 files.zettacode2/arithmetic.integer/terraform.txt
zettacode-0.1.5 files.zettacode/arithmetic.integer/terraform.txt
zettacode-0.1.5 files.zettacode2/arithmetic.integer/terraform.txt
zettacode-0.1.4 files.zettacode/arithmetic.integer/terraform.txt
zettacode-0.1.4 files.zettacode2/arithmetic.integer/terraform.txt
zettacode-0.1.3 files.zettacode/arithmetic.integer/terraform.txt
zettacode-0.1.2 files.zettacode/arithmetic.integer/terraform.txt
zettacode-0.1.1 zettacode.files/arithmetic.integer/terraform.txt