Jump to content

Logical operations: Difference between revisions

Added Terraform implemen
(→‎Delphi: fulfill task requirements and write a function [not a program], make reference to →‎Pascal: to deduplicate code, →‎Pascal: show/mention all operators, make use of formatted output capabilities)
(Added Terraform implemen)
Line 3,790:
puts "not a: [expr {!$a}]"
}</lang>
 
=={{header|Terraform}}==
The Hashicorp Configuration Language ( HCL ) does not support user defined functions. It only supports AND, OR and NOT logical operations. HCL is not meant for generic programming but I don't see an use case for a logarithm function in a language meant to provision infrastructure either. So......
 
<lang terraform>
variable "a" {
type = bool
default = true
}
 
variable "b" {
type = bool
default = false
}
 
output "a_and_b" {
value = var.a && var.b
}
 
output "a_or_b" {
value = var.a || var.b
}
 
output "not_a" {
value = !var.a
}
</lang>
Invocation and output :
<pre>
$ terraform apply -var="a=true" -var="b=false" -auto-approve
 
No changes. Your infrastructure matches the configuration.
 
Terraform has compared your real infrastructure against your configuration and found no differences, so no changes are needed.
 
Apply complete! Resources: 0 added, 0 changed, 0 destroyed.
 
Outputs:
 
a_and_b = false
a_or_b = true
not_a = false
$
</pre>
 
=={{header|Toka}}==
503

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.