Transform a list into a boolean expression: list2exp

### 5.2.5 Transform a list into a boolean expression: list2exp

The list2exp command is the inverse of exp2list. It takes two arguments; a list [val1, val2, ...] of values and a variable name var.
list2exp returns the boolean expression ((var = val1) or (var = val2) or ...).
Input:

list2exp([0,1],a)

Output:

((a=0) or (a=1))

Input:

list2exp(solve(x^2-1=0,x),x)

Output:

((x=-1) or (x=1))

Alternatively, each element of the list could be a list with n values, followed by a list of n variables. The output would be boolean expressions of the form ((var1 = val1) and (var2 = val2) ...) for each list of n values, combined with ors. Input:

list2exp ([[3,9], [-1,1]], [x, y])

Output:

((((x=3) and (y=9))) or (((x=-1) and (y=1))))