6.1.6 Transforming a list into a boolean expression: list2exp
The list2exp command is the inverse of exp2list; it
takes lists and tranforms them into boolean expressions. It can do
this in two ways.
The first way:
-
list2exp takes two arguments:
-
L, a list of values of
the form [a1,…,an]
- x, a variable name.
- list2exp(L,x) returns
the boolean expression ((x=a1) or …(x=an)).
Examples.
Alternatively:
-
list2exp takes two arguments:
-
L, a list where each element of L it itself a list
of n values of the form [a1,…,an].
- vars, a list [x1,…,xn] of n variable names.
In this case:
- list2exp(L,vars) returns a
boolean expression of the form
((x1=a1) and …and (xn=an) for each
list of n values in the first argument, combined with ors.
Example.
Input:
list2exp([[3,9], [-1,1]], [x, y])
Output: