1
0
mirror of synced 2026-05-03 06:39:40 +00:00
Files
Interlisp.medley/internal/test/LANGUAGE/AUTO/6-4-OR.TEST

73 lines
2.2 KiB
Plaintext

;; Function To Be Tested: OR
;;
;; Source: Guy L Steele's CLTL
;; Section: 6.4 Logical Operators
;; Page: 83
;;
;; Created By: Kelly Roach
;;
;; Creation Date: 25-Jul-86
;;
;; Last Update: 25-Jul-86
;;
;; Filed As: {ERIS}<LISPCORE>CML>TEST>6-4-OR.TEST
;;
;;
;; Syntax: (OR &REST FORMS)
;;
;; Function Description:
;;
;; (OR FORM1 FORM2 ... ) evaluates each FORM, one at a time,
;; from left to right. If any FORM other than the last
;; evaluates to something other than NIL,
;; OR
;; immediately returns that non-NIL value without evaluating the remaining
;; FORMS. If every FORM but the last evaluates to NIL,
;; OR returns whatever evaluation of the last of the FORMS returns.
;; Therefore in general OR can be used both for logical operations,
;; where NIL stands for FALSE and non-NIL values stand for TRUE,
;; and as a conditional expression.
;;
;; To put it another way,
;; the OR special form does SHORT-CIRCUIT Boolean evaluation,
;; like the or else operator in Ada
;; and what in some Pascal-like languages is called cor (for ``conditional
;; or''); the Lisp OR special form is
;; unlike the Pascal or Ada or operator,
;; which always evaluates both arguments.
;;
;; From the general definition, one can deduce that
;; (OR X) = X. Also,
;; (OR) evaluates to NIL, which is the identity for this operation.
;;
;; One can define OR in terms of macro COND in this way:
;;
;; (OR X Y Z ... W) = (COND (X) (Y) (Z) ... (T W))
;;
;;
;; See IF and macro UNLESS, which are sometimes
;; stylistically more appropriate than OR for conditional purposes.
;; If it is necessary to test whether a predicate is true
;; one or more elements of a list or vector (element 0 OR element 1 OR
;; element 2 OR...), then the function function SOME may be useful.
;;
;; Argument(s): Any number of Lisp objects.
;;
;; Returns: A Lisp object.
;;
(DO-TEST "TEST OR 1"
(AND (EQ (OR) NIL)
(EQ (OR NIL) NIL)
(EQ (OR T) T)
(EQ (OR 123) 123)
(EQ (OR 'ATOM) 'ATOM)
(EQ (OR NIL NIL) NIL)
(EQ (OR NIL T) T)
(EQ (OR NIL T 100) T)
(EQ (OR 100 NIL T) 100)
(EQ (OR NIL 1 NIL 2 NIL 3) 1)
(EQ (OR NIL NIL 10 20 NIL) 10)))
STOP