Gamma: Version 4.0
Prev |  | Next

# Logical Operators

Logical Operators -- (`!`, `&&`, `||`)

## Syntax

    ! s_exp
    s_exp && s_exp ...
    s_exp || !s_exp ...

## Arguments

`s_exp`

  Any Gamma or Lisp expression.

## Returns

Non-nil or nil.

## Description

In Gamma or Lisp, any expression which is not nil is treated as being true (t) for the purpose of boolean logic. Applying `!` to any non-nil expression will produce nil. Applying `!` to nil must produce an arbitrary non-nil result. The generic non-nil value in Gamma is `t`.

`&&` evaluates each of its arguments in order, and continues so long as each argument evaluates to non-nil. If any argument is nil, then nil is returned immediately, without evaluating the rest of the arguments. If no argument is nil, the last argument is returned.

`||` returns non-nil if any of its arguments is not nil. Each argument is evaluated in turn, and as soon as a non-nil value is reached, that argument is returned. Subsequent arguments are not evaluated.

## Examples

        Gamma> 6;
        6
        Gamma> !6;
        nil
        Gamma> !nil;
        t
        Gamma> 5<6 && string("hi ","there");
        "hi there"
        Gamma> 5>6 && string("hi ","there");
        nil
        Gamma> x = 5;
        5
        Gamma> y = 6;
        6
        Gamma> (x = t) || (y = 0);
        t
        Gamma> x;
        t
        Gamma> y;
        6
        Gamma>

## See Also

`and, not, or`

Prev | Home | Next
Increment and Decrement Operators | Up | Quote Operators

Copyright 1995-2002 by Cogent Real-Time Systems, Inc.