15dfecf96Smrg;; 25dfecf96Smrg;; Copyright (c) 2002 by The XFree86 Project, Inc. 35dfecf96Smrg;; 45dfecf96Smrg;; Permission is hereby granted, free of charge, to any person obtaining a 55dfecf96Smrg;; copy of this software and associated documentation files (the "Software"), 65dfecf96Smrg;; to deal in the Software without restriction, including without limitation 75dfecf96Smrg;; the rights to use, copy, modify, merge, publish, distribute, sublicense, 85dfecf96Smrg;; and/or sell copies of the Software, and to permit persons to whom the 95dfecf96Smrg;; Software is furnished to do so, subject to the following conditions: 105dfecf96Smrg;; 115dfecf96Smrg;; The above copyright notice and this permission notice shall be included in 125dfecf96Smrg;; all copies or substantial portions of the Software. 135dfecf96Smrg;; 145dfecf96Smrg;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 155dfecf96Smrg;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 165dfecf96Smrg;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 175dfecf96Smrg;; THE XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 185dfecf96Smrg;; WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF 195dfecf96Smrg;; OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 205dfecf96Smrg;; SOFTWARE. 215dfecf96Smrg;; 225dfecf96Smrg;; Except as contained in this notice, the name of the XFree86 Project shall 235dfecf96Smrg;; not be used in advertising or otherwise to promote the sale, use or other 245dfecf96Smrg;; dealings in this Software without prior written authorization from the 255dfecf96Smrg;; XFree86 Project. 265dfecf96Smrg;; 275dfecf96Smrg;; Author: Paulo César Pereira de Andrade 285dfecf96Smrg;; 295dfecf96Smrg;; 305dfecf96Smrg;; $XFree86: xc/programs/xedit/lisp/test/list.lsp,v 1.5 2002/11/26 04:06:30 paulo Exp $ 315dfecf96Smrg;; 325dfecf96Smrg 335dfecf96Smrg;; basic lisp function tests 345dfecf96Smrg 355dfecf96Smrg;; Most of the tests are just the examples from the 365dfecf96Smrg;; 375dfecf96Smrg;; Common Lisp HyperSpec (TM) 385dfecf96Smrg;; Copyright 1996-2001, Xanalys Inc. All rights reserved. 395dfecf96Smrg;; 405dfecf96Smrg;; Some tests are hand crafted, to test how the interpreter treats 415dfecf96Smrg;; uncommon arguments or special conditions 425dfecf96Smrg 435dfecf96Smrg 445dfecf96Smrg#| 455dfecf96Smrg MAJOR PROBLEMS: 465dfecf96Smrg 475dfecf96Smrg o NIL and T should be always treated as symbols, actually it is 485dfecf96Smrg legal to say (defun nil (...) ...) 495dfecf96Smrg o There aren't true uninterned symbols, there are only symbols that 505dfecf96Smrg did not yet establish the home package, but once one is created, an 515dfecf96Smrg interned symbol is always returned. 525dfecf96Smrg|# 535dfecf96Smrg 545dfecf96Smrg(defun compare-test (test expect function arguments 555dfecf96Smrg &aux result (error t) unused error-value) 565dfecf96Smrg (multiple-value-setq 575dfecf96Smrg (unused error-value) 585dfecf96Smrg (ignore-errors 595dfecf96Smrg (setq result (apply function arguments)) 605dfecf96Smrg (setq error nil) 615dfecf96Smrg ) 625dfecf96Smrg ) 635dfecf96Smrg (if error 645dfecf96Smrg (format t "ERROR: (~S~{ ~S~}) => ~S~%" function arguments error-value) 655dfecf96Smrg (or (funcall test result expect) 665dfecf96Smrg (format t "(~S~{ ~S~}) => should be ~S not ~S~%" 675dfecf96Smrg function arguments expect result 685dfecf96Smrg ) 695dfecf96Smrg ) 705dfecf96Smrg ) 715dfecf96Smrg) 725dfecf96Smrg 735dfecf96Smrg(defun compare-eval (test expect form 745dfecf96Smrg &aux result (error t) unused error-value) 755dfecf96Smrg (multiple-value-setq 765dfecf96Smrg (unused error-value) 775dfecf96Smrg (ignore-errors 785dfecf96Smrg (setq result (eval form)) 795dfecf96Smrg (setq error nil) 805dfecf96Smrg ) 815dfecf96Smrg ) 825dfecf96Smrg (if error 835dfecf96Smrg (format t "ERROR: ~S => ~S~%" form error-value) 845dfecf96Smrg (or (funcall test result expect) 855dfecf96Smrg (format t "~S => should be ~S not ~S~%" 865dfecf96Smrg form expect result 875dfecf96Smrg ) 885dfecf96Smrg ) 895dfecf96Smrg ) 905dfecf96Smrg) 915dfecf96Smrg 925dfecf96Smrg(defun error-test (function &rest arguments &aux result (error t)) 935dfecf96Smrg (ignore-errors 945dfecf96Smrg (setq result (apply function arguments)) 955dfecf96Smrg (setq error nil) 965dfecf96Smrg ) 975dfecf96Smrg (or error 985dfecf96Smrg (format t "ERROR: no error for (~S~{ ~S~}), result was ~S~%" 995dfecf96Smrg function arguments result) 1005dfecf96Smrg ) 1015dfecf96Smrg) 1025dfecf96Smrg 1035dfecf96Smrg(defun error-eval (form &aux result (error t)) 1045dfecf96Smrg (ignore-errors 1055dfecf96Smrg (setq result (eval form)) 1065dfecf96Smrg (setq error nil) 1075dfecf96Smrg ) 1085dfecf96Smrg (or error 1095dfecf96Smrg (format t "ERROR: no error for ~S, result was ~S~%" form result) 1105dfecf96Smrg ) 1115dfecf96Smrg) 1125dfecf96Smrg 1135dfecf96Smrg(defun eq-test (expect function &rest arguments) 1145dfecf96Smrg (compare-test #'eq expect function arguments)) 1155dfecf96Smrg 1165dfecf96Smrg(defun eql-test (expect function &rest arguments) 1175dfecf96Smrg (compare-test #'eql expect function arguments)) 1185dfecf96Smrg 1195dfecf96Smrg(defun equal-test (expect function &rest arguments) 1205dfecf96Smrg (compare-test #'equal expect function arguments)) 1215dfecf96Smrg 1225dfecf96Smrg(defun equalp-test (expect function &rest arguments) 1235dfecf96Smrg (compare-test #'equalp expect function arguments)) 1245dfecf96Smrg 1255dfecf96Smrg 1265dfecf96Smrg(defun eq-eval (expect form) 1275dfecf96Smrg (compare-eval #'eq expect form)) 1285dfecf96Smrg 1295dfecf96Smrg(defun eql-eval (expect form) 1305dfecf96Smrg (compare-eval #'eql expect form)) 1315dfecf96Smrg 1325dfecf96Smrg(defun equal-eval (expect form) 1335dfecf96Smrg (compare-eval #'equal expect form)) 1345dfecf96Smrg 1355dfecf96Smrg(defun equalp-eval (expect form) 1365dfecf96Smrg (compare-eval #'equalp expect form)) 1375dfecf96Smrg 1385dfecf96Smrg;; clisp treats strings loaded from a file as constants 1395dfecf96Smrg(defun xseq (sequence) 1405dfecf96Smrg #+clisp (if *load-pathname* (copy-seq sequence) sequence) 1415dfecf96Smrg #-clisp sequence 1425dfecf96Smrg) 1435dfecf96Smrg 1445dfecf96Smrg;; apply - function 1455dfecf96Smrg(equal-test '((+ 2 3) . 4) #'apply 'cons '((+ 2 3) 4)) 1465dfecf96Smrg(eql-test -1 #'apply #'- '(1 2)) 1475dfecf96Smrg(eql-test 7 #'apply #'max 3 5 '(2 7 3)) 1485dfecf96Smrg(error-test #'apply #'+ 1) 1495dfecf96Smrg(error-test #'apply #'+ 1 2) 1505dfecf96Smrg(error-test #'apply #'+ 1 . 2) 1515dfecf96Smrg(error-test #'apply #'+ 1 2 3) 1525dfecf96Smrg(error-test #'apply #'+ 1 2 . 3) 1535dfecf96Smrg(eql-test 6 #'apply #'+ 1 2 3 ()) 1545dfecf96Smrg 1555dfecf96Smrg;; eq - function 1565dfecf96Smrg(eq-eval t '(let* ((a #\a) (b a)) (eq a b))) 1575dfecf96Smrg(eq-test t #'eq 'a 'a) 1585dfecf96Smrg(eq-test nil #'eq 'a 'b) 1595dfecf96Smrg(eq-eval t '(eq #1=1 #1#)) 1605dfecf96Smrg(eq-test nil #'eq "abc" "abc") 1615dfecf96Smrg(setq a '('x #c(1 2) #\z)) 1625dfecf96Smrg(eq-test nil #'eq a (copy-seq a)) 1635dfecf96Smrg 1645dfecf96Smrg;; eql - function 1655dfecf96Smrg(eq-test t #'eql 1 1) 1665dfecf96Smrg(eq-test t #'eql 1.3d0 1.3d0) 1675dfecf96Smrg(eq-test nil #'eql 1 1d0) 1685dfecf96Smrg(eq-test t #'eql #c(1 -5) #c(1 -5)) 1695dfecf96Smrg(eq-test t #'eql 'a 'a) 1705dfecf96Smrg(eq-test nil #'eql :a 'a) 1715dfecf96Smrg(eq-test t #'eql #c(5d0 0) 5d0) 1725dfecf96Smrg(eq-test nil #'eql #c(5d0 0d0) 5d0) 1735dfecf96Smrg(eq-test nil #'eql "abc" "abc") 1745dfecf96Smrg(equal-eval '(1 5/6 #p"test" #\#) '(setq a '(1 5/6 #p"test" #\#))) 1755dfecf96Smrg(eq-test nil #'eql a (copy-seq a)) 1765dfecf96Smrg 1775dfecf96Smrg(setf 1785dfecf96Smrg hash0 (make-hash-table) 1795dfecf96Smrg hash1 (make-hash-table) 1805dfecf96Smrg (gethash 1 hash0) 2 1815dfecf96Smrg (gethash 1 hash1) 2 1825dfecf96Smrg (gethash :foo hash0) :bar 1835dfecf96Smrg (gethash :foo hash1) :bar 1845dfecf96Smrg) 1855dfecf96Smrg(defstruct test a b c) 1865dfecf96Smrg(setq 1875dfecf96Smrg struc0 (make-test :a 1 :b 2 :c #\c) 1885dfecf96Smrg struc1 (make-test :a 1 :b 2 :c #\c) 1895dfecf96Smrg) 1905dfecf96Smrg 1915dfecf96Smrg;; equal - function 1925dfecf96Smrg(eq-test t #'equal "abc" "abc") 1935dfecf96Smrg(eq-test t #'equal 1 1) 1945dfecf96Smrg(eq-test t #'equal #c(1 2) #c(1 2)) 1955dfecf96Smrg(eq-test nil #'equal #c(1 2) #c(1 2d0)) 1965dfecf96Smrg(eq-test t #'equal #\A #\A) 1975dfecf96Smrg(eq-test nil #'equal #\A #\a) 1985dfecf96Smrg(eq-test nil #'equal "abc" "Abc") 1995dfecf96Smrg(equal-eval '(1 2 3/5 #\a) '(setq a '(1 2 3/5 #\a))) 2005dfecf96Smrg(eq-test t #'equal a (copy-seq a)) 2015dfecf96Smrg(eq-test nil #'equal hash0 hash1) 2025dfecf96Smrg(eq-test nil #'equal struc0 struc1) 2035dfecf96Smrg(eq-test nil #'equal #(1 2 3 4) #(1 2 3 4)) 2045dfecf96Smrg 2055dfecf96Smrg;; equalp - function 2065dfecf96Smrg(eq-test t #'equalp hash0 hash1) 2075dfecf96Smrg(setf 2085dfecf96Smrg (gethash 2 hash0) "FoObAr" 2095dfecf96Smrg (gethash 2 hash1) "fOoBaR" 2105dfecf96Smrg) 2115dfecf96Smrg(eq-test t #'equalp hash0 hash1) 2125dfecf96Smrg(setf 2135dfecf96Smrg (gethash 3 hash0) 3 2145dfecf96Smrg (gethash 3d0 hash1) 3 2155dfecf96Smrg) 2165dfecf96Smrg(eq-test nil #'equalp hash0 hash1) 2175dfecf96Smrg(eq-test t #'equalp struc0 struc1) 2185dfecf96Smrg(setf 2195dfecf96Smrg (test-a struc0) #\a 2205dfecf96Smrg (test-a struc1) #\A 2215dfecf96Smrg) 2225dfecf96Smrg(eq-test t #'equalp struc0 struc1) 2235dfecf96Smrg(setf 2245dfecf96Smrg (test-b struc0) 'test 2255dfecf96Smrg (test-b struc1) :test 2265dfecf96Smrg) 2275dfecf96Smrg(eq-test nil #'equalp struc0 struc1) 2285dfecf96Smrg(eq-test t #'equalp #c(1/2 1d0) #c(0.5d0 1)) 2295dfecf96Smrg(eq-test t #'equalp 1 1d0) 2305dfecf96Smrg(eq-test t #'equalp #(1 2 3 4) #(1 2 3 4)) 2315dfecf96Smrg(eq-test t #'equalp #(1 #\a 3 4d0) #(1 #\A 3 4)) 2325dfecf96Smrg 2335dfecf96Smrg;; acons - function 2345dfecf96Smrg(equal-test '((1 . "one")) #'acons 1 "one" nil) 2355dfecf96Smrg(equal-test '((2 . "two") (1 . "one")) #'acons 2 "two" '((1 . "one"))) 2365dfecf96Smrg 2375dfecf96Smrg;; adjoin - function 2385dfecf96Smrg(equal-test '(nil) #'adjoin nil nil) 2395dfecf96Smrg(equal-test '(a) #'adjoin 'a nil) 2405dfecf96Smrg(equal-test '(1 2 3) #'adjoin 1 '(1 2 3)) 2415dfecf96Smrg(equal-test '(1 2 3) #'adjoin 2 '(1 2 3)) 2425dfecf96Smrg(equal-test '((1) (1) (2) (3)) #'adjoin '(1) '((1) (2) (3))) 2435dfecf96Smrg(equal-test '((1) (2) (3)) #'adjoin '(1) '((1) (2) (3)) :key #'car) 2445dfecf96Smrg(error-test #'adjoin nil 1) 2455dfecf96Smrg 2465dfecf96Smrg;; alpha-char-p - function 2475dfecf96Smrg(eq-test t #'alpha-char-p #\a) 2485dfecf96Smrg(eq-test nil #'alpha-char-p #\5) 2495dfecf96Smrg(error-test #'alpha-char-p 'a) 2505dfecf96Smrg 2515dfecf96Smrg;; alphanumericp - function 2525dfecf96Smrg(eq-test t #'alphanumericp #\Z) 2535dfecf96Smrg(eq-test t #'alphanumericp #\8) 2545dfecf96Smrg(eq-test nil #'alphanumericp #\#) 2555dfecf96Smrg 2565dfecf96Smrg;; and - macro 2575dfecf96Smrg(eql-eval 1 '(setq temp1 1 temp2 1 temp3 1)) 2585dfecf96Smrg(eql-eval 2 '(and (incf temp1) (incf temp2) (incf temp3))) 2595dfecf96Smrg(eq-eval t '(and (eql 2 temp1) (eql 2 temp2) (eql 2 temp3))) 2605dfecf96Smrg(eql-eval 1 '(decf temp3)) 2615dfecf96Smrg(eq-eval nil '(and (decf temp1) (decf temp2) (eq temp3 'nil) (decf temp3))) 2625dfecf96Smrg(eq-eval t '(and (eql temp1 temp2) (eql temp2 temp3))) 2635dfecf96Smrg(eq-eval t '(and)) 2645dfecf96Smrg(equal-eval '(1 2 3) '(multiple-value-list (and (values 'a) (values 1 2 3)))) 2655dfecf96Smrg(equal-eval nil '(and (values) t)) 2665dfecf96Smrg 2675dfecf96Smrg;; append - function 2685dfecf96Smrg(equal-test '(a b c d e f g) #'append '(a b c) '(d e f) '() '(g)) 2695dfecf96Smrg(equal-test '(a b c . d) #'append '(a b c) 'd) 2705dfecf96Smrg(eq-test nil #'append) 2715dfecf96Smrg(eql-test 'a #'append nil 'a) 2725dfecf96Smrg(error-test #'append 1 2) 2735dfecf96Smrg 2745dfecf96Smrg;; assoc - function 2755dfecf96Smrg(equal-test '(1 . "one") #'assoc 1 '((2 . "two") (1 . "one"))) 2765dfecf96Smrg(equal-test '(2 . "two") #'assoc 2 '((1 . "one") (2 . "two"))) 2775dfecf96Smrg(eq-test nil #'assoc 1 nil) 2785dfecf96Smrg(equal-test '(2 . "two") #'assoc-if #'evenp '((1 . "one") (2 . "two"))) 2795dfecf96Smrg(equal-test '(3 . "three") #'assoc-if-not #'(lambda(x) (< x 3)) 2805dfecf96Smrg '((1 . "one") (2 . "two") (3 . "three"))) 2815dfecf96Smrg(equal-test '("two" . 2) #'assoc #\o '(("one" . 1) ("two" . 2) ("three" . 3)) 2825dfecf96Smrg :key #'(lambda (x) (char x 2))) 2835dfecf96Smrg(equal-test '(a . b) #'assoc 'a '((x . a) (y . b) (a . b) (a . c))) 2845dfecf96Smrg 2855dfecf96Smrg;; atom - function 2865dfecf96Smrg(eq-test t #'atom 1) 2875dfecf96Smrg(eq-test t #'atom '()) 2885dfecf96Smrg(eq-test nil #'atom '(1)) 2895dfecf96Smrg(eq-test t #'atom 'a) 2905dfecf96Smrg 2915dfecf96Smrg;; block - special operator 2925dfecf96Smrg(eq-eval nil '(block empty)) 2935dfecf96Smrg(eql-eval 2 '(let ((x 1)) 2945dfecf96Smrg (block stop (setq x 2) (return-from stop) (setq x 3)) x)) 2955dfecf96Smrg(eql-eval 2 '(block twin (block twin (return-from twin 1)) 2)) 2965dfecf96Smrg 2975dfecf96Smrg;; both-case-p - function 2985dfecf96Smrg(eq-test t #'both-case-p #\a) 2995dfecf96Smrg(eq-test nil #'both-case-p #\1) 3005dfecf96Smrg 3015dfecf96Smrg;; boundp - function 3025dfecf96Smrg(eql-eval 1 '(setq x 1)) 3035dfecf96Smrg(eq-test t #'boundp 'x) 3045dfecf96Smrg(makunbound 'x) 3055dfecf96Smrg(eq-test nil #'boundp 'x) 3065dfecf96Smrg(eq-eval nil '(let ((x 1)) (boundp 'x))) 3075dfecf96Smrg(error-test #'boundp 1) 3085dfecf96Smrg 3095dfecf96Smrg;; butlast, nbutlast - function 3105dfecf96Smrg(setq x '(1 2 3 4 5 6 7 8 9)) 3115dfecf96Smrg(equal-test '(1 2 3 4 5 6 7 8) #'butlast x) 3125dfecf96Smrg(equal-eval '(1 2 3 4 5 6 7 8 9) 'x) 3135dfecf96Smrg(eq-eval nil '(nbutlast x 9)) 3145dfecf96Smrg(equal-test '(1) #'nbutlast x 8) 3155dfecf96Smrg(equal-eval '(1) 'x) 3165dfecf96Smrg(eq-test nil #'butlast nil) 3175dfecf96Smrg(eq-test nil #'nbutlast '()) 3185dfecf96Smrg(error-test #'butlast 1 2) 3195dfecf96Smrg(error-test #'butlast -1 '(1 2)) 3205dfecf96Smrg 3215dfecf96Smrg;; car, cdr, caar ... - function 3225dfecf96Smrg(eql-test 1 #'car '(1 2)) 3235dfecf96Smrg(eql-test 2 #'cdr '(1 . 2)) 3245dfecf96Smrg(eql-test 1 #'caar '((1 2))) 3255dfecf96Smrg(eql-test 2 #'cadr '(1 2)) 3265dfecf96Smrg(eql-test 2 #'cdar '((1 . 2))) 3275dfecf96Smrg(eql-test 3 #'cddr '(1 2 . 3)) 3285dfecf96Smrg(eql-test 1 #'caaar '(((1 2)))) 3295dfecf96Smrg(eql-test 2 #'caadr '(1 (2 3))) 3305dfecf96Smrg(eql-test 2 #'cadar '((1 2) 2 3)) 3315dfecf96Smrg(eql-test 3 #'caddr '(1 2 3 4)) 3325dfecf96Smrg(eql-test 2 #'cdaar '(((1 . 2)) 3)) 3335dfecf96Smrg(eql-test 3 #'cdadr '(1 (2 . 3) 4)) 3345dfecf96Smrg(eql-test 3 #'cddar '((1 2 . 3) 3)) 3355dfecf96Smrg(eql-test 4 #'cdddr '(1 2 3 . 4)) 3365dfecf96Smrg(eql-test 1 #'caaaar '((((1 2))))) 3375dfecf96Smrg(eql-test 2 #'caaadr '(1 ((2)))) 3385dfecf96Smrg(eql-test 2 #'caadar '((1 (2)) 3)) 3395dfecf96Smrg(eql-test 3 #'caaddr '(1 2 (3 4))) 3405dfecf96Smrg(eql-test 2 #'cadaar '(((1 2)) 3)) 3415dfecf96Smrg(eql-test 3 #'cadadr '(1 (2 3) 4)) 3425dfecf96Smrg(eql-test 3 #'caddar '((1 2 3) 4)) 3435dfecf96Smrg(eql-test 4 #'cadddr '(1 2 3 4 5)) 3445dfecf96Smrg(eql-test 2 #'cdaaar '((((1 . 2))) 3)) 3455dfecf96Smrg(eql-test 3 #'cdaadr '(1 ((2 . 3)) 4)) 3465dfecf96Smrg(eql-test 3 #'cdadar '((1 (2 . 3)) 4)) 3475dfecf96Smrg(eql-test 4 #'cdaddr '(1 2 (3 . 4) 5)) 3485dfecf96Smrg(eql-test 3 #'cddaar '(((1 2 . 3)) 4)) 3495dfecf96Smrg(eql-test 4 #'cddadr '(1 (2 3 . 4) 5)) 3505dfecf96Smrg(eql-test 4 #'cdddar '((1 2 3 . 4) 5)) 3515dfecf96Smrg(eql-test 5 #'cddddr '(1 2 3 4 . 5)) 3525dfecf96Smrg 3535dfecf96Smrg;; first ... tenth, rest - function 3545dfecf96Smrg(eql-test 2 #'rest '(1 . 2)) 3555dfecf96Smrg(eql-test 1 #'first '(1 2)) 3565dfecf96Smrg(eql-test 2 #'second '(1 2 3)) 3575dfecf96Smrg(eql-test 2 #'second '(1 2 3)) 3585dfecf96Smrg(eql-test 3 #'third '(1 2 3 4)) 3595dfecf96Smrg(eql-test 4 #'fourth '(1 2 3 4 5)) 3605dfecf96Smrg(eql-test 5 #'fifth '(1 2 3 4 5 6)) 3615dfecf96Smrg(eql-test 6 #'sixth '(1 2 3 4 5 6 7)) 3625dfecf96Smrg(eql-test 7 #'seventh '(1 2 3 4 5 6 7 8)) 3635dfecf96Smrg(eql-test 8 #'eighth '(1 2 3 4 5 6 7 8 9)) 3645dfecf96Smrg(eql-test 9 #'ninth '(1 2 3 4 5 6 7 8 9 10)) 3655dfecf96Smrg(eql-test 10 #'tenth '(1 2 3 4 5 6 7 8 9 10 11)) 3665dfecf96Smrg(error-test #'car 1) 3675dfecf96Smrg(error-test #'car #c(1 2)) 3685dfecf96Smrg(error-test #'car #(1 2)) 3695dfecf96Smrg 3705dfecf96Smrg;; case - macro 3715dfecf96Smrg(eql-eval t '(let ((a 1)) (case a ((4 5 6) nil) ((3 2 1) t) (otherwise :error)))) 3725dfecf96Smrg(eql-eval t '(let ((a 1)) (case a ((3 2) nil) (1 t) (t :error)))) 3735dfecf96Smrg(error-eval '(let ((a 1)) (case a (2 :error) (t nil) (otherwise t)))) 3745dfecf96Smrg(error-eval '(let ((a 1)) (case a (2 :error) (otherwise t) (t nil)))) 3755dfecf96Smrg 3765dfecf96Smrg;; catch - special operator 3775dfecf96Smrg(eql-eval 3 '(catch 'dummy-tag 1 2 (throw 'dummy-tag 3) 4)) 3785dfecf96Smrg(eql-eval 4 '(catch 'dummy-tag 1 2 3 4)) 3795dfecf96Smrg(eq-eval 'throw-back '(defun throw-back (tag) (throw tag t))) 3805dfecf96Smrg(eq-eval t '(catch 'dummy-tag (throw-back 'dummy-tag) 2)) 3815dfecf96Smrg 3825dfecf96Smrg;; char - function 3835dfecf96Smrg(eql-test #\a #'char "abc" 0) 3845dfecf96Smrg(eql-test #\b #'char "abc" 1) 3855dfecf96Smrg(error-test #'char "abc" 3) 3865dfecf96Smrg 3875dfecf96Smrg;; char-* - function 3885dfecf96Smrg(eq-test nil #'alpha-char-p #\3) 3895dfecf96Smrg(eq-test t #'alpha-char-p #\y) 3905dfecf96Smrg(eql-test #\a #'char-downcase #\a) 3915dfecf96Smrg(eql-test #\a #'char-downcase #\a) 3925dfecf96Smrg(eql-test #\1 #'char-downcase #\1) 3935dfecf96Smrg(error-test #'char-downcase 1) 3945dfecf96Smrg(eql-test #\A #'char-upcase #\a) 3955dfecf96Smrg(eql-test #\A #'char-upcase #\A) 3965dfecf96Smrg(eql-test #\1 #'char-upcase #\1) 3975dfecf96Smrg(error-test #'char-upcase 1) 3985dfecf96Smrg(eq-test t #'lower-case-p #\a) 3995dfecf96Smrg(eq-test nil #'lower-case-p #\A) 4005dfecf96Smrg(eq-test t #'upper-case-p #\W) 4015dfecf96Smrg(eq-test nil #'upper-case-p #\w) 4025dfecf96Smrg(eq-test t #'both-case-p #\x) 4035dfecf96Smrg(eq-test nil #'both-case-p #\%) 4045dfecf96Smrg(eq-test t #'char= #\d #\d) 4055dfecf96Smrg(eq-test t #'char-equal #\d #\d) 4065dfecf96Smrg(eq-test nil #'char= #\A #\a) 4075dfecf96Smrg(eq-test t #'char-equal #\A #\a) 4085dfecf96Smrg(eq-test nil #'char= #\d #\x) 4095dfecf96Smrg(eq-test nil #'char-equal #\d #\x) 4105dfecf96Smrg(eq-test nil #'char= #\d #\D) 4115dfecf96Smrg(eq-test t #'char-equal #\d #\D) 4125dfecf96Smrg(eq-test nil #'char/= #\d #\d) 4135dfecf96Smrg(eq-test nil #'char-not-equal #\d #\d) 4145dfecf96Smrg(eq-test nil #'char/= #\d #\d) 4155dfecf96Smrg(eq-test nil #'char-not-equal #\d #\d) 4165dfecf96Smrg(eq-test t #'char/= #\d #\x) 4175dfecf96Smrg(eq-test t #'char-not-equal #\d #\x) 4185dfecf96Smrg(eq-test t #'char/= #\d #\D) 4195dfecf96Smrg(eq-test nil #'char-not-equal #\d #\D) 4205dfecf96Smrg(eq-test t #'char= #\d #\d #\d #\d) 4215dfecf96Smrg(eq-test t #'char-equal #\d #\d #\d #\d) 4225dfecf96Smrg(eq-test nil #'char= #\d #\D #\d #\d) 4235dfecf96Smrg(eq-test t #'char-equal #\d #\D #\d #\d) 4245dfecf96Smrg(eq-test nil #'char/= #\d #\d #\d #\d) 4255dfecf96Smrg(eq-test nil #'char-not-equal #\d #\d #\d #\d) 4265dfecf96Smrg(eq-test nil #'char/= #\d #\d #\D #\d) 4275dfecf96Smrg(eq-test nil #'char-not-equal #\d #\d #\D #\d) 4285dfecf96Smrg(eq-test nil #'char= #\d #\d #\x #\d) 4295dfecf96Smrg(eq-test nil #'char-equal #\d #\d #\x #\d) 4305dfecf96Smrg(eq-test nil #'char/= #\d #\d #\x #\d) 4315dfecf96Smrg(eq-test nil #'char-not-equal #\d #\d #\x #\d) 4325dfecf96Smrg(eq-test nil #'char= #\d #\y #\x #\c) 4335dfecf96Smrg(eq-test nil #'char-equal #\d #\y #\x #\c) 4345dfecf96Smrg(eq-test t #'char/= #\d #\y #\x #\c) 4355dfecf96Smrg(eq-test t #'char-not-equal #\d #\y #\x #\c) 4365dfecf96Smrg(eq-test nil #'char= #\d #\c #\d) 4375dfecf96Smrg(eq-test nil #'char-equal #\d #\c #\d) 4385dfecf96Smrg(eq-test nil #'char/= #\d #\c #\d) 4395dfecf96Smrg(eq-test nil #'char-not-equal #\d #\c #\d) 4405dfecf96Smrg(eq-test t #'char< #\d #\x) 4415dfecf96Smrg(eq-test t #'char-lessp #\d #\x) 4425dfecf96Smrg(eq-test t #'char-lessp #\d #\X) 4435dfecf96Smrg(eq-test t #'char-lessp #\D #\x) 4445dfecf96Smrg(eq-test t #'char-lessp #\D #\X) 4455dfecf96Smrg(eq-test t #'char<= #\d #\x) 4465dfecf96Smrg(eq-test t #'char-not-greaterp #\d #\x) 4475dfecf96Smrg(eq-test t #'char-not-greaterp #\d #\X) 4485dfecf96Smrg(eq-test t #'char-not-greaterp #\D #\x) 4495dfecf96Smrg(eq-test t #'char-not-greaterp #\D #\X) 4505dfecf96Smrg(eq-test nil #'char< #\d #\d) 4515dfecf96Smrg(eq-test nil #'char-lessp #\d #\d) 4525dfecf96Smrg(eq-test nil #'char-lessp #\d #\D) 4535dfecf96Smrg(eq-test nil #'char-lessp #\D #\d) 4545dfecf96Smrg(eq-test nil #'char-lessp #\D #\D) 4555dfecf96Smrg(eq-test t #'char<= #\d #\d) 4565dfecf96Smrg(eq-test t #'char-not-greaterp #\d #\d) 4575dfecf96Smrg(eq-test t #'char-not-greaterp #\d #\D) 4585dfecf96Smrg(eq-test t #'char-not-greaterp #\D #\d) 4595dfecf96Smrg(eq-test t #'char-not-greaterp #\D #\D) 4605dfecf96Smrg(eq-test t #'char< #\a #\e #\y #\z) 4615dfecf96Smrg(eq-test t #'char-lessp #\a #\e #\y #\z) 4625dfecf96Smrg(eq-test t #'char-lessp #\a #\e #\y #\Z) 4635dfecf96Smrg(eq-test t #'char-lessp #\a #\E #\y #\z) 4645dfecf96Smrg(eq-test t #'char-lessp #\A #\e #\y #\Z) 4655dfecf96Smrg(eq-test t #'char<= #\a #\e #\y #\z) 4665dfecf96Smrg(eq-test t #'char-not-greaterp #\a #\e #\y #\z) 4675dfecf96Smrg(eq-test t #'char-not-greaterp #\a #\e #\y #\Z) 4685dfecf96Smrg(eq-test t #'char-not-greaterp #\A #\e #\y #\z) 4695dfecf96Smrg(eq-test nil #'char< #\a #\e #\e #\y) 4705dfecf96Smrg(eq-test nil #'char-lessp #\a #\e #\e #\y) 4715dfecf96Smrg(eq-test nil #'char-lessp #\a #\e #\E #\y) 4725dfecf96Smrg(eq-test nil #'char-lessp #\A #\e #\E #\y) 4735dfecf96Smrg(eq-test t #'char<= #\a #\e #\e #\y) 4745dfecf96Smrg(eq-test t #'char-not-greaterp #\a #\e #\e #\y) 4755dfecf96Smrg(eq-test t #'char-not-greaterp #\a #\E #\e #\y) 4765dfecf96Smrg(eq-test t #'char> #\e #\d) 4775dfecf96Smrg(eq-test t #'char-greaterp #\e #\d) 4785dfecf96Smrg(eq-test t #'char-greaterp #\e #\D) 4795dfecf96Smrg(eq-test t #'char-greaterp #\E #\d) 4805dfecf96Smrg(eq-test t #'char-greaterp #\E #\D) 4815dfecf96Smrg(eq-test t #'char>= #\e #\d) 4825dfecf96Smrg(eq-test t #'char-not-lessp #\e #\d) 4835dfecf96Smrg(eq-test t #'char-not-lessp #\e #\D) 4845dfecf96Smrg(eq-test t #'char-not-lessp #\E #\d) 4855dfecf96Smrg(eq-test t #'char-not-lessp #\E #\D) 4865dfecf96Smrg(eq-test t #'char> #\d #\c #\b #\a) 4875dfecf96Smrg(eq-test t #'char-greaterp #\d #\c #\b #\a) 4885dfecf96Smrg(eq-test t #'char-greaterp #\d #\c #\b #\A) 4895dfecf96Smrg(eq-test t #'char-greaterp #\d #\c #\B #\a) 4905dfecf96Smrg(eq-test t #'char-greaterp #\d #\C #\b #\a) 4915dfecf96Smrg(eq-test t #'char-greaterp #\D #\C #\b #\a) 4925dfecf96Smrg(eq-test t #'char>= #\d #\c #\b #\a) 4935dfecf96Smrg(eq-test t #'char-not-lessp #\d #\c #\b #\a) 4945dfecf96Smrg(eq-test t #'char-not-lessp #\d #\c #\b #\A) 4955dfecf96Smrg(eq-test t #'char-not-lessp #\D #\c #\b #\a) 4965dfecf96Smrg(eq-test t #'char-not-lessp #\d #\C #\B #\a) 4975dfecf96Smrg(eq-test nil #'char> #\d #\d #\c #\a) 4985dfecf96Smrg(eq-test nil #'char-greaterp #\d #\d #\c #\a) 4995dfecf96Smrg(eq-test nil #'char-greaterp #\d #\d #\c #\A) 5005dfecf96Smrg(eq-test nil #'char-greaterp #\d #\D #\c #\a) 5015dfecf96Smrg(eq-test nil #'char-greaterp #\d #\D #\C #\a) 5025dfecf96Smrg(eq-test t #'char>= #\d #\d #\c #\a) 5035dfecf96Smrg(eq-test t #'char-not-lessp #\d #\d #\c #\a) 5045dfecf96Smrg(eq-test t #'char-not-lessp #\d #\D #\c #\a) 5055dfecf96Smrg(eq-test t #'char-not-lessp #\D #\d #\c #\a) 5065dfecf96Smrg(eq-test t #'char-not-lessp #\D #\D #\c #\A) 5075dfecf96Smrg(eq-test nil #'char> #\e #\d #\b #\c #\a) 5085dfecf96Smrg(eq-test nil #'char-greaterp #\e #\d #\b #\c #\a) 5095dfecf96Smrg(eq-test nil #'char-greaterp #\E #\d #\b #\c #\a) 5105dfecf96Smrg(eq-test nil #'char-greaterp #\e #\D #\b #\c #\a) 5115dfecf96Smrg(eq-test nil #'char-greaterp #\E #\d #\B #\c #\A) 5125dfecf96Smrg(eq-test nil #'char>= #\e #\d #\b #\c #\a) 5135dfecf96Smrg(eq-test nil #'char-not-lessp #\e #\d #\b #\c #\a) 5145dfecf96Smrg(eq-test nil #'char-not-lessp #\e #\d #\b #\c #\A) 5155dfecf96Smrg(eq-test nil #'char-not-lessp #\E #\d #\B #\c #\a) 5165dfecf96Smrg 5175dfecf96Smrg;; char-code - function 5185dfecf96Smrg;; XXX assumes ASCII 5195dfecf96Smrg(eql-test 49 #'char-code #\1) 5205dfecf96Smrg(eql-test 90 #'char-code #\Z) 5215dfecf96Smrg(eql-test 127 #'char-code #\Delete) 5225dfecf96Smrg(eql-test 27 #'char-code #\Escape) 5235dfecf96Smrg(eql-test 13 #'char-code #\Return) 5245dfecf96Smrg(eql-test 0 #'char-code #\Null) 5255dfecf96Smrg(eql-test 10 #'char-code #\Newline) 5265dfecf96Smrg(error-test #'char-code 65) 5275dfecf96Smrg 5285dfecf96Smrg;; character - function 5295dfecf96Smrg(eql-test #\a #'character #\a) 5305dfecf96Smrg(eql-test #\a #'character "a") 5315dfecf96Smrg(eql-test #\A #'character 'a) 5325dfecf96Smrg 5335dfecf96Smrg;; XXX assumes ASCII, and should be allowed to fail? 5345dfecf96Smrg(eql-test #\A #'character 65) 5355dfecf96Smrg 5365dfecf96Smrg(error-test #'character 1/2) 5375dfecf96Smrg(error-test #'character "abc") 5385dfecf96Smrg(error-test #'character :test) 5395dfecf96Smrg(eq-test #\T #'character t) 5405dfecf96Smrg(error-test #'character nil) 5415dfecf96Smrg 5425dfecf96Smrg;; characterp - function 5435dfecf96Smrg(eq-test t #'characterp #\a) 5445dfecf96Smrg(eq-test nil #'characterp 1) 5455dfecf96Smrg(eq-test nil #'characterp 1/2) 5465dfecf96Smrg(eq-test nil #'characterp 'a) 5475dfecf96Smrg(eq-test nil #'characterp '`a) 5485dfecf96Smrg 5495dfecf96Smrg 5505dfecf96Smrg 5515dfecf96Smrg 5525dfecf96Smrg;; TODO coerce 5535dfecf96Smrg 5545dfecf96Smrg 5555dfecf96Smrg 5565dfecf96Smrg 5575dfecf96Smrg;; cond - macro 5585dfecf96Smrg(eql-eval 2 '(let ((a 1)) (cond ((= a 2) 1) ((= a 1) 2) ((= a 0) 1) (t nil)))) 5595dfecf96Smrg(eql-eval nil '(let ((a 1)) (cond ((= a 2) 1) (t nil) ((= a 1) 2) ((= a 0) 1)))) 5605dfecf96Smrg 5615dfecf96Smrg;; consp - function (predicate) 5625dfecf96Smrg(eq-test t #'consp '(1 2)) 5635dfecf96Smrg(eq-test t #'consp '(1 . 2)) 5645dfecf96Smrg(eq-test nil #'consp nil) 5655dfecf96Smrg(eq-test nil #'consp 1) 5665dfecf96Smrg 5675dfecf96Smrg;; constantp - function (predicate) 5685dfecf96Smrg(eq-test t #'constantp 1) 5695dfecf96Smrg(eq-test t #'constantp #\x) 5705dfecf96Smrg(eq-test t #'constantp :test) 5715dfecf96Smrg(eq-test nil #'constantp 'test) 5725dfecf96Smrg(eq-test t #'constantp ''1) 5735dfecf96Smrg(eq-test t #'constantp '(quote 1)) 5745dfecf96Smrg(eq-test t #'constantp "string") 5755dfecf96Smrg(eq-test t #'constantp #c(1 2)) 5765dfecf96Smrg(eq-test t #'constantp #(1 2)) 5775dfecf96Smrg(eq-test nil #'constantp #p"test") 5785dfecf96Smrg(eq-test nil #'constantp '(1 2)) 5795dfecf96Smrg(eq-test nil #'constantp (make-hash-table)) 5805dfecf96Smrg(eq-test nil #'constantp *package*) 5815dfecf96Smrg(eq-test nil #'constantp *standard-input*) 5825dfecf96Smrg 5835dfecf96Smrg;; copy-list, copy-alist and copy-tree - function 5845dfecf96Smrg(equal-test '(1 2) #'copy-list '(1 2)) 5855dfecf96Smrg(equal-test '(1 . 2) #'copy-list '(1 . 2)) 5865dfecf96Smrg(eq-test nil #'copy-list nil) 5875dfecf96Smrg(error-test #'copy-list 1) 5885dfecf96Smrg(equal-eval '(1 (2 3)) '(setq x '(1 (2 3)))) 5895dfecf96Smrg(equal-eval x '(setq y (copy-list x))) 5905dfecf96Smrg(equal-test '("one" (2 3)) #'rplaca x "one") 5915dfecf96Smrg(eql-test 1 #'car y) 5925dfecf96Smrg(equal-test '("two" 3) #'rplaca (cadr x) "two") 5935dfecf96Smrg(eq-test (caadr x) #'caadr y) 5945dfecf96Smrg(equal-eval '(1 (2 3) 4) '(setq a '(1 (2 3) 4) b (copy-list a))) 5955dfecf96Smrg(eq-eval t '(eq (cadr a) (cadr b))) 5965dfecf96Smrg(eq-eval t '(eq (car a) (car b))) 5975dfecf96Smrg(setq a '(1 (2 3) 4) b (copy-alist a)) 5985dfecf96Smrg(eq-eval nil '(eq (cadr a) (cadr b))) 5995dfecf96Smrg(eq-eval t '(eq (car a) (car b))) 6005dfecf96Smrg(eq-test nil #'copy-alist nil) 6015dfecf96Smrg(eq-test nil #'copy-list nil) 6025dfecf96Smrg(error-test #'copy-list 1) 6035dfecf96Smrg(setq a '(1 (2 (3)))) 6045dfecf96Smrg(setq as-list (copy-list a)) 6055dfecf96Smrg(setq as-alist (copy-alist a)) 6065dfecf96Smrg(setq as-tree (copy-tree a)) 6075dfecf96Smrg(eq-eval t '(eq (cadadr a) (cadadr as-list))) 6085dfecf96Smrg(eq-eval t '(eq (cadadr a) (cadadr as-alist))) 6095dfecf96Smrg(eq-eval nil '(eq (cadadr a) (cadadr as-tree))) 6105dfecf96Smrg 6115dfecf96Smrg;; decf - macro 6125dfecf96Smrg(setq n 2) 6135dfecf96Smrg(eql-eval 1 '(decf n)) 6145dfecf96Smrg(eql-eval 1 'n) 6155dfecf96Smrg(setq n -2147483648) 6165dfecf96Smrg(eql-eval -2147483649 '(decf n)) 6175dfecf96Smrg(eql-eval -2147483649 'n) 6185dfecf96Smrg(setq n 0) 6195dfecf96Smrg(eql-eval -0.5d0 '(decf n 0.5d0)) 6205dfecf96Smrg(eql-eval -0.5d0 'n) 6215dfecf96Smrg(setq n 1) 6225dfecf96Smrg(eql-eval 1/2 '(decf n 1/2)) 6235dfecf96Smrg(eql-eval 1/2 'n) 6245dfecf96Smrg 6255dfecf96Smrg;; delete and remove - function 6265dfecf96Smrg(setq a '(1 3 4 5 9) b a) 6275dfecf96Smrg(equal-test '(1 3 5 9) #'remove 4 a) 6285dfecf96Smrg(eq-eval t '(eq a b)) 6295dfecf96Smrg(setq a (delete 4 a)) 6305dfecf96Smrg(equal-eval '(1 3 5 9) 'a) 6315dfecf96Smrg(setq a '(1 2 4 1 3 4 5) b a) 6325dfecf96Smrg(equal-test '(1 2 1 3 5) #'remove 4 a) 6335dfecf96Smrg(eq-eval t '(eq a b)) 6345dfecf96Smrg(equal-test '(1 2 1 3 4 5) #'remove 4 a :count 1) 6355dfecf96Smrg(eq-eval t '(eq a b)) 6365dfecf96Smrg(equal-test '(1 2 4 1 3 5) #'remove 4 a :count 1 :from-end t) 6375dfecf96Smrg(eq-eval t '(eq a b)) 6385dfecf96Smrg(equal-test '(4 3 4 5) #'remove 3 a :test #'>) 6395dfecf96Smrg(eq-eval t '(eq a b)) 6405dfecf96Smrg(setq a (delete 4 '(1 2 4 1 3 4 5))) 6415dfecf96Smrg(equal-eval '(1 2 1 3 5) 'a) 6425dfecf96Smrg(setq a (delete 4 '(1 2 4 1 3 4 5) :count 1)) 6435dfecf96Smrg(equal-eval '(1 2 1 3 4 5) 'a) 6445dfecf96Smrg(setq a (delete 4 '(1 2 4 1 3 4 5) :count 1 :from-end t)) 6455dfecf96Smrg(equal-eval '(1 2 4 1 3 5) 'a) 6465dfecf96Smrg(equal-test "abc" #'delete-if #'digit-char-p "a1b2c3") 6475dfecf96Smrg(equal-test "123" #'delete-if-not #'digit-char-p "a1b2c3") 6485dfecf96Smrg(eq-test nil #'delete 1 nil) 6495dfecf96Smrg(eq-test nil #'remove 1 nil) 6505dfecf96Smrg(setq a '(1 2 3 4 :test 5 6 7 8) b a) 6515dfecf96Smrg(equal-test '(1 2 :test 7 8) #'remove-if #'numberp a :start 2 :end 7) 6525dfecf96Smrg(eq-eval t '(eq a b)) 6535dfecf96Smrg(setq a (delete-if #'numberp a :start 2 :end 7)) 6545dfecf96Smrg(equal-eval '(1 2 :test 7 8) 'a) 6555dfecf96Smrg 6565dfecf96Smrg;; digit-char - function 6575dfecf96Smrg(eql-test #\0 #'digit-char 0) 6585dfecf96Smrg(eql-test #\A #'digit-char 10 11) 6595dfecf96Smrg(eq-test nil #'digit-char 10 10) 6605dfecf96Smrg(eql-test 35 #'digit-char-p #\z 36) 6615dfecf96Smrg(error-test #'digit-char #\a) 6625dfecf96Smrg(error-test #'digit-char-p 1/2) 6635dfecf96Smrg 6645dfecf96Smrg 6655dfecf96Smrg 6665dfecf96Smrg;; TODO directory (known to have problems with parameters like "../*/../*/") 6675dfecf96Smrg 6685dfecf96Smrg 6695dfecf96Smrg 6705dfecf96Smrg;; elt - function 6715dfecf96Smrg(eql-test #\a #'elt "xabc" 1) 6725dfecf96Smrg(eql-test 3 #'elt '(0 1 2 3) 3) 6735dfecf96Smrg(error-test #'elt nil 0) 6745dfecf96Smrg 6755dfecf96Smrg;; endp - function 6765dfecf96Smrg(eql-test t #'endp nil) 6775dfecf96Smrg(error-test #'endp t) 6785dfecf96Smrg(eql-test nil #'endp '(1 . 2)) 6795dfecf96Smrg(error-test #'endp #(1 2)) 6805dfecf96Smrg 6815dfecf96Smrg;; every - function 6825dfecf96Smrg(eql-test t #'every 'not-used ()) 6835dfecf96Smrg(eql-test t #'every #'characterp "abc") 6845dfecf96Smrg(eql-test nil #'every #'< '(1 2 3) '(4 5 6) #(7 8 -1)) 6855dfecf96Smrg(eql-test t #'every #'< '(1 2 3) '(4 5 6) #(7 8)) 6865dfecf96Smrg 6875dfecf96Smrg;; fboundp and fmakunbound - function 6885dfecf96Smrg(eq-test t #'fboundp 'car) 6895dfecf96Smrg(eq-eval 'test '(defun test ())) 6905dfecf96Smrg(eq-test t #'fboundp 'test) 6915dfecf96Smrg(eq-test 'test #'fmakunbound 'test) 6925dfecf96Smrg(eq-test nil #'fboundp 'test) 6935dfecf96Smrg(eq-eval 'test '(defmacro test (x) x)) 6945dfecf96Smrg(eq-test t #'fboundp 'test) 6955dfecf96Smrg(eq-test 'test #'fmakunbound 'test) 6965dfecf96Smrg 6975dfecf96Smrg;; fill - function 6985dfecf96Smrg(setq x (list 1 2 3 4)) 6995dfecf96Smrg(equal-test '((4 4 4 4) (4 4 4 4) (4 4 4 4) (4 4 4 4)) #'fill x '(4 4 4 4)) 7005dfecf96Smrg(eq-eval t '(eq (car x) (cadr x))) 7015dfecf96Smrg(equalp-test '#(a z z d e) #'fill '#(a b c d e) 'z :start 1 :end 3) 7025dfecf96Smrg(equal-test "012ee" #'fill (xseq "01234") #\e :start 3) 7035dfecf96Smrg(error-test #'fill 1 #\a) 7045dfecf96Smrg 7055dfecf96Smrg;; find - function 7065dfecf96Smrg(eql-test #\Space #'find #\d "here are some letters that can be looked at" :test #'char>) 7075dfecf96Smrg(eql-test 3 #'find-if #'oddp '(1 2 3 4 5) :end 3 :from-end t) 7085dfecf96Smrg(eq-test nil #'find-if-not #'complexp '#(3.5 2 #C(1.0 0.0) #C(0.0 1.0)) :start 2) 7095dfecf96Smrg(eq-test nil #'find 1 "abc") 7105dfecf96Smrg(error-test #'find 1 #c(1 2)) 7115dfecf96Smrg 7125dfecf96Smrg;; find-symbol - function 7135dfecf96Smrg(equal-eval '(nil nil) 7145dfecf96Smrg '(multiple-value-list (find-symbol "NEVER-BEFORE-USED"))) 7155dfecf96Smrg(equal-eval '(nil nil) 7165dfecf96Smrg '(multiple-value-list (find-symbol "NEVER-BEFORE-USED"))) 7175dfecf96Smrg(setq test (multiple-value-list (intern "NEVER-BEFORE-USED"))) 7185dfecf96Smrg(equal-eval test '(read-from-string "(never-before-used nil)")) 7195dfecf96Smrg(equal-eval '(never-before-used :internal) 7205dfecf96Smrg '(multiple-value-list (intern "NEVER-BEFORE-USED"))) 7215dfecf96Smrg(equal-eval '(never-before-used :internal) 7225dfecf96Smrg '(multiple-value-list (find-symbol "NEVER-BEFORE-USED"))) 7235dfecf96Smrg(equal-eval '(nil nil) 7245dfecf96Smrg '(multiple-value-list (find-symbol "never-before-used"))) 7255dfecf96Smrg(equal-eval '(car :inherited) 7265dfecf96Smrg '(multiple-value-list (find-symbol "CAR" 'common-lisp-user))) 7275dfecf96Smrg(equal-eval '(car :external) 7285dfecf96Smrg '(multiple-value-list (find-symbol "CAR" 'common-lisp))) 7295dfecf96Smrg;; XXX these will generate wrong results, NIL is not really a symbol 7305dfecf96Smrg;; currently in the interpreter 7315dfecf96Smrg(equal-eval '(nil :inherited) 7325dfecf96Smrg '(multiple-value-list (find-symbol "NIL" 'common-lisp-user))) 7335dfecf96Smrg(equal-eval '(nil :external) 7345dfecf96Smrg '(multiple-value-list (find-symbol "NIL" 'common-lisp))) 7355dfecf96Smrg(setq test (multiple-value-list 7365dfecf96Smrg (find-symbol "NIL" (prog1 (make-package "JUST-TESTING" :use '()) 7375dfecf96Smrg (intern "NIL" "JUST-TESTING"))))) 7385dfecf96Smrg(equal-eval (read-from-string "(just-testing::nil :internal)") 'test) 7395dfecf96Smrg(eq-eval t '(export 'just-testing::nil 'just-testing)) 7405dfecf96Smrg(equal-eval '(just-testing:nil :external) 7415dfecf96Smrg '(multiple-value-list (find-symbol "NIL" 'just-testing))) 7425dfecf96Smrg 7435dfecf96Smrg#+xedit (equal-eval '(nil nil) 7445dfecf96Smrg '(multiple-value-list (find-symbol "NIL" "KEYWORD"))) 7455dfecf96Smrg#| 7465dfecf96Smrg;; optional result of previous form: 7475dfecf96Smrg(equal-eval '(:nil :external) 7485dfecf96Smrg '(multiple-value-list (find-symbol "NIL" "KEYWORD"))) 7495dfecf96Smrg|# 7505dfecf96Smrg 7515dfecf96Smrg 7525dfecf96Smrg 7535dfecf96Smrg;; funcall - function 7545dfecf96Smrg(eql-test 6 #'funcall #'+ 1 2 3) 7555dfecf96Smrg(eql-test 1 #'funcall #'car '(1 2 3)) 7565dfecf96Smrg(equal-test '(1 2 3) #'funcall #'list 1 2 3) 7575dfecf96Smrg 7585dfecf96Smrg 7595dfecf96Smrg 7605dfecf96Smrg;; TODO properly implement ``function'' 7615dfecf96Smrg 7625dfecf96Smrg 7635dfecf96Smrg 7645dfecf96Smrg;; functionp - function (predicate) 7655dfecf96Smrg(eq-test nil #'functionp 'append) 7665dfecf96Smrg(eq-test t #'functionp #'append) 7675dfecf96Smrg(eq-test nil #'functionp '(lambda (x) (* x x))) 7685dfecf96Smrg(eq-test t #'functionp #'(lambda (x) (* x x))) 7695dfecf96Smrg(eq-test t #'functionp (symbol-function 'append)) 7705dfecf96Smrg(eq-test nil #'functionp 1) 7715dfecf96Smrg(eq-test nil #'functionp nil) 7725dfecf96Smrg 7735dfecf96Smrg;; gensym - function 7745dfecf96Smrg(setq sym1 (gensym)) 7755dfecf96Smrg(eq-test nil #'symbol-package sym1) 7765dfecf96Smrg(setq sym1 (gensym 100)) 7775dfecf96Smrg(setq sym2 (gensym 100)) 7785dfecf96Smrg(eq-test nil #'eq sym1 sym2) 7795dfecf96Smrg(eq-test nil #'equalp (gensym) (gensym)) 7805dfecf96Smrg 7815dfecf96Smrg;; get - accessor 7825dfecf96Smrg(defun make-person (first-name last-name) 7835dfecf96Smrg (let ((person (gensym "PERSON"))) 7845dfecf96Smrg (setf (get person 'first-name) first-name) 7855dfecf96Smrg (setf (get person 'last-name) last-name) 7865dfecf96Smrg person)) 7875dfecf96Smrg(eq-eval '*john* '(defvar *john* (make-person "John" "Dow"))) 7885dfecf96Smrg(eq-eval '*sally* '(defvar *sally* (make-person "Sally" "Jones"))) 7895dfecf96Smrg(equal-eval "John" '(get *john* 'first-name)) 7905dfecf96Smrg(equal-eval "Jones" '(get *sally* 'last-name)) 7915dfecf96Smrg(defun marry (man woman married-name) 7925dfecf96Smrg (setf (get man 'wife) woman) 7935dfecf96Smrg (setf (get woman 'husband) man) 7945dfecf96Smrg (setf (get man 'last-name) married-name) 7955dfecf96Smrg (setf (get woman 'last-name) married-name) 7965dfecf96Smrg married-name) 7975dfecf96Smrg(equal-eval "Dow-Jones" '(marry *john* *sally* "Dow-Jones")) 7985dfecf96Smrg(equal-eval "Dow-Jones" '(get *john* 'last-name)) 7995dfecf96Smrg(equal-eval "Sally" '(get (get *john* 'wife) 'first-name)) 8005dfecf96Smrg(equal-eval `(wife ,*sally* last-name "Dow-Jones" first-name "John") 8015dfecf96Smrg '(symbol-plist *john*)) 8025dfecf96Smrg(eq-eval 'age 8035dfecf96Smrg '(defmacro age (person &optional (default ''thirty-something)) 8045dfecf96Smrg `(get ,person 'age ,default))) 8055dfecf96Smrg(eq-eval 'thirty-something '(age *john*)) 8065dfecf96Smrg(eql-eval 20 '(age *john* 20)) 8075dfecf96Smrg(eql-eval 25 '(setf (age *john*) 25)) 8085dfecf96Smrg(eql-eval 25 '(age *john*)) 8095dfecf96Smrg(eql-eval 25 '(age *john* 20)) 8105dfecf96Smrg 8115dfecf96Smrg;; graphic-char-p - function 8125dfecf96Smrg(eq-test t #'graphic-char-p #\a) 8135dfecf96Smrg(eq-test t #'graphic-char-p #\Space) 8145dfecf96Smrg(eq-test nil #'graphic-char-p #\Newline) 8155dfecf96Smrg(eq-test nil #'graphic-char-p #\Tab) 8165dfecf96Smrg(eq-test nil #'graphic-char-p #\Rubout) 8175dfecf96Smrg 8185dfecf96Smrg;; if - special operator 8195dfecf96Smrg(eq-eval nil '(if nil t)) 8205dfecf96Smrg(eq-eval nil '(if t nil t)) 8215dfecf96Smrg(eq-eval nil '(if nil t nil)) 8225dfecf96Smrg(eq-eval nil '(if nil t (if nil (if nil t) nil))) 8235dfecf96Smrg 8245dfecf96Smrg;; incf - macro 8255dfecf96Smrg(setq n 1) 8265dfecf96Smrg(eql-eval 2 '(incf n)) 8275dfecf96Smrg(eql-eval 2 'n) 8285dfecf96Smrg(setq n 2147483647) 8295dfecf96Smrg(eql-eval 2147483648 '(incf n)) 8305dfecf96Smrg(eql-eval 2147483648 'n) 8315dfecf96Smrg(setq n 0) 8325dfecf96Smrg(eql-eval 0.5d0 '(incf n 0.5d0)) 8335dfecf96Smrg(eql-eval 0.5d0 'n) 8345dfecf96Smrg(setq n 1) 8355dfecf96Smrg(eql-eval 3/2 '(incf n 1/2)) 8365dfecf96Smrg(eql-eval 3/2 'n) 8375dfecf96Smrg 8385dfecf96Smrg;; intersection - function 8395dfecf96Smrg(setq list1 (list 1 1 2 3 4 'a 'b 'c "A" "B" "C" "d") 8405dfecf96Smrg list2 (list 1 4 5 'b 'c 'd "a" "B" "c" "D")) 8415dfecf96Smrg(equal-test '(1 1 4 b c) #'intersection list1 list2) 8425dfecf96Smrg(equal-test '(1 1 4 b c "B") #'intersection list1 list2 :test 'equal) 8435dfecf96Smrg(equal-test '(1 1 4 b c "A" "B" "C" "d") 8445dfecf96Smrg #'intersection list1 list2 :test #'equalp) 8455dfecf96Smrg(setq list1 (nintersection list1 list2)) 8465dfecf96Smrg(equal-eval '(1 1 4 b c) 'list1) 8475dfecf96Smrg(setq list1 (copy-list '((1 . 2) (2 . 3) (3 . 4) (4 . 5)))) 8485dfecf96Smrg(setq list2 (copy-list '((1 . 3) (2 . 4) (3 . 6) (4 . 8)))) 8495dfecf96Smrg(equal-test '((2 . 3) (3 . 4)) #'nintersection list1 list2 :key #'cdr) 8505dfecf96Smrg 8515dfecf96Smrg;; keywordp - function (predicate) 8525dfecf96Smrg(eq-test t #'keywordp :test) 8535dfecf96Smrg(eq-test nil #'keywordp 'test) 8545dfecf96Smrg(eq-test nil #'keywordp '#:test) 8555dfecf96Smrg(eq-test nil #'keywordp 1) 8565dfecf96Smrg(eq-test nil #'keywordp #'keywordp) 8575dfecf96Smrg(eq-test nil #'keywordp nil) 8585dfecf96Smrg 8595dfecf96Smrg;; last - function 8605dfecf96Smrg(equal-test '(3) #'last '(1 2 3)) 8615dfecf96Smrg(equal-test '(2 . 3) #'last '(1 2 . 3)) 8625dfecf96Smrg(eq-test nil #'last nil) 8635dfecf96Smrg(eql-test () #'last '(1 2 3) 0) 8645dfecf96Smrg(setq a '(1 . 2)) 8655dfecf96Smrg(eql-test 2 #'last a 0) 8665dfecf96Smrg(eq-test a #'last a 1) 8675dfecf96Smrg(eq-test a #'last a 2) 8685dfecf96Smrg(eq-test t #'last t) 8695dfecf96Smrg(equal-test #c(1 2) #'last #c(1 2)) 8705dfecf96Smrg(equalp-test #(1 2 3) #'last #(1 2 3)) 8715dfecf96Smrg 8725dfecf96Smrg;; length - function 8735dfecf96Smrg(eql-test 3 #'length "abc") 8745dfecf96Smrg(eql-test 0 #'length nil) 8755dfecf96Smrg(eql-test 1 #'length '(1 . 2)) 8765dfecf96Smrg(eql-test 2 #'length #(1 2)) 8775dfecf96Smrg(error-test #'length #c(1 2)) 8785dfecf96Smrg(error-test #'length t) 8795dfecf96Smrg 8805dfecf96Smrg;; let - special operator 8815dfecf96Smrg(eql-eval 2 '(setq a 1 b 2)) 8825dfecf96Smrg(eql-eval 2 '(let ((a 2)) a)) 8835dfecf96Smrg(eql-eval 1 'a) 8845dfecf96Smrg(eql-eval 1 '(let ((a 3) (b a)) b)) 8855dfecf96Smrg(eql-eval 2 'b) 8865dfecf96Smrg 8875dfecf96Smrg;; let* - special operator 8885dfecf96Smrg(setq a 1 b 2) 8895dfecf96Smrg(eql-eval 2 '(let* ((a 2)) a)) 8905dfecf96Smrg(eql-eval 1 'a) 8915dfecf96Smrg(eql-eval 3 '(let* ((a 3) (b a)) b)) 8925dfecf96Smrg(eql-eval 2 'b) 8935dfecf96Smrg 8945dfecf96Smrg;; list - function 8955dfecf96Smrg(equal-test '(1) #'list 1) 8965dfecf96Smrg(equal-test '(3 4 a b 4) #'list 3 4 'a (car '(b . c)) (+ 6 -2)) 8975dfecf96Smrg(eq-test nil #'list) 8985dfecf96Smrg 8995dfecf96Smrg;; list-length - function 9005dfecf96Smrg(eql-test 4 #'list-length '(a b c d)) 9015dfecf96Smrg(eql-test 3 #'list-length '(a (b c) d)) 9025dfecf96Smrg(eql-test 0 #'list-length '()) 9035dfecf96Smrg(eql-test 0 #'list-length nil) 9045dfecf96Smrg(defun circular-list (&rest elements) 9055dfecf96Smrg (let ((cycle (copy-list elements))) 9065dfecf96Smrg (nconc cycle cycle))) 9075dfecf96Smrg(eq-test nil #'list-length (circular-list 'a 'b)) 9085dfecf96Smrg(eq-test nil #'list-length (circular-list 'a)) 9095dfecf96Smrg(eql-test 0 #'list-length (circular-list)) 9105dfecf96Smrg 9115dfecf96Smrg;; list* - function 9125dfecf96Smrg(eql-test 1 #'list* 1) 9135dfecf96Smrg(equal-test '(a b c . d) #'list* 'a 'b 'c 'd) 9145dfecf96Smrg(error-test #'list*) 9155dfecf96Smrg(setq a '(1 2)) 9165dfecf96Smrg(eq-test a #'list* a) 9175dfecf96Smrg 9185dfecf96Smrg;; listp - function (predicate) 9195dfecf96Smrg(eq-test t #'listp nil) 9205dfecf96Smrg(eq-test t #'listp '(1 . 2)) 9215dfecf96Smrg(eq-test nil #'listp t) 9225dfecf96Smrg(eq-test nil #'listp #'listp) 9235dfecf96Smrg(eq-test nil #'listp #(1 2)) 9245dfecf96Smrg(eq-test nil #'listp #c(1 2)) 9255dfecf96Smrg 9265dfecf96Smrg;; lower-case-p - function 9275dfecf96Smrg(eq-test t #'lower-case-p #\a) 9285dfecf96Smrg(eq-test nil #'lower-case-p #\1) 9295dfecf96Smrg(eq-test nil #'lower-case-p #\Newline) 9305dfecf96Smrg(error-test #'lower-case-p 1) 9315dfecf96Smrg 9325dfecf96Smrg 9335dfecf96Smrg 9345dfecf96Smrg;; TODO make-array (will be rewritten) 9355dfecf96Smrg 9365dfecf96Smrg 9375dfecf96Smrg 9385dfecf96Smrg;; make-list - function 9395dfecf96Smrg(equal-test '(nil nil nil) #'make-list 3) 9405dfecf96Smrg(equal-test '((1 2) (1 2)) #'make-list 2 :initial-element '(1 2)) 9415dfecf96Smrg(eq-test nil #'make-list 0) 9425dfecf96Smrg(eq-test nil #'make-list 0 :initial-element 1) 9435dfecf96Smrg 9445dfecf96Smrg;; make-package - function 9455dfecf96Smrg(setq pack1 (make-package "PACKAGE-1" :nicknames '("PACK-1" "PACK1"))) 9465dfecf96Smrg(setq pack2 (make-package "PACKAGE-2" :nicknames '("PACK-2" "PACK2") :use '("PACK1"))) 9475dfecf96Smrg(equal-test (list pack2) #'package-used-by-list pack1) 9485dfecf96Smrg(equal-test (list pack1) #'package-use-list pack2) 9495dfecf96Smrg(eq-test pack1 #'symbol-package 'pack1::test) 9505dfecf96Smrg(eq-test pack2 #'symbol-package 'pack2::test) 9515dfecf96Smrg 9525dfecf96Smrg;; make-string - function 9535dfecf96Smrg(equal-test "55555" #'make-string 5 :initial-element #\5) 9545dfecf96Smrg(equal-test "" #'make-string 0) 9555dfecf96Smrg(error-test #'make-string 10 :initial-element t) 9565dfecf96Smrg(error-test #'make-string 10 :initial-element nil) 9575dfecf96Smrg(error-test #'make-string 10 :initial-element 1) 9585dfecf96Smrg(eql-test 10 #'length (make-string 10)) 9595dfecf96Smrg 9605dfecf96Smrg;; make-symbol - function 9615dfecf96Smrg(setq a "TEST") 9625dfecf96Smrg;; This will fail 9635dfecf96Smrg(eq-test nil #'eq (make-symbol a) (make-symbol a)) 9645dfecf96Smrg(equal-test a #'symbol-name (make-symbol a)) 9655dfecf96Smrg(setq temp-string "temp") 9665dfecf96Smrg(setq temp-symbol (make-symbol temp-string)) 9675dfecf96Smrg(equal-test temp-string #'symbol-name temp-symbol) 9685dfecf96Smrg(equal-eval '(nil nil) '(multiple-value-list (find-symbol temp-string))) 9695dfecf96Smrg 9705dfecf96Smrg;; makunbound - function 9715dfecf96Smrg(eq-eval 1 '(setf (symbol-value 'a) 1)) 9725dfecf96Smrg(eq-test t #'boundp 'a) 9735dfecf96Smrg(eql-eval 1 'a) 9745dfecf96Smrg(eq-test 'a #'makunbound 'a) 9755dfecf96Smrg(eq-test nil #'boundp 'a) 9765dfecf96Smrg(error-test #'makunbound 1) 9775dfecf96Smrg 9785dfecf96Smrg;; mapc - function 9795dfecf96Smrg(setq dummy nil) 9805dfecf96Smrg(equal-test '(1 2 3 4) 9815dfecf96Smrg #'mapc #'(lambda (&rest x) (setq dummy (append dummy x))) 9825dfecf96Smrg '(1 2 3 4) 9835dfecf96Smrg '(a b c d e) 9845dfecf96Smrg '(x y z)) 9855dfecf96Smrg(equal-eval '(1 a x 2 b y 3 c z) 'dummy) 9865dfecf96Smrg 9875dfecf96Smrg;; mapcan - function 9885dfecf96Smrg(equal-test '(d 4 e 5) 9895dfecf96Smrg #'mapcan #'(lambda (x y) (if (null x) nil (list x y))) 9905dfecf96Smrg '(nil nil nil d e) 9915dfecf96Smrg '(1 2 3 4 5 6)) 9925dfecf96Smrg(equal-test '(1 3 4 5) 9935dfecf96Smrg #'mapcan #'(lambda (x) (and (numberp x) (list x))) 9945dfecf96Smrg '(a 1 b c 3 4 d 5)) 9955dfecf96Smrg 9965dfecf96Smrg;; mapcar - function 9975dfecf96Smrg(equal-test '(1 2 3) #'mapcar #'car '((1 a) (2 b) (3 c))) 9985dfecf96Smrg(equal-test '(3 4 2 5 6) #'mapcar #'abs '(3 -4 2 -5 -6)) 9995dfecf96Smrg(equal-test '((a . 1) (b . 2) (c . 3)) #'mapcar #'cons '(a b c) '(1 2 3)) 10005dfecf96Smrg(equal-test '((1 3 5)) #'mapcar #'list* '(1 2) '(3 4) '((5))) 10015dfecf96Smrg(equal-test '((1 3 5) (2 4 6)) #'mapcar #'list* '(1 2) '(3 4) '((5) (6))) 10025dfecf96Smrg 10035dfecf96Smrg;; mapcon - function 10045dfecf96Smrg(equal-test '(1 a 2 b (3) c) #'mapcon #'car '((1 a) (2 b) ((3) c))) 10055dfecf96Smrg(equal-test '((1 2 3 4) (2 3 4) (3 4) (4)) #'mapcon #'list '(1 2 3 4)) 10065dfecf96Smrg 10075dfecf96Smrg;; mapl - function 10085dfecf96Smrg(setq dummy nil) 10095dfecf96Smrg(equal-test '(1 2 3 4) #'mapl #'(lambda (x) (push x dummy)) '(1 2 3 4)) 10105dfecf96Smrg(equal-eval '((4) (3 4) (2 3 4) (1 2 3 4)) 'dummy) 10115dfecf96Smrg 10125dfecf96Smrg;; maplist - function 10135dfecf96Smrg(equal-test '((1 2 3 4 1 2 1 2 3) (2 3 4 2 2 3)) 10145dfecf96Smrg #'maplist #'append '(1 2 3 4) '(1 2) '(1 2 3)) 10155dfecf96Smrg(equal-test '((foo a b c d) (foo b c d) (foo c d) (foo d)) 10165dfecf96Smrg #'maplist #'(lambda (x) (cons 'foo x)) '(a b c d)) 10175dfecf96Smrg(equal-test '(0 0 1 0 1 1 1) 10185dfecf96Smrg #'maplist #'(lambda (x) (if (member (car x) (cdr x)) 0 1)) '(a b a c d b c)) 10195dfecf96Smrg 10205dfecf96Smrg;; member - function 10215dfecf96Smrg(setq a '(1 2 3)) 10225dfecf96Smrg(eq-test (cdr a) #'member 2 a) 10235dfecf96Smrg(setq a '((1 . 2) (3 . 4))) 10245dfecf96Smrg(eq-test (cdr a) #'member 2 a :test-not #'= :key #'cdr) 10255dfecf96Smrg(eq-test nil #'member 'e '(a b c d)) 10265dfecf96Smrg(eq-test nil #'member 1 nil) 10275dfecf96Smrg(error-test #'member 2 '(1 . 2)) 10285dfecf96Smrg(setq a '(a b nil c d)) 10295dfecf96Smrg(eq-test (cddr a) #'member-if #'listp a) 10305dfecf96Smrg(setq a '(a #\Space 5/3 foo)) 10315dfecf96Smrg(eq-test (cddr a) #'member-if #'numberp a) 10325dfecf96Smrg(setq a '(3 6 9 11 . 12)) 10335dfecf96Smrg(eq-test (cdddr a) #'member-if-not #'zerop a :key #'(lambda (x) (mod x 3))) 10345dfecf96Smrg 10355dfecf96Smrg;; multiple-value-bind - macro 10365dfecf96Smrg(equal-eval '(11 9) '(multiple-value-bind (f r) (floor 130 11) (list f r))) 10375dfecf96Smrg 10385dfecf96Smrg;; multiple-value-call - special operator 10395dfecf96Smrg(equal-eval '(1 / 2 3 / / 2 0.5) 10405dfecf96Smrg '(multiple-value-call #'list 1 '/ (values 2 3) '/ (values) '/ (floor 2.5))) 10415dfecf96Smrg(eql-eval 10 '(multiple-value-call #'+ (floor 5 3) (floor 19 4))) 10425dfecf96Smrg 10435dfecf96Smrg;; multiple-value-list - macro 10445dfecf96Smrg(equal-eval '(-1 1) '(multiple-value-list (floor -3 4))) 10455dfecf96Smrg(eql-eval nil '(multiple-value-list (values))) 10465dfecf96Smrg(equal-eval '(nil) '(multiple-value-list (values nil))) 10475dfecf96Smrg 10485dfecf96Smrg;; multiple-value-prog1 - special operator 10495dfecf96Smrg(setq temp '(1 2 3)) 10505dfecf96Smrg(equal-eval temp 10515dfecf96Smrg '(multiple-value-list 10525dfecf96Smrg (multiple-value-prog1 10535dfecf96Smrg (values-list temp) 10545dfecf96Smrg (setq temp nil) 10555dfecf96Smrg (values-list temp)))) 10565dfecf96Smrg 10575dfecf96Smrg;; multiple-value-setq - macro 10585dfecf96Smrg(eql-eval 1 '(multiple-value-setq (quotient remainder) (truncate 3.5d0 2))) 10595dfecf96Smrg(eql-eval 1 quotient) 10605dfecf96Smrg(eql-eval 1.5d0 'remainder) 10615dfecf96Smrg(eql-eval 1 '(multiple-value-setq (a b c) (values 1 2))) 10625dfecf96Smrg(eql-eval 1 'a) 10635dfecf96Smrg(eql-eval 2 'b) 10645dfecf96Smrg(eq-eval nil 'c) 10655dfecf96Smrg(eql-eval 4 '(multiple-value-setq (a b) (values 4 5 6))) 10665dfecf96Smrg(eql-eval 4 'a) 10675dfecf96Smrg(eql-eval 5 'b) 10685dfecf96Smrg(setq a 1) 10695dfecf96Smrg(eql-eval nil '(multiple-value-setq (a) (values))) 10705dfecf96Smrg(eql-eval nil 'a) 10715dfecf96Smrg 10725dfecf96Smrg;; nconc - function 10735dfecf96Smrg(eq-test nil #'nconc) 10745dfecf96Smrg(setq x '(a b c)) 10755dfecf96Smrg(setq y '(d e f)) 10765dfecf96Smrg(equal-test '(a b c d e f) #'nconc x y) 10775dfecf96Smrg(equal-eval '(a b c d e f) 'x) 10785dfecf96Smrg(eq-test y #'cdddr x) 10795dfecf96Smrg(equal-test '(1 . 2) #'nconc (list 1) 2) 10805dfecf96Smrg(error-test #'nconc 1 2 3) 10815dfecf96Smrg(equal-eval '(k l m) 10825dfecf96Smrg '(setq foo (list 'a 'b 'c 'd 'e) 10835dfecf96Smrg bar (list 'f 'g 'h 'i 'j) 10845dfecf96Smrg baz (list 'k 'l 'm))) 10855dfecf96Smrg(equal-test '(a b c d e f g h i j k l m) #'nconc foo bar baz) 10865dfecf96Smrg(equal-eval '(a b c d e f g h i j k l m) 'foo) 10875dfecf96Smrg(equal-eval (nthcdr 5 foo) 'bar) 10885dfecf96Smrg(equal-eval (nthcdr 10 foo) 'baz) 10895dfecf96Smrg(setq foo (list 'a 'b 'c 'd 'e) 10905dfecf96Smrg bar (list 'f 'g 'h 'i 'j) 10915dfecf96Smrg baz (list 'k 'l 'm)) 10925dfecf96Smrg(equal-eval '(a b c d e f g h i j k l m) '(setq foo (nconc nil foo bar nil baz))) 10935dfecf96Smrg(equal-eval '(a b c d e f g h i j k l m) 'foo) 10945dfecf96Smrg(equal-eval (nthcdr 5 foo) 'bar) 10955dfecf96Smrg(equal-eval (nthcdr 10 foo) 'baz) 10965dfecf96Smrg 10975dfecf96Smrg;; notany - function 10985dfecf96Smrg(eql-test t #'notany #'> '(1 2 3 4) '(5 6 7 8) '(9 10 11 12)) 10995dfecf96Smrg(eql-test t #'notany 'not-used ()) 11005dfecf96Smrg(eql-test nil #'notany #'characterp #(1 2 3 4 5 #\6 7 8)) 11015dfecf96Smrg 11025dfecf96Smrg;; notevery - function 11035dfecf96Smrg(eql-test nil #'notevery #'< '(1 2 3 4) '(5 6 7 8) '(9 10 11 12)) 11045dfecf96Smrg(eql-test nil #'notevery 'not-used ()) 11055dfecf96Smrg(eql-test t #'notevery #'numberp #(1 2 3 4 5 #\6 7 8)) 11065dfecf96Smrg 11075dfecf96Smrg;; nth - accessor (function) 11085dfecf96Smrg(eql-test 'foo #'nth 0 '(foo bar baz)) 11095dfecf96Smrg(eql-test 'bar #'nth 1 '(foo bar baz)) 11105dfecf96Smrg(eq-test nil #'nth 3 '(foo bar baz)) 11115dfecf96Smrg(error-test #'nth 0 #c(1 2)) 11125dfecf96Smrg(error-test #'nth 0 #(1 2)) 11135dfecf96Smrg(error-test #'nth 0 "test") 11145dfecf96Smrg 11155dfecf96Smrg;; nth-value - macro 11165dfecf96Smrg(equal-eval 'a '(nth-value 0 (values 'a 'b))) 11175dfecf96Smrg(equal-eval 'b '(nth-value 1 (values 'a 'b))) 11185dfecf96Smrg(eq-eval nil '(nth-value 2 (values 'a 'b))) 11195dfecf96Smrg(equal-eval '(3332987528 3332987528 t) 11205dfecf96Smrg '(multiple-value-list 11215dfecf96Smrg (let* ((x 83927472397238947423879243432432432) 11225dfecf96Smrg (y 32423489732) 11235dfecf96Smrg (a (nth-value 1 (floor x y))) 11245dfecf96Smrg (b (mod x y))) 11255dfecf96Smrg (values a b (= a b))))) 11265dfecf96Smrg 11275dfecf96Smrg;; nthcdr - function 11285dfecf96Smrg(eq-test nil #'nthcdr 0 '()) 11295dfecf96Smrg(eq-test nil #'nthcdr 3 '()) 11305dfecf96Smrg(equal-test '(a b c) #'nthcdr 0 '(a b c)) 11315dfecf96Smrg(equal-test '(c) #'nthcdr 2 '(a b c)) 11325dfecf96Smrg(eq-test () #'nthcdr 4 '(a b c)) 11335dfecf96Smrg(eql-test 1 #'nthcdr 1 '(0 . 1)) 11345dfecf96Smrg(error-test #'nthcdr -1 '(1 2)) 11355dfecf96Smrg(error-test #'nthcdr #\Null '(1 2)) 11365dfecf96Smrg(error-test #'nthcdr 1 t) 11375dfecf96Smrg(error-test #'nthcdr 1 #(1 2 3)) 11385dfecf96Smrg 11395dfecf96Smrg;; or - macro 11405dfecf96Smrg(eq-eval nil '(or)) 11415dfecf96Smrg(setq temp0 nil temp1 10 temp2 20 temp3 30) 11425dfecf96Smrg(eql-eval 10 '(or temp0 temp1 (setq temp2 37))) 11435dfecf96Smrg(eql-eval 20 'temp2) 11445dfecf96Smrg(eql-eval 11 '(or (incf temp1) (incf temp2) (incf temp3))) 11455dfecf96Smrg(eql-eval 11 'temp1) 11465dfecf96Smrg(eql-eval 20 temp2) 11475dfecf96Smrg(eql-eval 30 'temp3) 11485dfecf96Smrg(eql-eval 11 '(or (values) temp1)) 11495dfecf96Smrg(eql-eval 11 '(or (values temp1 temp2) temp3)) 11505dfecf96Smrg(equal-eval '(11 20) '(multiple-value-list (or temp0 (values temp1 temp2)))) 11515dfecf96Smrg(equal-eval '(20 30) 11525dfecf96Smrg '(multiple-value-list (or (values temp0 temp1) (values temp2 temp3)))) 11535dfecf96Smrg 11545dfecf96Smrg;; packagep - function (predicate) 11555dfecf96Smrg(eq-test t #'packagep *package*) 11565dfecf96Smrg(eq-test nil #'packagep 10) 11575dfecf96Smrg(eq-test t #'packagep (make-package "TEST-PACKAGE")) 11585dfecf96Smrg(eq-test nil #'packagep 'keyword) 11595dfecf96Smrg(eq-test t #'packagep (find-package 'keyword)) 11605dfecf96Smrg 11615dfecf96Smrg;; pairlis - function 11625dfecf96Smrg#+xedit ;; order of result may vary 11635dfecf96Smrg(progn 11645dfecf96Smrg (equal-test '((one . 1) (two . 2) (three . 3) (four . 19)) 11655dfecf96Smrg #'pairlis '(one two) '(1 2) '((three . 3) (four . 19))) 11665dfecf96Smrg (setq keys '(1 2 3) 11675dfecf96Smrg data '("one" "two" "three") 11685dfecf96Smrg alist '((4 . "four"))) 11695dfecf96Smrg (equal-test '((1 . "one") (2 . "two") (3 . "three")) 11705dfecf96Smrg #'pairlis keys data) 11715dfecf96Smrg (equal-test '((1 . "one") (2 . "two") (3 . "three") (4 . "four")) 11725dfecf96Smrg #'pairlis keys data alist) 11735dfecf96Smrg (equal-eval '(1 2 3) 'keys) 11745dfecf96Smrg (equal-eval '("one" "two" "three") 'data) 11755dfecf96Smrg (equal-eval '((4 . "four")) 'alist) 11765dfecf96Smrg (eq-test nil #'pairlis 1 2) 11775dfecf96Smrg (error-test #'pairlis '(1 2 3) '(4 5)) 11785dfecf96Smrg) 11795dfecf96Smrg 11805dfecf96Smrg;; pop - macro 11815dfecf96Smrg(setq stack '(a b c) test stack) 11825dfecf96Smrg(eq-eval 'a '(pop stack)) 11835dfecf96Smrg(eq-eval (cdr test) 'stack) 11845dfecf96Smrg(setq llst '((1 2 3 4)) test (car llst)) 11855dfecf96Smrg(eq-eval 1 '(pop (car llst))) 11865dfecf96Smrg(eq-eval (cdr test) '(car llst)) 11875dfecf96Smrg(error-eval '(pop 1)) 11885dfecf96Smrg(error-eval '(pop nil)) 11895dfecf96Smrg;; dotted list 11905dfecf96Smrg(setq stack (cons 1 2)) 11915dfecf96Smrg(eq-eval 1 '(pop stack)) 11925dfecf96Smrg(error-eval '(pop stack)) 11935dfecf96Smrg;; circular list 11945dfecf96Smrg(setq stack '#1=(1 . #1#) *print-circle* t) 11955dfecf96Smrg(eql-eval 1 '(pop stack)) 11965dfecf96Smrg(eql-eval 1 '(pop stack)) 11975dfecf96Smrg(eql-eval 1 '(pop (cdr stack))) 11985dfecf96Smrg 11995dfecf96Smrg;; position - function 12005dfecf96Smrg(eql-test 4 #'position #\a "baobab" :from-end t) 12015dfecf96Smrg(eql-test 2 #'position-if #'oddp '((1) (2) (3) (4)) :start 1 :key #'car) 12025dfecf96Smrg(eq-test nil #'position 595 '()) 12035dfecf96Smrg(eq-test 4 #'position-if-not #'integerp '(1 2 3 4 5.0)) 12045dfecf96Smrg(eql-test 1 #'position (char-int #\1) "0123" :key #'char-int) 12055dfecf96Smrg 12065dfecf96Smrg;; prog - macro 12075dfecf96Smrg(eq-eval nil '(prog () :error)) 12085dfecf96Smrg(eq-eval 'ok 12095dfecf96Smrg '(prog ((a 0)) 12105dfecf96Smrg l1 (if (< a 10) (go l3) (go l2)) 12115dfecf96Smrg (return 'failed) 12125dfecf96Smrg l2 (return 'ok) 12135dfecf96Smrg (return 'failed) 12145dfecf96Smrg l3 (incf a) (go l1) 12155dfecf96Smrg (return 'failed) 12165dfecf96Smrg )) 12175dfecf96Smrg(setq a 1) 12185dfecf96Smrg(eq-eval '/= '(prog ((a 2) (b a)) (return (if (= a b) '= '/=)))) 12195dfecf96Smrg 12205dfecf96Smrg;; prog* - macro 12215dfecf96Smrg(setq a 1) 12225dfecf96Smrg(eq-eval nil '(prog* () :error)) 12235dfecf96Smrg(eq-eval 'ok 12245dfecf96Smrg '(prog* ((a 0) (b 0)) 12255dfecf96Smrg l1 (if (< a 10) (go l3) (go l2)) 12265dfecf96Smrg (return 'failed) 12275dfecf96Smrg l2 (if (< b 10) (go l4) (return 'ok)) 12285dfecf96Smrg (return 'failed) 12295dfecf96Smrg l3 (incf a) (go l1) 12305dfecf96Smrg (return 'failed) 12315dfecf96Smrg l4 (incf b) (setq a 0) (go l1) 12325dfecf96Smrg (return 'failed) 12335dfecf96Smrg )) 12345dfecf96Smrg(eq-eval '= '(prog* ((a 2) (b a)) (return (if (= a b) '= '/=)))) 12355dfecf96Smrg 12365dfecf96Smrg;; prog1 - macro 12375dfecf96Smrg(setq temp 1) 12385dfecf96Smrg(eql-eval 1 '(prog1 temp (incf temp) (eql-eval 2 'temp) temp)) 12395dfecf96Smrg(eql-eval 2 'temp) 12405dfecf96Smrg(eql-eval 2 '(prog1 temp (setq temp nil) (eql-eval nil 'temp) temp)) 12415dfecf96Smrg(eq-eval nil 'temp) 12425dfecf96Smrg(eql-eval 1 '(prog1 (values 1 2 3) 4)) 12435dfecf96Smrg(setq temp (list 'a 'b 'c)) 12445dfecf96Smrg(eq-eval 'a '(prog1 (car temp) (setf (car temp) 'alpha))) 12455dfecf96Smrg(equal-eval '(alpha b c) 'temp) 12465dfecf96Smrg(equal-eval '(1) 12475dfecf96Smrg '(multiple-value-list (prog1 (values 1 2) (values 4 5)))) 12485dfecf96Smrg 12495dfecf96Smrg;; prog2 - macro 12505dfecf96Smrg(setq temp 1) 12515dfecf96Smrg(eql-eval 3 '(prog2 (incf temp) (incf temp) (incf temp))) 12525dfecf96Smrg(eql-eval 4 'temp) 12535dfecf96Smrg(eql-eval 2 '(prog2 1 (values 2 3 4) 5)) 12545dfecf96Smrg(equal-eval '(3) 12555dfecf96Smrg '(multiple-value-list (prog2 (values 1 2) (values 3 4) (values 5 6)))) 12565dfecf96Smrg 12575dfecf96Smrg;; progn - special operator 12585dfecf96Smrg(eq-eval nil '(progn)) 12595dfecf96Smrg(eql-eval 3 '(progn 1 2 3)) 12605dfecf96Smrg(equal-eval '(1 2 3) '(multiple-value-list (progn (values 1 2 3)))) 12615dfecf96Smrg(setq a 1) 12625dfecf96Smrg(eq-eval 'here '(if a (progn (setq a nil) 'here) (progn (setq a t) 'there))) 12635dfecf96Smrg(eq-eval nil 'a) 12645dfecf96Smrg 12655dfecf96Smrg;; progv - special operator 12665dfecf96Smrg(makunbound '*x*) ;; make sure it is not bound 12675dfecf96Smrg(setq *x* 1) 12685dfecf96Smrg(eql-eval 2 '(progv '(*x*) '(2) *x*)) 12695dfecf96Smrg(eql-eval 1 '*x*) 12705dfecf96Smrg(equal-eval '(3 4) 12715dfecf96Smrg '(let ((*x* 3)) (progv '(*x*) '(4) (list *x* (symbol-value '*x*))))) 12725dfecf96Smrg(makunbound '*x*) 12735dfecf96Smrg(defvar *x* 1) 12745dfecf96Smrg(equal-eval '(4 4) 12755dfecf96Smrg '(let ((*x* 3)) (progv '(*x*) '(4) (list *x* (symbol-value '*x*))))) 12765dfecf96Smrg(equal-eval '(4 4) 12775dfecf96Smrg '(multiple-value-list 12785dfecf96Smrg (let ((*x* 3)) 12795dfecf96Smrg (progv '(*x*) '(4) (values-list (list *x* (symbol-value '*x*))))))) 12805dfecf96Smrg 12815dfecf96Smrg;; push - macro 12825dfecf96Smrg(setq llst '(nil)) 12835dfecf96Smrg(equal-eval '(1) '(push 1 (car llst))) 12845dfecf96Smrg(equal-eval '((1)) 'llst) 12855dfecf96Smrg(equal-eval '(1 1) '(push 1 (car llst))) 12865dfecf96Smrg(equal-eval '((1 1)) 'llst) 12875dfecf96Smrg(setq x '(a (b c) d)) 12885dfecf96Smrg(equal-eval '(5 B C) '(push 5 (cadr x))) 12895dfecf96Smrg(equal-eval '(a (5 b c) d) 'x) 12905dfecf96Smrg 12915dfecf96Smrg;; pushnew - macro 12925dfecf96Smrg(setq x '(a (b c) d)) 12935dfecf96Smrg(equal-eval '(5 b c) '(pushnew 5 (cadr x))) 12945dfecf96Smrg(equal-eval '(a (5 b c) d) 'x) 12955dfecf96Smrg(equal-eval '(5 b c) '(pushnew 'b (cadr x))) 12965dfecf96Smrg(equal-eval '(a (5 b c) d) 'x) 12975dfecf96Smrg(setq lst '((1) (1 2) (1 2 3))) 12985dfecf96Smrg(equal-eval '((2) (1) (1 2) (1 2 3)) '(pushnew '(2) lst)) 12995dfecf96Smrg(equal-eval '((1) (2) (1) (1 2) (1 2 3)) '(pushnew '(1) lst)) 13005dfecf96Smrg(equal-eval '((1) (2) (1) (1 2) (1 2 3)) '(pushnew '(1) lst :test 'equal)) 13015dfecf96Smrg(equal-eval '((1) (2) (1) (1 2) (1 2 3)) '(pushnew '(1) lst :key #'car)) 13025dfecf96Smrg 13035dfecf96Smrg;; remove-duplicates - function 13045dfecf96Smrg(equal-test "aBcD" #'remove-duplicates "aBcDAbCd" :test #'char-equal :from-end t) 13055dfecf96Smrg(equal-test '(a c b d e) #'remove-duplicates '(a b c b d d e)) 13065dfecf96Smrg(equal-test '(a b c d e) #'remove-duplicates '(a b c b d d e) :from-end t) 13075dfecf96Smrg(equal-test '((bar #\%) (baz #\A)) 13085dfecf96Smrg #'remove-duplicates '((foo #\a) (bar #\%) (baz #\A)) 13095dfecf96Smrg :test #'char-equal :key #'cadr) 13105dfecf96Smrg(equal-test '((foo #\a) (bar #\%)) 13115dfecf96Smrg #'remove-duplicates '((foo #\a) (bar #\%) (baz #\A)) 13125dfecf96Smrg :test #'char-equal :key #'cadr :from-end t) 13135dfecf96Smrg(setq tester (list 0 1 2 3 4 5 6)) 13145dfecf96Smrg(equal-test '(0 4 5 6) #'delete-duplicates tester :key #'oddp :start 1 :end 6) 13155dfecf96Smrg 13165dfecf96Smrg;; replace - function 13175dfecf96Smrg(equal-test "abcd456hij" 13185dfecf96Smrg #'replace (copy-seq "abcdefghij") "0123456789" :start1 4 :end1 7 :start2 4) 13195dfecf96Smrg(setq lst (xseq "012345678")) 13205dfecf96Smrg(equal-test "010123456" #'replace lst lst :start1 2 :start2 0) 13215dfecf96Smrg(equal-eval "010123456" 'lst) 13225dfecf96Smrg 13235dfecf96Smrg;; rest - accessor 13245dfecf96Smrg(equal-eval '(2) '(rest '(1 2))) 13255dfecf96Smrg(eql-eval 2 '(rest '(1 . 2))) 13265dfecf96Smrg(eq-eval nil '(rest '(1))) 13275dfecf96Smrg(setq *cons* '(1 . 2)) 13285dfecf96Smrg(equal-eval "two" '(setf (rest *cons*) "two")) 13295dfecf96Smrg(equal-eval '(1 . "two") '*cons*) 13305dfecf96Smrg 13315dfecf96Smrg;; return - macro 13325dfecf96Smrg(eq-eval nil '(block nil (return) 1)) 13335dfecf96Smrg(eql-eval 1 '(block nil (return 1) 2)) 13345dfecf96Smrg(equal-eval '(1 2) '(multiple-value-list (block nil (return (values 1 2)) 3))) 13355dfecf96Smrg(eql-eval 1 '(block nil (block alpha (return 1) 2))) 13365dfecf96Smrg(eql-eval 2 '(block alpha (block nil (return 1)) 2)) 13375dfecf96Smrg(eql-eval 1 '(block nil (block nil (return 1) 2))) 13385dfecf96Smrg 13395dfecf96Smrg;; return-from - special operator 13405dfecf96Smrg(eq-eval nil '(block alpha (return-from alpha) 1)) 13415dfecf96Smrg(eql-eval 1 '(block alpha (return-from alpha 1) 2)) 13425dfecf96Smrg(equal-eval '(1 2) 13435dfecf96Smrg '(multiple-value-list (block alpha (return-from alpha (values 1 2)) 3))) 13445dfecf96Smrg(eql-eval 2 13455dfecf96Smrg '(let ((a 0)) (dotimes (i 10) (incf a) (when (oddp i) (return))) a)) 13465dfecf96Smrg(eq-eval 'temp '(defun temp (x) (if x (return-from temp ''dummy)) 44)) 13475dfecf96Smrg(eql-eval 44 '(temp nil)) 13485dfecf96Smrg(eq-eval 'dummy (temp t)) 13495dfecf96Smrg(eql-eval 2 (block nil (unwind-protect (return-from nil 1) (return-from nil 2)))) 13505dfecf96Smrg(error-eval '(funcall (block nil #'(lambda () (return-from nil))))) 13515dfecf96Smrg 13525dfecf96Smrg;; reverse - function 13535dfecf96Smrg(setq str (xseq "abc") test str) 13545dfecf96Smrg(equal-test "cba" #'reverse str) 13555dfecf96Smrg(eq-eval test 'str) 13565dfecf96Smrg(equal-eval "cba" '(setq test (nreverse str))) 13575dfecf96Smrg(equal-eval "cba" 'test) 13585dfecf96Smrg(setq l (list 1 2 3) test l) 13595dfecf96Smrg(equal-eval '(3 2 1) '(setq test (nreverse l))) 13605dfecf96Smrg(equal-eval '(3 2 1) 'test) 13615dfecf96Smrg 13625dfecf96Smrg;; rplac? - function 13635dfecf96Smrg(eql-eval '*some-list* 13645dfecf96Smrg '(defparameter *some-list* (list* 'one 'two 'three 'four))) 13655dfecf96Smrg(equal-eval '(one two three . four) '*some-list*) 13665dfecf96Smrg(equal-test '(uno two three . four) #'rplaca *some-list* 'uno) 13675dfecf96Smrg(equal-eval '(uno two three . four) '*some-list*) 13685dfecf96Smrg(equal-test '(three iv) #'rplacd (last *some-list*) (list 'iv)) 13695dfecf96Smrg(equal-eval '(uno two three iv) '*some-list*) 13705dfecf96Smrg 13715dfecf96Smrg;; search - function 13725dfecf96Smrg(eql-test 7 #'search "dog" "it's a dog's life") 13735dfecf96Smrg(eql-test 2 #'search '(0 1) '(2 4 6 1 3 5) :key #'oddp) 13745dfecf96Smrg(eql-test 8 #'search "foo" "foooobarfooooobarfo" :from-end t) 13755dfecf96Smrg(eql-test 5 13765dfecf96Smrg #'search "123" 13775dfecf96Smrg (mapcar #'(lambda (x) (+ x (char-code #\0))) 13785dfecf96Smrg '(1 2 34 3 2 1 2 3 4 3 2 1)) :from-end t 13795dfecf96Smrg :key #'(lambda (x) (if (integerp x) (code-char x) x))) 13805dfecf96Smrg(eql-test 0 #'search "abc" "abcd" :from-end t) 13815dfecf96Smrg(eql-test 3 #'search "bar" "foobar") 13825dfecf96Smrg 13835dfecf96Smrg;; set - function 13845dfecf96Smrg(eql-eval 1 '(setf (symbol-value 'n) 1)) 13855dfecf96Smrg(eql-test 2 #'set 'n 2) 13865dfecf96Smrg(eql-test 2 #'symbol-value 'n) 13875dfecf96Smrg(eql-eval 4 13885dfecf96Smrg '(let ((n 3)) 13895dfecf96Smrg (setq n (+ n 1)) 13905dfecf96Smrg (setf (symbol-value 'n) (* n 10)) 13915dfecf96Smrg (set 'n (+ (symbol-value 'n) n)) 13925dfecf96Smrg n)) 13935dfecf96Smrg(eql-eval 44 'n) 13945dfecf96Smrg(defvar *n* 2) 13955dfecf96Smrg(eql-eval 80 13965dfecf96Smrg '(let ((*n* 3)) 13975dfecf96Smrg (setq *n* (+ *n* 1)) 13985dfecf96Smrg (setf (symbol-value '*n*) (* *n* 10)) 13995dfecf96Smrg (set '*n* (+ (symbol-value '*n*) *n*)) 14005dfecf96Smrg *n*)) 14015dfecf96Smrg(eql-eval 2 '*n*) 14025dfecf96Smrg(eq-eval '*even-count* '(defvar *even-count* 0)) 14035dfecf96Smrg(eq-eval '*odd-count* '(defvar *odd-count* 0)) 14045dfecf96Smrg(eql-eval 'tally-list 14055dfecf96Smrg '(defun tally-list (list) 14065dfecf96Smrg (dolist (element list) 14075dfecf96Smrg (set (if (evenp element) '*even-count* '*odd-count*) 14085dfecf96Smrg (+ element (if (evenp element) *even-count* *odd-count*)))))) 14095dfecf96Smrg(eq-eval nil '(tally-list '(1 9 4 3 2 7))) 14105dfecf96Smrg(eql-eval 6 '*even-count*) 14115dfecf96Smrg(eql-eval 20 '*odd-count*) 14125dfecf96Smrg 14135dfecf96Smrg;; set-difference - function 14145dfecf96Smrg(setq lst1 (list "A" "b" "C" "d") lst2 (list "a" "B" "C" "d")) 14155dfecf96Smrg(equal-test '("A" "b" "C" "d") #'set-difference lst1 lst2) 14165dfecf96Smrg(equal-test '("A" "b") #'set-difference lst1 lst2 :test 'equal) 14175dfecf96Smrg(eq-test nil #'set-difference lst1 lst2 :test #'equalp) 14185dfecf96Smrg(equal-test '("A" "b") #'nset-difference lst1 lst2 :test #'string=) 14195dfecf96Smrg(setq lst1 '(("a" . "b") ("c" . "d") ("e" . "f")) 14205dfecf96Smrg lst2 '(("c" . "a") ("e" . "b") ("d" . "a"))) 14215dfecf96Smrg(equal-test '(("c" . "d") ("e" . "f")) 14225dfecf96Smrg #'nset-difference lst1 lst2 :test #'string= :key #'cdr) 14235dfecf96Smrg(equal-eval '(("c" . "a") ("e" . "b") ("d" . "a")) 'lst2) 14245dfecf96Smrg(equal-test '("banana" "lemon" "rhubarb") 14255dfecf96Smrg #'set-difference 14265dfecf96Smrg '("strawberry" "chocolate" "banana" "lemon" "pistachio" "rhubarb") 14275dfecf96Smrg '(#\c #\w) :test #'(lambda (s c) (find c s))) 14285dfecf96Smrg 14295dfecf96Smrg;; set-exclusive-or - function 14305dfecf96Smrg(setq lst1 (list 1 "a" "b") lst2 (list 1 "A" "b")) 14315dfecf96Smrg(equal-test '("a" "b" "A" "b") #'set-exclusive-or lst1 lst2) 14325dfecf96Smrg(equal-test '("a" "A") #'set-exclusive-or lst1 lst2 :test #'equal) 14335dfecf96Smrg(eq-test nil #'set-exclusive-or lst1 lst2 :test 'equalp) 14345dfecf96Smrg(equal-test '("a" "b" "A" "b") #'nset-exclusive-or lst1 lst2) 14355dfecf96Smrg(setq lst1 '(("a" . "b") ("c" . "d") ("e" . "f")) 14365dfecf96Smrg lst2 '(("c" . "a") ("e" . "b") ("d" . "a"))) 14375dfecf96Smrg(equal-test '(("c" . "d") ("e" . "f") ("c" . "a") ("d" . "a")) 14385dfecf96Smrg #'nset-exclusive-or lst1 lst2 :test #'string= :key #'cdr) 14395dfecf96Smrg 14405dfecf96Smrg;; setf - macro 14415dfecf96Smrg(setq x (cons 'a 'b) y (list 1 2 3)) 14425dfecf96Smrg(equal-eval '(1 x 3) '(setf (car x) 'x (cadr y) (car x) (cdr x) y)) 14435dfecf96Smrg(equal-eval '(x 1 x 3) 'x) 14445dfecf96Smrg(equal-eval '(1 x 3) 'y) 14455dfecf96Smrg(setq x (cons 'a 'b) y (list 1 2 3)) 14465dfecf96Smrg(eq-eval nil '(psetf (car x) 'x (cadr y) (car x) (cdr x) y)) 14475dfecf96Smrg(equal-eval '(x 1 a 3) 'x) 14485dfecf96Smrg(equal-eval '(1 a 3) 'y) 14495dfecf96Smrg(error-eval '(setf x)) 14505dfecf96Smrg(error-eval '(psetf x)) 14515dfecf96Smrg 14525dfecf96Smrg;; setq - special form 14535dfecf96Smrg(eql-eval 3 '(setq a 1 b 2 c 3)) 14545dfecf96Smrg(eql-eval 1 'a) 14555dfecf96Smrg(eql-eval 2 'b) 14565dfecf96Smrg(eql-eval 3 'c) 14575dfecf96Smrg(eql-eval 7 '(setq a (1+ b) b (1+ a) c (+ a b))) 14585dfecf96Smrg(eql-eval 3 'a) 14595dfecf96Smrg(eql-eval 4 'b) 14605dfecf96Smrg(eql-eval 7 'c) 14615dfecf96Smrg(eq-eval nil '(psetq a 1 b 2 c 3)) 14625dfecf96Smrg(eql-eval 1 'a) 14635dfecf96Smrg(eql-eval 2 'b) 14645dfecf96Smrg(eql-eval 3 'c) 14655dfecf96Smrg(equal-eval '(2 1) 14665dfecf96Smrg '(multiple-value-list (let ((a 1) (b 2)) (psetq a b b a) (values a b)))) 14675dfecf96Smrg(error-eval '(setq x)) 14685dfecf96Smrg(error-eval '(setq x 1 y)) 14695dfecf96Smrg 14705dfecf96Smrg;; some - function 14715dfecf96Smrg(eq-test t #'some #'= '(1 2 3 4 5) '(5 4 3 2 1)) 14725dfecf96Smrg 14735dfecf96Smrg;; sort - function 14745dfecf96Smrg(setq tester (copy-seq "lkjashd")) 14755dfecf96Smrg(equal-test "adhjkls" #'sort tester #'char-lessp) 14765dfecf96Smrg(setq tester (list '(1 2 3) '(4 5 6) '(7 8 9))) 14775dfecf96Smrg(equal-test '((7 8 9) (4 5 6) (1 2 3)) #'sort tester #'> :key #'car) 14785dfecf96Smrg(setq tester (list 1 2 3 4 5 6 7 8 9 0)) 14795dfecf96Smrg(equal-test '(1 3 5 7 9 2 4 6 8 0) 14805dfecf96Smrg #'stable-sort tester #'(lambda (x y) (and (oddp x) (evenp y)))) 14815dfecf96Smrg(equalp-test 14825dfecf96Smrg #((("Kathy" "Chapman") "Editorial") 14835dfecf96Smrg (("Dick" "Gabriel") "Objects") 14845dfecf96Smrg (("Gregor" "Kiczales") "Objects") 14855dfecf96Smrg (("Sandra" "Loosemore") "Compiler") 14865dfecf96Smrg (("Larry" "Masinter") "Cleanup") 14875dfecf96Smrg (("David" "Moon") "Objects") 14885dfecf96Smrg (("Kent" "Pitman") "Conditions") 14895dfecf96Smrg (("Dick" "Waters") "Iteration") 14905dfecf96Smrg (("JonL" "White") "Iteration")) 14915dfecf96Smrg #'sort (setq committee-data 14925dfecf96Smrg (vector (list (list "JonL" "White") "Iteration") 14935dfecf96Smrg (list (list "Dick" "Waters") "Iteration") 14945dfecf96Smrg (list (list "Dick" "Gabriel") "Objects") 14955dfecf96Smrg (list (list "Kent" "Pitman") "Conditions") 14965dfecf96Smrg (list (list "Gregor" "Kiczales") "Objects") 14975dfecf96Smrg (list (list "David" "Moon") "Objects") 14985dfecf96Smrg (list (list "Kathy" "Chapman") "Editorial") 14995dfecf96Smrg (list (list "Larry" "Masinter") "Cleanup") 15005dfecf96Smrg (list (list "Sandra" "Loosemore") "Compiler"))) 15015dfecf96Smrg #'string-lessp :key #'cadar) 15025dfecf96Smrg(equalp-eval 15035dfecf96Smrg #((("Larry" "Masinter") "Cleanup") 15045dfecf96Smrg (("Sandra" "Loosemore") "Compiler") 15055dfecf96Smrg (("Kent" "Pitman") "Conditions") 15065dfecf96Smrg (("Kathy" "Chapman") "Editorial") 15075dfecf96Smrg (("Dick" "Waters") "Iteration") 15085dfecf96Smrg (("JonL" "White") "Iteration") 15095dfecf96Smrg (("Dick" "Gabriel") "Objects") 15105dfecf96Smrg (("Gregor" "Kiczales") "Objects") 15115dfecf96Smrg (("David" "Moon") "Objects")) 15125dfecf96Smrg '(setq committee-data 15135dfecf96Smrg (stable-sort committee-data #'string-lessp :key #'cadr))) 15145dfecf96Smrg(error-test #'sort #c(1 2)) 15155dfecf96Smrg 15165dfecf96Smrg;; string - function 15175dfecf96Smrg(setq a "already a string") 15185dfecf96Smrg(eq-test a #'string a) 15195dfecf96Smrg(equal-test "ELM" #'string 'elm) 15205dfecf96Smrg(equal-test "c" #'string #\c) 15215dfecf96Smrg 15225dfecf96Smrg;; string-* - function 15235dfecf96Smrg(eq-test t #'string= "foo" "foo") 15245dfecf96Smrg(eq-test nil #'string= "foo" "Foo") 15255dfecf96Smrg(eq-test nil #'string= "foo" "bar") 15265dfecf96Smrg(eq-test t #'string= "together" "frog" :start1 1 :end1 3 :start2 2) 15275dfecf96Smrg(eq-test t #'string-equal "foo" "Foo") 15285dfecf96Smrg(eq-test t #'string= "abcd" "01234abcd9012" :start2 5 :end2 9) 15295dfecf96Smrg(eql-test 3 #'string< "aaaa" "aaab") 15305dfecf96Smrg(eql-test 4 #'string>= "aaaaa" "aaaa") 15315dfecf96Smrg(eql-test 5 #'string-not-greaterp "Abcde" "abcdE") 15325dfecf96Smrg(eql-test 6 #'string-lessp "012AAAA789" "01aaab6" :start1 3 :end1 7 15335dfecf96Smrg :start2 2 :end2 6) 15345dfecf96Smrg(eq-test nil #'string-not-equal "AAAA" "aaaA") 15355dfecf96Smrg(error-test #'string= #(1 2 3) '(1 2 3)) 15365dfecf96Smrg(eql-test 0 #'string< "abcd" "efg") 15375dfecf96Smrg(eql-test 1 #'string< "abcd" "afg") 15385dfecf96Smrg(eql-test 0 #'string/= "foo" "baar") 15395dfecf96Smrg(eql-test nil #'string/= "foobar" "foobar") 15405dfecf96Smrg 15415dfecf96Smrg;; string-{upcase,downcase,capitalize} - function 15425dfecf96Smrg(equal-test "ABCDE" #'string-upcase "abcde") 15435dfecf96Smrg(equal-test "aBCDe" #'string-upcase "abcde" :start 1 :end 4) 15445dfecf96Smrg(equal-test "aBCDe" #'nstring-upcase (xseq "abcde") :start 1 :end 4) 15455dfecf96Smrg(equal-test "DR. LIVINGSTON, I PRESUME?" 15465dfecf96Smrg #'string-upcase "Dr. Livingston, I presume?") 15475dfecf96Smrg(equal-test "Dr. LIVINGSTON, I Presume?" 15485dfecf96Smrg #'string-upcase "Dr. Livingston, I presume?" :start 4 :end 19) 15495dfecf96Smrg(equal-test "Dr. LIVINGSTON, I Presume?" 15505dfecf96Smrg #'nstring-upcase (xseq "Dr. Livingston, I presume?") :start 4 :end 19) 15515dfecf96Smrg(equal-test "Dr. LiVINGston, I presume?" 15525dfecf96Smrg #'string-upcase "Dr. Livingston, I presume?" :start 6 :end 10) 15535dfecf96Smrg(equal-test "Dr. LiVINGston, I presume?" 15545dfecf96Smrg #'nstring-upcase (xseq "Dr. Livingston, I presume?") :start 6 :end 10) 15555dfecf96Smrg(equal-test "dr. livingston, i presume?" 15565dfecf96Smrg #'string-downcase "Dr. Livingston, I presume?") 15575dfecf96Smrg(equal-test "Dr. livingston, i Presume?" 15585dfecf96Smrg #'string-downcase "Dr. Livingston, I Presume?" :start 1 :end 17) 15595dfecf96Smrg(equal-test "Dr. livingston, i Presume?" 15605dfecf96Smrg #'nstring-downcase (xseq "Dr. Livingston, I Presume?") :start 1 :end 17) 15615dfecf96Smrg(equal-test "Elm 13c Arthur;Fig Don'T" 15625dfecf96Smrg #'string-capitalize "elm 13c arthur;fig don't") 15635dfecf96Smrg(equal-test "elm 13C Arthur;Fig Don't" 15645dfecf96Smrg #'string-capitalize "elm 13c arthur;fig don't" :start 6 :end 21) 15655dfecf96Smrg(equal-test "elm 13C Arthur;Fig Don't" 15665dfecf96Smrg #'nstring-capitalize (xseq "elm 13c arthur;fig don't") :start 6 :end 21) 15675dfecf96Smrg(equal-test " Hello " #'string-capitalize " hello ") 15685dfecf96Smrg(equal-test " Hello " #'nstring-capitalize (xseq " hello ")) 15695dfecf96Smrg(equal-test "Occluded Casements Forestall Inadvertent Defenestration" 15705dfecf96Smrg #'string-capitalize "occlUDeD cASEmenTs FOreSTAll iNADVertent DEFenestraTION") 15715dfecf96Smrg(equal-test "Don'T!" #'string-capitalize "DON'T!") 15725dfecf96Smrg(equal-test "Pipe 13a, Foo16c" #'string-capitalize "pipe 13a, foo16c") 15735dfecf96Smrg(setq str (copy-seq "0123ABCD890a")) 15745dfecf96Smrg(equal-test "0123AbcD890a" #'nstring-downcase str :start 5 :end 7) 15755dfecf96Smrg(equal-eval "0123AbcD890a" 'str) 15765dfecf96Smrg(error-test #'nstring-capitalize 1) 15775dfecf96Smrg(error-test #'string-capitalize "foobar" :start 4 :end 2) 15785dfecf96Smrg(equal-test "foobar" #'string-capitalize "foobar" :start 0 :end 0) 15795dfecf96Smrg 15805dfecf96Smrg;; string-{,left-,right-}trim - function 15815dfecf96Smrg(equal-test "kaaak" #'string-trim "abc" "abcaakaaakabcaaa") 15825dfecf96Smrg#+xedit (equal-test "kaaak" #'nstring-trim "abc" "abcaakaaakabcaaa") 15835dfecf96Smrg(equal-test "garbanzo beans" 15845dfecf96Smrg #'string-trim '(#\Space #\Tab #\Newline) " garbanzo beans 15855dfecf96Smrg ") 15865dfecf96Smrg#+xedit (equal-test "garbanzo beans" 15875dfecf96Smrg #'nstring-trim '(#\Space #\Tab #\Newline) " garbanzo beans 15885dfecf96Smrg ") 15895dfecf96Smrg(equal-test "three (silly) words" 15905dfecf96Smrg #'string-trim " (*)" " ( *three (silly) words* ) ") 15915dfecf96Smrg#+xedit (equal-test "three (silly) words" 15925dfecf96Smrg #'nstring-trim " (*)" " ( *three (silly) words* ) ") 15935dfecf96Smrg(equal-test "labcabcabc" #'string-left-trim "abc" "labcabcabc") 15945dfecf96Smrg#+xedit (equal-test "labcabcabc" #'nstring-left-trim "abc" "labcabcabc") 15955dfecf96Smrg(equal-test "three (silly) words* ) " 15965dfecf96Smrg #'string-left-trim " (*)" " ( *three (silly) words* ) ") 15975dfecf96Smrg#+xedit (equal-test "three (silly) words* ) " 15985dfecf96Smrg #'nstring-left-trim " (*)" " ( *three (silly) words* ) ") 15995dfecf96Smrg(equal-test " ( *three (silly) words" 16005dfecf96Smrg #'string-right-trim " (*)" " ( *three (silly) words* ) ") 16015dfecf96Smrg#+xedit (equal-test " ( *three (silly) words" 16025dfecf96Smrg #'nstring-right-trim " (*)" " ( *three (silly) words* ) ") 16035dfecf96Smrg(error-test #'string-trim 123 "123") 16045dfecf96Smrg(error-test #'string-left-trim 123 "123") 16055dfecf96Smrg 16065dfecf96Smrg;; stringp - function (predicate) 16075dfecf96Smrg(eq-test t #'stringp "abc") 16085dfecf96Smrg(eq-test nil #'stringp #\a) 16095dfecf96Smrg(eq-test nil #'stringp 1) 16105dfecf96Smrg(eq-test nil #'stringp #(#\a #\b #\c)) 16115dfecf96Smrg 16125dfecf96Smrg;; subseq - accessor 16135dfecf96Smrg(setq str (xseq "012345")) 16145dfecf96Smrg(equal-test "2345" #'subseq str 2) 16155dfecf96Smrg(equal-test "34" #'subseq str 3 5) 16165dfecf96Smrg(equal-eval "abc" '(setf (subseq str 4) "abc")) 16175dfecf96Smrg(equal-eval "0123ab" 'str) 16185dfecf96Smrg(equal-eval "A" '(setf (subseq str 0 2) "A")) 16195dfecf96Smrg(equal-eval "A123ab" 'str) 16205dfecf96Smrg 16215dfecf96Smrg;; subsetp - function 16225dfecf96Smrg(setq cosmos '(1 "a" (1 2))) 16235dfecf96Smrg(eq-test t #'subsetp '(1) cosmos) 16245dfecf96Smrg(eq-test nil #'subsetp '((1 2)) cosmos) 16255dfecf96Smrg(eq-test t #'subsetp '((1 2)) cosmos :test 'equal) 16265dfecf96Smrg(eq-test t #'subsetp '(1 "A") cosmos :test #'equalp) 16275dfecf96Smrg(eq-test nil #'subsetp '((1) (2)) '((1) (2))) 16285dfecf96Smrg(eq-test t #'subsetp '((1) (2)) '((1) (2)) :key #'car) 16295dfecf96Smrg 16305dfecf96Smrg;; svref - function 16315dfecf96Smrg;; XXX vectors will be reimplemented, just a test for the current implementation 16325dfecf96Smrg(setq v (vector 1 2 'sirens)) 16335dfecf96Smrg(eql-eval 1 '(svref v 0)) 16345dfecf96Smrg(eql-eval 'sirens '(svref v 2)) 16355dfecf96Smrg(eql-eval 'newcomer '(setf (svref v 1) 'newcomer)) 16365dfecf96Smrg(equalp-eval #(1 newcomer sirens) 'v) 16375dfecf96Smrg 16385dfecf96Smrg;; symbol-name - function 16395dfecf96Smrg(equal-test "TEMP" #'symbol-name 'temp) 16405dfecf96Smrg(equal-test "START" #'symbol-name :start) 16415dfecf96Smrg(error-test #'symbol-name 1) 16425dfecf96Smrg 16435dfecf96Smrg;; symbol-package - function 16445dfecf96Smrg(eq-test (find-package "LISP") #'symbol-package 'car) 16455dfecf96Smrg(eql-test *package* #'symbol-package 'bus) 16465dfecf96Smrg(eq-test (find-package "KEYWORD") #'symbol-package :optional) 16475dfecf96Smrg;; Gensyms are uninterned, so have no home package. 16485dfecf96Smrg(eq-test nil #'symbol-package (gensym)) 16495dfecf96Smrg(setq pk1 (make-package 'pk1)) 16505dfecf96Smrg(intern "SAMPLE1" "PK1") 16515dfecf96Smrg(eq-eval t '(export (find-symbol "SAMPLE1" "PK1") "PK1")) 16525dfecf96Smrg(setq pk2 (make-package 'pk2 :use '(pk1))) 16535dfecf96Smrg(equal-eval '(pk1:sample1 :inherited) 16545dfecf96Smrg '(multiple-value-list (find-symbol "SAMPLE1" "PK2"))) 16555dfecf96Smrg(eq-test pk1 #'symbol-package 'pk1::sample1) 16565dfecf96Smrg(eq-test pk1 #'symbol-package 'pk2::sample1) 16575dfecf96Smrg(eq-test pk1 #'symbol-package 'pk1::sample2) 16585dfecf96Smrg(eq-test pk2 #'symbol-package 'pk2::sample2) 16595dfecf96Smrg;; The next several forms create a scenario in which a symbol 16605dfecf96Smrg;; is not really uninterned, but is "apparently uninterned", 16615dfecf96Smrg;; and so SYMBOL-PACKAGE still returns NIL. 16625dfecf96Smrg(setq s3 'pk1::sample3) 16635dfecf96Smrg(eq-eval t '(import s3 'pk2)) 16645dfecf96Smrg(eq-eval t '(unintern s3 'pk1)) ;; XXX unintern not yet implemented 16655dfecf96Smrg(eq-test nil #'symbol-package s3) ;; fail due to unintern not implemented 16665dfecf96Smrg(eq-test t #'eq s3 'pk2::sample3) 16675dfecf96Smrg 16685dfecf96Smrg;; symbol-plist - accessor 16695dfecf96Smrg(setq sym (gensym)) 16705dfecf96Smrg(eq-eval () '(symbol-plist sym)) 16715dfecf96Smrg(eq-eval 'val1 '(setf (get sym 'prop1) 'val1)) 16725dfecf96Smrg(equal-eval '(prop1 val1) '(symbol-plist sym)) 16735dfecf96Smrg(eq-eval 'val2 '(setf (get sym 'prop2) 'val2)) 16745dfecf96Smrg(equal-eval '(prop2 val2 prop1 val1) '(symbol-plist sym)) 16755dfecf96Smrg(setq sym-plist (list 'prop3 'val3)) 16765dfecf96Smrg(eq-eval sym-plist '(setf (symbol-plist sym) sym-plist)) 16775dfecf96Smrg(eq-eval sym-plist '(symbol-plist sym)) 16785dfecf96Smrg 16795dfecf96Smrg;; symbol-value - accessor 16805dfecf96Smrg(eql-eval 1 '(setf (symbol-value 'a) 1)) 16815dfecf96Smrg(eql-eval 1 '(symbol-value 'a)) 16825dfecf96Smrg;; SYMBOL-VALUE cannot see lexical variables. 16835dfecf96Smrg(eql-eval 1 '(let ((a 2)) (symbol-value 'a))) 16845dfecf96Smrg(eql-eval 1 '(let ((a 2)) (setq a 3) (symbol-value 'a))) 16855dfecf96Smrg 16865dfecf96Smrg#+xedit ;; incorrect... 16875dfecf96Smrg(progn 16885dfecf96Smrg ;; SYMBOL-VALUE can see dynamic variables. 16895dfecf96Smrg ;; declare not yet implemented 16905dfecf96Smrg (proclaim '(special a)) 16915dfecf96Smrg (eql-eval 2 '(let ((a 2)) (symbol-value 'a))) 16925dfecf96Smrg (eql-eval 1 'a) 16935dfecf96Smrg (eql-eval 3 '(let ((a 2)) (setq a 3) (symbol-value 'a))) 16945dfecf96Smrg (eql-eval 1 'a) 16955dfecf96Smrg ;; declare not yet implement 16965dfecf96Smrg (makunbound 'a) 16975dfecf96Smrg (eql-eval 2 '(let ((a 2)) (setf (symbol-value 'a) 3) a)) 16985dfecf96Smrg (eql-eval 3 'a) 16995dfecf96Smrg (eql-eval 3 '(symbol-value 'a)) 17005dfecf96Smrg ;; declare not yet implement 17015dfecf96Smrg (makunbound 'a) 17025dfecf96Smrg (equal-eval '(5 4) 17035dfecf96Smrg '(multiple-value-list 17045dfecf96Smrg (let ((a 4)) 17055dfecf96Smrg 17065dfecf96Smrg ;; declare not yet implemented 17075dfecf96Smrg (defparameter a 3) 17085dfecf96Smrg 17095dfecf96Smrg (let ((b (symbol-value 'a))) 17105dfecf96Smrg (setf (symbol-value 'a) 5) 17115dfecf96Smrg (values a b))))) 17125dfecf96Smrg (eql-eval 3 'a) 17135dfecf96Smrg) 17145dfecf96Smrg(eq-eval :any-keyword '(symbol-value :any-keyword)) 17155dfecf96Smrg;; XXX these will fail 17165dfecf96Smrg(eq-eval nil '(symbol-value 'nil)) 17175dfecf96Smrg(eq-eval nil '(symbol-value '())) 17185dfecf96Smrg 17195dfecf96Smrg;; symbolp - function (predicate) 17205dfecf96Smrg(eq-test t #'symbolp 'elephant) 17215dfecf96Smrg(eq-test nil #'symbolp 12) 17225dfecf96Smrg;; XXX these will fail 17235dfecf96Smrg(eq-test t #'symbolp nil) 17245dfecf96Smrg(eq-test t #'symbolp '()) 17255dfecf96Smrg(eq-test t #'symbolp :test) 17265dfecf96Smrg(eq-test nil #'symbolp "hello") 17275dfecf96Smrg 17285dfecf96Smrg;; remprop - function 17295dfecf96Smrg(setq test (make-symbol "PSEUDO-PI")) 17305dfecf96Smrg(eq-eval () '(symbol-plist test)) 17315dfecf96Smrg(eq-eval t '(setf (get test 'constant) t)) 17325dfecf96Smrg(eql-eval 3.14 '(setf (get test 'approximation) 3.14)) 17335dfecf96Smrg(eql-eval 'noticeable '(setf (get test 'error-range) 'noticeable)) 17345dfecf96Smrg(equal-eval '(error-range noticeable approximation 3.14 constant t) 17355dfecf96Smrg '(symbol-plist test)) 17365dfecf96Smrg(eq-eval nil '(setf (get test 'approximation) nil)) 17375dfecf96Smrg(equal-eval '(error-range noticeable approximation nil constant t) 17385dfecf96Smrg '(symbol-plist test)) 17395dfecf96Smrg(eq-eval nil (get test 'approximation)) 17405dfecf96Smrg(eq-test t #'remprop test 'approximation) 17415dfecf96Smrg(eq-eval nil '(get test 'approximation)) 17425dfecf96Smrg(equal-eval '(error-range noticeable constant t) '(symbol-plist test)) 17435dfecf96Smrg(eq-test nil #'remprop test 'approximation) 17445dfecf96Smrg(equal-eval '(error-range noticeable constant t) '(symbol-plist test)) 17455dfecf96Smrg(eq-test t #'remprop test 'error-range) 17465dfecf96Smrg(eql-eval 3 '(setf (get test 'approximation) 3)) 17475dfecf96Smrg(equal-eval '(approximation 3 constant t) '(symbol-plist test)) 17485dfecf96Smrg 17495dfecf96Smrg;; throw - special operator 17505dfecf96Smrg(equal-eval '(3 9) 17515dfecf96Smrg '(multiple-value-list 17525dfecf96Smrg (catch 'result 17535dfecf96Smrg (setq i 0 j 0) 17545dfecf96Smrg (loop (incf j 3) (incf i) 17555dfecf96Smrg (if (= i 3) (throw 'result (values i j))))))) 17565dfecf96Smrg(eql-eval 2 '(catch nil (unwind-protect (throw nil 1) (throw nil 2)))) 17575dfecf96Smrg 17585dfecf96Smrg;; XXX undefined consequences 17595dfecf96Smrg(eql-eval 2 17605dfecf96Smrg '(catch 'a 17615dfecf96Smrg (catch 'b 17625dfecf96Smrg (unwind-protect (throw 'a 1) 17635dfecf96Smrg (throw 'b 2))))) 17645dfecf96Smrg(eq-eval :outer-catch 17655dfecf96Smrg '(catch 'foo 17665dfecf96Smrg (setq string (format nil "The inner catch returns ~s." 17675dfecf96Smrg (catch 'foo 17685dfecf96Smrg (unwind-protect (throw 'foo :first-throw) 17695dfecf96Smrg (throw 'foo :second-throw))))) 17705dfecf96Smrg :outer-catch)) 17715dfecf96Smrg(equal-eval "The inner catch returns :SECOND-THROW." 'string) 17725dfecf96Smrg 17735dfecf96Smrg;; tree-equal - function 17745dfecf96Smrg(setq tree1 '(1 (1 2)) 17755dfecf96Smrg tree2 '(1 (1 2))) 17765dfecf96Smrg(eq-test t #'tree-equal tree1 tree2) 17775dfecf96Smrg(eq-test nil #'eql tree1 tree2) 17785dfecf96Smrg(setq tree1 '('a ('b 'c)) 17795dfecf96Smrg tree2 '('a ('b 'c))) 17805dfecf96Smrg(eq-test t #'tree-equal tree1 tree2 :test 'eq) 17815dfecf96Smrg(eq-test t #'tree-equal 1 1) 17825dfecf96Smrg(eq-test nil #'tree-equal (list 1 2) (cons 1 2)) 17835dfecf96Smrg(eq-test nil #'tree-equal 1 2) 17845dfecf96Smrg 17855dfecf96Smrg;; union - function 17865dfecf96Smrg(equal-test '(b c f a d) #'union '(a b c) '(f a d)) 17875dfecf96Smrg(equal-test '((y 6) (z 2) (x 4)) 17885dfecf96Smrg #'union '((x 5) (y 6)) '((z 2) (x 4)) :key #'car) 17895dfecf96Smrg(setq lst1 (list 1 2 '(1 2) "a" "b") 17905dfecf96Smrg lst2 (list 2 3 '(2 3) "B" "C")) 17915dfecf96Smrg(equal-test '(1 (1 2) "a" "b" 2 3 (2 3) "B" "C") #'nunion lst1 lst2) 17925dfecf96Smrg 17935dfecf96Smrg;; unless - macro 17945dfecf96Smrg(eq-eval 'hello '(when t 'hello)) 17955dfecf96Smrg(eq-eval nil '(unless t 'hello)) 17965dfecf96Smrg(eq-eval nil (when nil 'hello)) 17975dfecf96Smrg(eq-eval 'hello '(unless nil 'hello)) 17985dfecf96Smrg(eq-eval nil (when t)) 17995dfecf96Smrg(eql-eval nil '(unless nil)) 18005dfecf96Smrg(setq test nil) 18015dfecf96Smrg(equal-eval '(3 2 1) '(when t (push 1 test) (push 2 test) (push 3 test))) 18025dfecf96Smrg(equal-eval '(3 2 1) 'test) 18035dfecf96Smrg(setq test nil) 18045dfecf96Smrg(eq-eval nil '(unless t (push 1 test) (push 2 test) (push 3 test))) 18055dfecf96Smrg(eq-eval nil 'test) 18065dfecf96Smrg(eq-eval nil '(when nil (push 1 test) (push 2 test) (push 3 test))) 18075dfecf96Smrg(eq-eval nil 'test) 18085dfecf96Smrg(equal-eval '(3 2 1) '(unless nil (push 1 test) (push 2 test) (push 3 test))) 18095dfecf96Smrg(equal-eval '(3 2 1) 'test) 18105dfecf96Smrg(equal-eval '((4) nil (5) nil 6 (6) 7 (7)) 18115dfecf96Smrg '(let ((x 3)) 18125dfecf96Smrg (list (when (oddp x) (incf x) (list x)) 18135dfecf96Smrg (when (oddp x) (incf x) (list x)) 18145dfecf96Smrg (unless (oddp x) (incf x) (list x)) 18155dfecf96Smrg (unless (oddp x) (incf x) (list x)) 18165dfecf96Smrg (if (oddp x) (incf x) (list x)) 18175dfecf96Smrg (if (oddp x) (incf x) (list x)) 18185dfecf96Smrg (if (not (oddp x)) (incf x) (list x)) 18195dfecf96Smrg (if (not (oddp x)) (incf x) (list x))))) 18205dfecf96Smrg 18215dfecf96Smrg;; unwind-protect - special operator 18225dfecf96Smrg(defun dummy-function (x) 18235dfecf96Smrg (setq state 'running) 18245dfecf96Smrg (unless (numberp x) (throw 'abort 'not-a-number)) 18255dfecf96Smrg (setq state (1+ x))) 18265dfecf96Smrg(eql-eval 2 '(catch 'abort (dummy-function 1))) 18275dfecf96Smrg(eql-eval 2 'state) 18285dfecf96Smrg(eq-eval 'not-a-number '(catch 'abort (dummy-function 'trash))) 18295dfecf96Smrg(eq-eval 'running 'state) 18305dfecf96Smrg(eq-eval 'not-a-number 18315dfecf96Smrg '(catch 'abort (unwind-protect (dummy-function 'trash) 18325dfecf96Smrg (setq state 'aborted)))) 18335dfecf96Smrg(eq-eval 'aborted 'state) 18345dfecf96Smrg(eql-eval 2 '(block nil (unwind-protect (return 1) (return 2)))) 18355dfecf96Smrg;; XXX undefined consequences 18365dfecf96Smrg(eql-eval 2 18375dfecf96Smrg '(block a 18385dfecf96Smrg (block b 18395dfecf96Smrg (unwind-protect (return-from a 1) 18405dfecf96Smrg (return-from b 2))))) 18415dfecf96Smrg(eql-eval 2 '(catch nil (unwind-protect (throw nil 1) (throw nil 2)))) 18425dfecf96Smrg;; XXX undefined consequences 18435dfecf96Smrg(eql-eval 2 18445dfecf96Smrg '(catch 'a (catch 'b (unwind-protect (throw 'a 1) (throw 'b 2))))) 18455dfecf96Smrg(eq-eval ':outer-catch 18465dfecf96Smrg '(catch 'foo 18475dfecf96Smrg (setq string 18485dfecf96Smrg (format nil "The inner catch returns ~s." 18495dfecf96Smrg (catch 'foo 18505dfecf96Smrg (unwind-protect (throw 'foo :first-throw) 18515dfecf96Smrg (throw 'foo :second-throw))))) 18525dfecf96Smrg :outer-catch)) 18535dfecf96Smrg(equal-eval "The inner catch returns :SECOND-THROW." 'string) 18545dfecf96Smrg(eql-eval 10 18555dfecf96Smrg '(catch 'a 18565dfecf96Smrg (catch 'b 18575dfecf96Smrg (unwind-protect (1+ (catch 'a (throw 'b 1))) 18585dfecf96Smrg (throw 'a 10))))) 18595dfecf96Smrg;; XXX undefined consequences 18605dfecf96Smrg(eql-eval 4 18615dfecf96Smrg '(catch 'foo 18625dfecf96Smrg (catch 'bar 18635dfecf96Smrg (unwind-protect (throw 'foo 3) 18645dfecf96Smrg (throw 'bar 4) 18655dfecf96Smrg (print 'xxx))))) 18665dfecf96Smrg(eql-eval 4 18675dfecf96Smrg '(catch 'bar 18685dfecf96Smrg (catch 'foo 18695dfecf96Smrg (unwind-protect (throw 'foo 3) 18705dfecf96Smrg (throw 'bar 4) 18715dfecf96Smrg (print 'xxx))))) 18725dfecf96Smrg(eql-eval 5 18735dfecf96Smrg '(block nil 18745dfecf96Smrg (let ((x 5)) 18755dfecf96Smrg (unwind-protect (return) 18765dfecf96Smrg (return x))))) 18775dfecf96Smrg 18785dfecf96Smrg;; upper-case-p - function 18795dfecf96Smrg(eq-test t #'upper-case-p #\A) 18805dfecf96Smrg(eq-test nil #'upper-case-p #\a) 18815dfecf96Smrg(eq-test nil #'upper-case-p #\5) 18825dfecf96Smrg(error-test #'upper-case-p 1) 18835dfecf96Smrg 18845dfecf96Smrg;; values - accessor 18855dfecf96Smrg(eq-eval () '(multiple-value-list (values))) 18865dfecf96Smrg(equal-eval '(1) '(multiple-value-list (values 1))) 18875dfecf96Smrg(equal-eval '(1 2) '(multiple-value-list (values 1 2))) 18885dfecf96Smrg(equal-eval '(1 2 3) '(multiple-value-list (values 1 2 3))) 18895dfecf96Smrg(equal-eval '(1 4 5) '(multiple-value-list (values (values 1 2 3) 4 5))) 18905dfecf96Smrg 18915dfecf96Smrg;; values-list - function 18925dfecf96Smrg(eq-eval nil '(multiple-value-list (values-list nil))) 18935dfecf96Smrg(equal-eval '(1) '(multiple-value-list (values-list '(1)))) 18945dfecf96Smrg(equal-eval '(1 2) '(multiple-value-list (values-list '(1 2)))) 18955dfecf96Smrg(equal-eval '(1 2 3) '(multiple-value-list (values-list '(1 2 3)))) 1896