1
0
mirror of synced 2026-02-04 07:53:24 +00:00
Files
Interlisp.medley/internal/test/LANGUAGE/AUTO/15-6-RASSOC-IF.TEST

83 lines
2.5 KiB
Plaintext

;; Function To Be Tested: RASSOC-IF
;;
;; Source: Guy L Steele's CLTL
;; Section: 15.6 Association Lists
;; Page: 281
;;
;; Created By: Kelly Roach
;;
;; Creation Date: June 27,1986
;;
;; Last Update: June 27,1986
;;
;; Filed As: {ERIS}<LISPCORE>CML>TEST>15-6-RASSOC-IF.TEST
;;
;;
;; Syntax: (RASSOC-IF PREDICATE ALIST)
;;
;; Function Description:
;; RASSOC is the reverse form of ASSOC; it searches for
;; a pair whose CDR satisfies the test, rather than the CAR.
;; If the A-LIST is considered to be a mapping, then RASSOC
;; treats the A-LIST as representing the inverse mapping.
;; For example:
;;
;; (RASSOC 'A '((A . B) (B . C) (C . A) (Z . A))) => (C . A)
;;
;;
;; The expressions
;;
;; (RASSOC ITEM LIST :TEST FN)
;;
;; and
;;
;; (FIND ITEM LIST :TEST FN :KEY #'CDR)
;;
;; are equivalent in meaning, except when the ITEM is NIL
;; and NIL appears in place of a pair in the a-list. See the discussion
;; of the function function ASSOC.
;;
;; Argument(s): PREDICATE - a function
;; ALIST - an association list
;;
;; Returns: a list
;;
(DO-TEST "RASSOC-IF TEST 1" (EQUAL (RASSOC-IF (QUOTE NUMBERP)
(QUOTE ((1 . 1)
(2 . A)
(3 . "FOO")
(4 1 2)
(T))))
(QUOTE (1 . 1)))
(EQUAL (RASSOC-IF (QUOTE SYMBOLP)
(QUOTE ((1 . 1)
(2 . A)
(3 . "FOO")
(4 1 2)
(T))))
(QUOTE (2 . A)))
(EQUAL (RASSOC-IF (QUOTE STRINGP)
(QUOTE ((1 . 1)
(2 . A)
(3 . "FOO")
(4 1 2)
(T))))
(QUOTE (3 . "FOO")))
(EQUAL (RASSOC-IF (QUOTE LISTP)
(QUOTE ((1 . 1)
(2 . A)
(3 . "FOO")
(4 1 2)
(T))))
(QUOTE (4 1 2)))
(EQUAL (RASSOC-IF (QUOTE NULL)
(QUOTE ((1 . 1)
(2 . A)
(3 . "FOO")
(4 1 2)
(T))))
(QUOTE (T))))
STOP