Logical operations: Difference between revisions

Content added Content deleted
(→‎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: Line 3,790:
puts "not a: [expr {!$a}]"
puts "not a: [expr {!$a}]"
}</lang>
}</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}}==
=={{header|Toka}}==