# Transforming a list into a boolean expression: list2exp

### 5.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.

- Input:
  list2exp([0,1,2],a)
  Output:

  a=0∨ a=1∨ a=2

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

  x=−1∨ x=1

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:

x=3∧ y=9∨ x=−1∧ y=1