# Comparison Operators in LISP

• Last Updated : 07 Sep, 2021

In this article, we will discuss the comparison operators in LISP. These operators are used to compare numbers by taking two or more operands.

Note: This will work only on numbers,

### Different comparison operators are:

Example: LISP Program demo on comparison operators.

## Lisp

 `;set value ``1` `to ``100` `; set value ``2` `to ``200` `(setq val1 ``100``) ` `(setq val2 ``200``) ` ` `  `;check val1 is ``equal` `to val2 or ``not` `(print (``=` `val1 val2)) ` ` `  `;check val1 is ``not` `equal` `to val2 or ``not` `(print (``/``=` `val1 val2)) ` ` `  `;check val1 is greater than val2 or ``not` `(print (> val1 val2)) ` ` `  `;check val1 is less than val2 or ``not` `(print (< val1 val2)) ` ` `  `;check val1 is greater than or ``equal` `to val2 or ``not` `(print (>``=` `val1 val2)) ` ` `  `;check val1 is less than or ``equal` `to val2 or ``not` `(print (<``=` `val1 val2)) ` ` `  `;get maximum number among val1 and val2 ` `(print (max val1 val2)) ` ` `  `;get minimum number among val1 and val2 ` `(print (min val1 val2))`

Output:

```NIL
T
NIL
T
NIL
T
200
100 ```

Example 2:

## Lisp

 `;set value ``1` `to ``20` `; set value ``2` `to ``70` `(setq val1 ``20``) ` `(setq val2 ``70``) ` ` `  `;check val1 is ``equal` `to val2 or ``not` `(print (``=` `val1 val2)) ` ` `  `;check val1 is ``not` `equal` `to val2 or ``not` `(print (``/``=` `val1 val2)) ` ` `  `;check val1 is greater than val2 or ``not` `(print (> val1 val2)) ` ` `  `;check val1 is less than val2 or ``not` `(print (< val1 val2)) ` ` `  `;check val1 is greater than or ``equal` `to val2 or ``not` `(print (>``=` `val1 val2)) ` ` `  `;check val1 is less than or ``equal` `to val2 or ``not` `(print (<``=` `val1 val2)) ` ` `  `;get maximum number among val1 and val2 ` `(print (max val1 val2)) ` ` `  `;get minimum number among val1 and val2 ` `(print (min val1 val2))`

Output:

```NIL
T
NIL
T
NIL
T
70
20 ```

Example 3: LISP program operands with equal numbers.

## Lisp

 `;set value ``1` `to ``50` `; set value ``2` `to ``50` `(setq val1 ``50``) ` `(setq val2 ``50``) ` ` `  `;check val1 is ``equal` `to val2 or ``not` `(print (``=` `val1 val2)) ` ` `  `;check val1 is ``not` `equal` `to val2 or ``not` `(print (``/``=` `val1 val2)) ` ` `  `;check val1 is greater than val2 or ``not` `(print (> val1 val2)) ` ` `  `;check val1 is less than val2 or ``not` `(print (< val1 val2)) ` ` `  `;check val1 is greater than or ``equal` `to val2 or ``not` `(print (>``=` `val1 val2)) ` ` `  `;check val1 is less than or ``equal` `to val2 or ``not` `(print (<``=` `val1 val2)) ` ` `  `;get maximum number among val1 and val2 ` `(print (max val1 val2)) ` ` `  `;get minimum number among val1 and val2 ` `(print (min val1 val2))`

Output:

```T
NIL
NIL
NIL
T
T
50
50 ```

My Personal Notes arrow_drop_up
Recommended Articles
Page :