Skip to main content

and

Use and to perform a boolean logic AND operation with short-circuiting.

Basic syntax

To perform a boolean logic AND operation between two boolean values oper1 and oper2, use the following syntax:

(and oper1 oper2)

Arguments

Use the following arguments to specify the boolean values for the and operation.

ArgumentTypeDescription
oper1boolSpecifies the first boolean value for the AND operation.
oper2boolSpecifies the second boolean value for the AND operation.

Return value

The and function returns a boolean value based on the result of the AND operation between the input boolean values.

Examples

The following example demonstrates how to use the and function to perform a boolean AND operation between the values true and false in the Pact REPL:

pact> (and true false)
false

The following example illustrates using the and function to evaluate two expressions to determine whether an account string is valid:

(and
(>= (length account) 3)
(<= (length account) 256))

In this example, both expressions must evaluate to true for an account string to be valid.