klisp

an open source interpreter for the Kernel Programming Language.
git clone http://git.hanabi.in/repos/klisp.git
Log | Files | Refs | README

pairs-and-lists.k (18034B)


      1 ;; check.k & test-helpers.k should be loaded
      2 
      3 ;; TODO use mutable-pair to verify that cons, list append etc construct with 
      4 
      5 ;;;
      6 ;;; Basic Functionality
      7 ;;;
      8 
      9 ;; null? & pair?
     10 ($check-predicate (null?))
     11 ($check-predicate (null? ()))
     12 ($check-predicate (null? () () ()))
     13 ($check-predicate (null? () . #0=(() . #0#)))
     14 
     15 ($check-predicate (pair?))
     16 ($check-predicate (pair? (cons () ())))
     17 ($check-predicate (pair? (cons () ()) 
     18                          (copy-es-immutable (cons () ())) (cons () ())))
     19 ($check-predicate (pair? (cons () ()) . 
     20                          #0=((copy-es-immutable (cons () ())) . #0#)))
     21 
     22 ($check-not-predicate (null? #t))
     23 ($check-not-predicate (null? ((unwrap list) . symbol)))
     24 ($check-not-predicate (null? (cons () ())))
     25 ($check-not-predicate (null? #ignore))
     26 ($check-not-predicate (null? (make-environment)))
     27 ($check-not-predicate (null? #inert))
     28 ($check-not-predicate (null? $vau))
     29 ($check-not-predicate (null? wrap))
     30 ($check-not-predicate (null? (call/cc ($lambda (c) c))))
     31 ($check-not-predicate (null? ($let (((enc . #ignore) 
     32                                      (make-encapsulation-type)))
     33                                (enc #inert))))
     34 ($check-not-predicate (null? (memoize #inert)))
     35 ($check-not-predicate (null? 1))
     36 ($check-not-predicate (null? 1.0))
     37 ($check-not-predicate (null? #e+infinity))
     38 ($check-not-predicate (null? #i+infinity))
     39 ($check-not-predicate (null? #undefined))
     40 ($check-not-predicate (null? #real))
     41 ($check-not-predicate (null? "string"))
     42 ($check-not-predicate (null? #\a))
     43 ($check-not-predicate (null? (get-current-input-port)))
     44 
     45 ($check-not-predicate (pair? #t))
     46 ($check-not-predicate (pair? ((unwrap list) . symbol)))
     47 ($check-not-predicate (pair? ()))
     48 ($check-not-predicate (pair? #ignore))
     49 ($check-not-predicate (pair? (make-environment)))
     50 ($check-not-predicate (pair? #inert))
     51 ($check-not-predicate (pair? $vau))
     52 ($check-not-predicate (pair? wrap))
     53 ($check-not-predicate (pair? (call/cc ($lambda (c) c))))
     54 ($check-not-predicate (pair? ($let (((enc . #ignore) 
     55                                      (make-encapsulation-type)))
     56                                (enc #inert))))
     57 ($check-not-predicate (pair? (memoize #inert)))
     58 ($check-not-predicate (pair? 1))
     59 ($check-not-predicate (pair? 1.0))
     60 ($check-not-predicate (pair? #e+infinity))
     61 ($check-not-predicate (pair? #i+infinity))
     62 ($check-not-predicate (pair? #undefined))
     63 ($check-not-predicate (pair? #real))
     64 ($check-not-predicate (pair? "string"))
     65 ($check-not-predicate (pair? #\a))
     66 ($check-not-predicate (pair? (get-current-input-port)))
     67 
     68 ;; basic eq?-ness
     69 ($check eq? () ())
     70 ($let ((p (cons () ())))
     71   ($check eq? p p))
     72 ($check not-eq? (cons () ()) (cons () ()))
     73 ($check not-eq? (cons () ()) ())
     74 
     75 ;; basic equal?-ness
     76 ($check equal? (cons () ()) (cons () ()))
     77 ($check equal? () ())
     78 ($check not-equal? (cons () ()) (cons (cons () ()) ()))
     79 ($check not-equal? (cons () ()) ())
     80 
     81 ;; list & list*
     82 ($check equal? (list) ())
     83 ($check equal? (list 1 2 3) (cons 1 (cons 2 (cons 3 ()))))
     84 ($check equal? ((unwrap list) 1 2 . 3) (list* 1 2 3))
     85 ($check equal? ((unwrap list) . #inert) (list* #inert))
     86 ($check equal? (list* #inert) #inert)
     87 ($check equal? (list* 1 2 3) (cons 1 (cons 2 3)))
     88 ($check equal? (list 1 . #0=(2 3 . #0#)) ((unwrap list) 1 . #0#))
     89 
     90 ;; car, cdr & co
     91 ($check equal? (car (cons 1 2)) 1)
     92 ($check equal? (cdr (cons 1 2)) 2)
     93 
     94 ($let* ((tree2 (cons 1 2))
     95         (tree4 (cons tree2 (cons 3 4)))
     96         (tree8 (cons tree4 (cons (cons 5 6) (cons 7 8))))
     97         (tree16 (cons tree8 (cons (cons (cons 9 10) (cons 11 12))
     98                                   (cons (cons 13 14) (cons 15 16))))))
     99   ($check eq? (car tree2) 1)
    100   ($check eq? (cdr tree2) 2)
    101 
    102   ($check eq? (caar tree4) 1)
    103   ($check eq? (cdar tree4) 2)
    104   ($check eq? (cadr tree4) 3)
    105   ($check eq? (cddr tree4) 4)
    106 
    107   ($check eq? (caaar tree8) 1)
    108   ($check eq? (cdaar tree8) 2)
    109   ($check eq? (cadar tree8) 3)
    110   ($check eq? (cddar tree8) 4)
    111   ($check eq? (caadr tree8) 5)
    112   ($check eq? (cdadr tree8) 6)
    113   ($check eq? (caddr tree8) 7)
    114   ($check eq? (cdddr tree8) 8)
    115 
    116   ($check eq? (caaaar tree16) 1)
    117   ($check eq? (cdaaar tree16) 2)
    118   ($check eq? (cadaar tree16) 3)
    119   ($check eq? (cddaar tree16) 4)
    120   ($check eq? (caadar tree16) 5)
    121   ($check eq? (cdadar tree16) 6)
    122   ($check eq? (caddar tree16) 7)
    123   ($check eq? (cdddar tree16) 8)
    124   ($check eq? (caaadr tree16) 9)
    125   ($check eq? (cdaadr tree16) 10)
    126   ($check eq? (cadadr tree16) 11)
    127   ($check eq? (cddadr tree16) 12)
    128   ($check eq? (caaddr tree16) 13)
    129   ($check eq? (cdaddr tree16) 14)
    130   ($check eq? (cadddr tree16) 15)
    131   ($check eq? (cddddr tree16) 16))
    132 
    133 ;; make-list
    134 ($check-predicate (null? (make-list 0)))
    135 ($check-predicate (mutable-pair? (make-list 1)))
    136 ($check equal? (make-list 2) (list #inert #inert))
    137 ($check equal? (make-list 3 "val") (list "val" "val" "val"))
    138 
    139 ;; list-copy
    140 ($check-predicate (null? (list-copy ())))
    141 ($check-predicate (mutable-pair? (list-copy (list 1))))
    142 ($check-predicate (mutable-pair? (list-copy (copy-es-immutable (list 1)))))
    143 ($check equal? (list-copy (list 1 2 3)) (list 1 2 3))
    144 ($check equal? (list-copy (list . #1=(1 2 . #1#))) (list . #2=(1 2 . #2#)))
    145 
    146 ;; reverse
    147 ($check-predicate (null? (reverse ())))
    148 ($check-predicate (mutable-pair? (reverse (list 1))))
    149 ($check-predicate (mutable-pair? (reverse (copy-es-immutable (list 1)))))
    150 ($check equal? (reverse (list 1)) (list 1))
    151 ($check equal? (reverse (list 1 2 3)) (list 3 2 1))
    152 
    153 ;; get-list-metrics
    154 ($check equal? (get-list-metrics ()) (list 0 1 0 0))
    155 ($check equal? (get-list-metrics #inert) (list 0 0 0 0))
    156 ($check equal? (get-list-metrics (list 1)) (list 1 1 1 0))
    157 ($check equal? (get-list-metrics (list* 1 2)) (list 1 0 1 0))
    158 ($check equal? (get-list-metrics (list 1 2 . #0=(3 4 5 . #0#))) (list 5 0 2 3))
    159 ($check equal? (get-list-metrics (list . #0=(1 2 . #0#))) (list 2 0 0 2))
    160 
    161 ;; list-tail
    162 ($check equal? (list-tail (list 1 2 3 4 5) 0) (list 1 2 3 4 5))
    163 ($check equal? (list-tail (list 1 2 3 4 5) 1) (list 2 3 4 5))
    164 ($check equal? (list-tail (list* 1 2 3) 2) 3)
    165 ($check equal? (list-tail (list . #0=(1 2 3 4 5 . #0#)) 10) (list . #0#))
    166 
    167 ;; length
    168 ($check =? (length ()) 0)
    169 ($check =? (length "string") 0) ; in Kernel improper lists have length too
    170 ($check =? (length (list 1 2 3 4 5)) 5)
    171 ($check =? (length (list* 1 2 3 4 5 "string")) 5)
    172 ($check =? (length (list 1 2 . #0=(3 4 5 . #0#))) #e+infinity)
    173 
    174 ;; list-ref
    175 ($check =? (list-ref (list 1 2 3 4 5) 0) 1)
    176 ($check =? (list-ref (list 1 2 3 4 5) 1) 2)
    177 ;; see kgpairs_lists.c for rationale on allowing
    178 ;; improper lists as argument to list-ref 
    179 ($check =? (list-ref (list* 1 2 3 4) 2) 3)
    180 ($check =? (list-ref (list . #0=(1 2 3 4 5 . #0#)) 10) 1)
    181 
    182 ;; append
    183 ($check equal? (append) ())
    184 ($check equal? (append ()) ())
    185 ($check equal? (append () ()) ())
    186 ($check equal? (append (list 1 2 3) (list 4 5) (list 6)) (list 1 2 3 4 5 6))
    187 ($check equal? (append (list 1 2) (list 3 4 5 6) ()) (list 1 2 3 4 5 6))
    188 ($check equal? (append () (list 1) (list 2 3 4)) (list 1 2 3 4))
    189 ($check equal? (append (list 1 2) (list 3 4) 5) (list* 1 2 3 4 5))
    190 ($let ((l1 (list 1 2)) (l2 (list 3 4))) ; the last list isn't copied
    191   ($check eq? (cddr (append l1 l2)) l2))
    192 ($let ((l1 (list 1 2)) (l2 (list 3 4))) ; here the last list is copied
    193   ($check not-eq? (cddr (append l1 l2 ())) l2))
    194 ($check equal?
    195         (append (list 1 2) (list 3 4) . #0=((list 5 6) . #0#))
    196         (list 1 2 3 4 . #1=(5 6 . #1#)))
    197 ($check equal?
    198         (append () () . #0=(() (list 1 2) () . #0#))
    199         (list . #1=(1 2 . #1#)))
    200 ($check equal?
    201         (append (list 1 2) (list 3 4) . #0=(() () . #0#))
    202         (list 1 2 3 4))
    203 
    204 ;; list-neighbors
    205 ($check equal? (list-neighbors ()) ())
    206 ($check equal? (list-neighbors (list 1)) ())
    207 ($check equal? (list-neighbors (list 1 2)) (list (list 1 2)))
    208 ($check equal? 
    209         (list-neighbors (list 1 2 3 4))
    210         (list (list 1 2) (list 2 3) (list 3 4)))
    211 ($check equal? 
    212         (list-neighbors (list . #0=(1 2 3 4 . #0#)))
    213         (list . #1=((list 1 2) (list 2 3) (list 3 4) (list 4 1) . #1#)))
    214 ($check equal? 
    215         (list-neighbors (list 1 2 . #0=(3 4 . #0#)))
    216         (list (list 1 2) (list 2 3) . #1=((list 3 4) (list 4 3) . #1#)))
    217 
    218 ;; filter
    219 ($check equal? (filter number? ()) ())
    220 ($check equal? (filter number? (list #t #f #t)) ())
    221 ($check equal? (filter number? (list 1 2 3)) (list 1 2 3))
    222 ($check equal? (filter number? (list 1 #t 2 #f)) (list 1 2))
    223 ($check equal? 
    224         (filter number? (list 1 #t . #0=(2 #f . #0#)))
    225         (list 1 . #1=(2 . #1#)))
    226 ($check equal? 
    227         (filter number? (list #t 1 #f . #0=(#t #f . #0#)))
    228         (list 1))
    229 ($check equal? 
    230         (filter number? (list #t #f . #0=(#t #f . #0#)))
    231         ())
    232 
    233 ($check equal? ; filter should use an empty environment
    234         (filter (wrap ($vau #ignore denv ($binds? denv $if)))
    235                 (list 1 2 3))
    236         ())
    237 
    238 ;; filter + continuation capturing and mutation
    239 ;; TODO
    240 
    241 ;; assoc
    242 ($check equal? (assoc #inert ()) ())
    243 ($check equal? (assoc 3 (list (list 1 10) (list 2 20))) ())
    244 ($check equal? (assoc 1 (list (list 1 10) (list 2 20))) (list 1 10))
    245 ($check equal? (assoc 1 (list (list 1 10) (list 2 20)) =?) (list 1 10))
    246 ($check equal?
    247         (assoc 1 (list . #0=((list 1 10) (list 2 20) (list 1 15) . #0#)))
    248         (list 1 10))
    249 ($check equal?
    250         (assoc 4 (list . #0=((list 1 10) (list 2 20) (list 1 15) . #0#)))
    251         ())
    252 ($check equal?
    253         (assoc (list 1) (list (list (list 1) 1) (list (list 2) 2)))
    254         (list (list 1) 1))
    255 
    256 ($check equal?
    257         (assoc 4 (list . #0=((list 1 10) (list 2 20) (list 1 15) . #0#))
    258                =?)
    259         ())
    260 ;; member?
    261 ($check-predicate (member? 1 (list 1 2)))
    262 ($check-predicate (member? 2 (list 1 2)))
    263 ($check-not-predicate (member? 1 ()))
    264 ($check-not-predicate (member? 3 (list 1 2)))
    265 ($check-predicate (member? (list 1) (list (list 1) 2)))
    266 ($check-predicate (member? (list 2) (list 1 (list 2))))
    267 ($check-predicate
    268  (member? (list 1 3) (list . #0=(1 2 (list 1 3) . #0#))))
    269 ($check-not-predicate
    270  (member? 4 (list . #0=(1 2 1 . #0#))))
    271 
    272 ($check-predicate (member? -1 (list 1 2) ($lambda (x y) (=? x (- 0 y)))))
    273 ($check-not-predicate (member? 1 (list 1 2 . #0=(3 4 . #0#)) 
    274                                ($lambda (x y) (=? x (- 0 y)))))
    275 
    276 ;; finite-list?
    277 ($check-predicate (finite-list? ()))
    278 ($check-predicate (finite-list? (list 1)))
    279 ($check-predicate (finite-list? (list 1 2)))
    280 ($check-predicate (finite-list? (list 1 2) (list 1 2 3) ()))
    281 ($check-predicate (finite-list? (list 1 2) . #0=((list 1 2 3) () . #0#)))
    282 ($check-not-predicate (finite-list? 1))
    283 ($check-not-predicate (finite-list? () (list 1 2 . #0=(3 . #0#))))
    284 ($check-not-predicate (finite-list? () 1))
    285 ($check-not-predicate (finite-list? (list 1 2) . #0=(1 () . #0#)))
    286 
    287 ;; countable-list?
    288 ($check-predicate (countable-list? ()))
    289 ($check-predicate (countable-list? (list 1 2)))
    290 ($check-predicate (countable-list? (list 1 . #0=(2 . #0#))))
    291 ($check-predicate (countable-list? (list 1 2) (list 1 . #0=(2 . #0#)) ()))
    292 ($check-predicate (countable-list? 
    293                    () . #0=((list 1 . #1=(2 . #1#)) () . #0#)))
    294 
    295 ($check-not-predicate (countable-list? 1))
    296 ($check-not-predicate (countable-list? () 1))
    297 ($check-not-predicate (countable-list? (list 1 2) . #0=(#inert () . #0#)))
    298 ($check-not-predicate (countable-list? 
    299                        () . #0=((list 1 . #1=(2 . #1#)) 3 . #0#)))
    300 
    301 ;; reduce
    302 ($let ((ac-+ ($lambda ls (reduce ls + 0)))
    303        (c-+
    304         ;; the idea of the cycle treatment is to carry a flag indicating
    305         ;; if all elements so far in the cycle were actually zero, if so
    306         ;; the sum of the cycle is zero otherwise it can be undefined or
    307         ;; (* +infinity (acyclic-sum)) which in the integer case is +infinity 
    308         ;; or -infinity
    309         ($let ((precycle ($lambda (x)
    310                            (cons x (zero? x))))
    311                (incycle ($lambda ((x . x-zero?) (y . y-zero?))
    312                           (cons (+ x y) 
    313                                 (and? x-zero? y-zero?))))
    314                (postcycle ($lambda ((result . all-zero?))
    315                             ($if all-zero?
    316                                  0
    317                                  (* #e+infinity result)))))
    318           ($lambda ls
    319             (reduce ls + 0 precycle incycle postcycle)))))
    320   ($check equal? (ac-+) 0)
    321   ($check equal? (ac-+ 1) 1)
    322   ($check equal? (ac-+ 1 2) 3)
    323   ($check equal? (ac-+ 1 2 3) 6)
    324 
    325   ($check equal? (c-+) 0)
    326   ($check equal? (c-+ 1) 1)
    327   ($check equal? (c-+ 1 2) 3)
    328   ($check equal? (c-+ 1 2 . #0=(0 0 . #0#)) 3)
    329   ($check equal? (c-+ 1 2 . #2=(-3 -4 . #2#)) #e-infinity))
    330 
    331 
    332 ;;;
    333 ;;; Error Checking and Robustness
    334 ;;;
    335 
    336 ;; null? & pair?
    337 ($check-error (null? () . #inert))
    338 ($check-error (pair? (cons () ()) . #inert))
    339 
    340 ;; list & list*
    341 ($check-error (list #inert . 1))
    342 ($check-error (list* . 1))
    343 ($check-error (list*))
    344 ($check-error (list* 1 #0=(2 3 . #0#)))
    345 
    346 ;; car, cdr & co
    347 ($check-error (car))
    348 ($check-error (cdr))
    349 ($check-error (car ()))
    350 ($check-error (cdr ()))
    351 ($check-error (car 1))
    352 ($check-error (cdr 1))
    353 ($check-error (car (cons 1 2) (cons 3 4)))
    354 ($check-error (cdr (cons 1 2) (cons 3 4)))
    355 
    356 ($let* ((tree2 (cons 1 2))
    357         (tree4 (cons tree2 (cons 3 4)))
    358         (tree8 (cons tree4 (cons (cons 5 6) (cons 7 8)))))
    359   ($check-error (caar tree2))
    360   ($check-error (cdar tree2))
    361   ($check-error (cadr tree2))
    362   ($check-error (cddr tree2))
    363 
    364   ($check-error (caaar tree4))
    365   ($check-error (cdaar tree4))
    366   ($check-error (cadar tree4))
    367   ($check-error (cddar tree4))
    368   ($check-error (caadr tree4))
    369   ($check-error (cdadr tree4))
    370   ($check-error (caddr tree4))
    371   ($check-error (cdddr tree4))
    372 
    373   ($check-error (caaaar tree8))
    374   ($check-error (cdaaar tree8))
    375   ($check-error (cadaar tree8))
    376   ($check-error (cddaar tree8))
    377   ($check-error (caadar tree8))
    378   ($check-error (cdadar tree8))
    379   ($check-error (caddar tree8))
    380   ($check-error (cdddar tree8))
    381   ($check-error (caaadr tree8))
    382   ($check-error (cdaadr tree8))
    383   ($check-error (cadadr tree8))
    384   ($check-error (cddadr tree8))
    385   ($check-error (caaddr tree8))
    386   ($check-error (cdaddr tree8))
    387   ($check-error (cadddr tree8))
    388   ($check-error (cddddr tree8)))
    389 
    390 ;; make-list
    391 ($check-error (make-list))
    392 ($check-error (make-list "str"))
    393 ($check-error (make-list 1 "str" "str2"))
    394 ($check-error (make-list -2))
    395 ($check-error (make-list 3/4))
    396 ($check-error (make-list #e+infinity))
    397 
    398 ;; list-copy
    399 ($check-error (list-copy))
    400 ($check-error (list-copy () ()))
    401 ($check-error (list-copy #inert))
    402 ($check-error (list-copy (list* 1 2 3)))
    403 
    404 ;; reverse
    405 ($check-error (reverse))
    406 ($check-error (reverse () ()))
    407 ($check-error (reverse #inert))
    408 ($check-error (reverse (list* 1 2 3)))
    409 ($check-error (reverse (list 1 . #1=(2 . #1#))))
    410 
    411 ;; get-list-metrics
    412 ($check-error (get-list-metrics))
    413 ($check-error (get-list-metrics () ()))
    414 
    415 ;; list-tail
    416 ($check-error (list-tail))
    417 ($check-error (list-tail (list 1 2 3)))
    418 ($check-error (list-tail (list 1 2 3) 3 4))
    419 ($check-error (list-tail (list 1 2 3) 4))
    420 ($check-error (list-tail (list 1 2 3) #e+infinity))
    421                                         ;($check-error (list-tail (list 1 2 3) 3.4))
    422 ($check-error (list-tail (list 1 2 3) -1))
    423 ($check-error (list-tail (list 1 2 3) #f))
    424 
    425 ;; length
    426 ($check-error (length))
    427 ($check-error (length () ()))
    428 ($check-error (length . #0=(() . #0#)))
    429 
    430 ;; list-ref
    431 ($check-error (list-ref))
    432 ($check-error (list-ref (list 1 2 3)))
    433 ($check-error (list-ref (list 1 2 3) 3 4))
    434 ($check-error (list-ref (list 1 2 3) 4))
    435 ($check-error (list-ref (list 1 2 3) #e+infinity))
    436                                         ;($check-error (list-ref (list 1 2 3) 3.4))
    437 ($check-error (list-ref (list 1 2 3) -1))
    438 ($check-error (list-ref (list 1 2 3) #f))
    439 
    440 ;; append
    441 ($check-error (append (list 1 2) (list . #0=(3 4 . #0#)) (list 5 6)))
    442 ($check-error (append (list . #0=(1 2 . #0#)) ()))
    443 ($check-error (append (list 1 2) 3 (list 4 5)))
    444 ($check-error (append (list 1 2) 3 ()))
    445 
    446 ;; list-neighbors
    447 ($check-error (list-neighbors))
    448 ($check-error (list-neighbors (list 1 2) (list 3 4)))
    449 ($check-error (list-neighbors 1))
    450 ($check-error (list-neighbors (list* 1 2 3 4)))
    451 
    452 ;; filter
    453 ($check-error (filter))
    454 ($check-error (filter number?))
    455 ($check-error (filter (list 1)))
    456 ($check-error (filter number? #inert))
    457 ($check-error (filter number? (list* 1 2 3)))
    458 ($check-error (filter number? (list 1 2 3) #inert))
    459 ($check-error (filter (unwrap number?) (list 1 2 3)))
    460 ($check-error (filter + (list 1 2 3)))
    461 ($check-error (filter car (list 1 2 3)))
    462 
    463 ;; asooc
    464 ($check-error (assoc))
    465 ($check-error (assoc 2))
    466 ($check-error (assoc 2 (list (list 1 1) (list 2 2)) () ()))
    467 ($check-error (assoc . #0=(2 (list (list 1 1) (list 2 2)) . #0#)))
    468 ($check-error (assoc 2 (list (list 1 1) (list 2 2)) () (unwrap equal?)))
    469 
    470 ($check-error (assoc 2 (list* (list 1 1) 2)))
    471 ($check-error (assoc 2 (list* (list 1 1) (list 2 2) #inert)))
    472 ($check-error (assoc 2 (list* 1 2) equal?))
    473 ($check-error (assoc 4 (list (list 1 1) (list 2 2) #inert (list 4 4))))
    474 ($check-error (assoc 2 (list (list 1 1) (list 2 2) #inert (list 4 4))))
    475 ($check-error (assoc 2 (list (list 1 1) (list 2 2) #inert (list 4 4)) 
    476                      equal?))
    477 
    478 ;; member?
    479 ($check-error (member?))
    480 ($check-error (member? 2))
    481 ($check-error (member? 2 (list 1 2) () ()))
    482 ($check-error (member? . #0=(2 (list 1 2) . #0#)))
    483 ($check-error (member? 2 (list 1 2) (unwrap equal?)))
    484 
    485 ($check-error (member? 2 (list* 1 2)))
    486 ($check-error (member? 2 (list* 1 2 3)))
    487 ($check-error (member? 2 (list* 1 2) equal?))
    488 
    489 ;; finite-list?
    490 ($check-error (countable-list? (cons () ()) . #inert))
    491 
    492 ;; countable-list?
    493 ($check-error (countable-list? (list . #0=(1 . #0#)) . #inert))
    494 
    495 ;; reduce
    496 ($check-error (reduce))
    497 ($check-error (reduce (list 1 2)))
    498 ($check-error (reduce (list 1 2) +))
    499 ($check-error (reduce #inert + 0))
    500 ($check-error (reduce (list 1 2) #inert 0))
    501 ($check-error (reduce (list 1 2 #0=(3 . #0#)) + 0))
    502 
    503 ($check-error (reduce (list 1 2 #0=(3 . #0#)) + 0 +))
    504 ($check-error (reduce (list 1 2 #0=(3 . #0#)) + 0 + +))
    505 ($check-error (reduce (list 1 2 #0=(3 . #0#)) + 0 + + + +))
    506 ($check-error (reduce (list 1 2 #0=(3 . #0#)) + 0 + + #inert))
    507 ($check-error (reduce (list 1 2 #0=(3 . #0#)) + 0 + #inert +))
    508 ($check-error (reduce (list 1 2 #0=(3 . #0#)) + 0 #inert + +))