Hex Artifact Content
Not logged in

Artifact cc63e0b1df5a84892a8659afc5396630ab26ba53:


0000: 23 21 72 36 72 73 0a 3b 3b 20 53 52 46 49 20 31  #!r6rs.;; SRFI 1
0010: 30 31 3a 20 50 75 72 65 6c 79 20 46 75 6e 63 74  01: Purely Funct
0020: 69 6f 6e 61 6c 20 52 61 6e 64 6f 6d 2d 41 63 63  ional Random-Acc
0030: 65 73 73 20 50 61 69 72 73 20 61 6e 64 20 4c 69  ess Pairs and Li
0040: 73 74 73 0a 3b 3b 20 43 6f 70 79 72 69 67 68 74  sts.;; Copyright
0050: 20 28 63 29 20 44 61 76 69 64 20 56 61 6e 20 48   (c) David Van H
0060: 6f 72 6e 20 32 30 30 39 2e 20 20 41 6c 6c 20 52  orn 2009.  All R
0070: 69 67 68 74 73 20 52 65 73 65 72 76 65 64 2e 0a  ights Reserved..
0080: 0a 3b 3b 20 50 65 72 6d 69 73 73 69 6f 6e 20 69  .;; Permission i
0090: 73 20 68 65 72 65 62 79 20 67 72 61 6e 74 65 64  s hereby granted
00a0: 2c 20 66 72 65 65 20 6f 66 20 63 68 61 72 67 65  , free of charge
00b0: 2c 20 74 6f 20 61 6e 79 20 70 65 72 73 6f 6e 20  , to any person 
00c0: 6f 62 74 61 69 6e 69 6e 67 0a 3b 3b 20 61 20 63  obtaining.;; a c
00d0: 6f 70 79 20 6f 66 20 74 68 69 73 20 73 6f 66 74  opy of this soft
00e0: 77 61 72 65 20 61 6e 64 20 61 73 73 6f 63 69 61  ware and associa
00f0: 74 65 64 20 64 6f 63 75 6d 65 6e 74 61 74 69 6f  ted documentatio
0100: 6e 0a 3b 3b 20 66 69 6c 65 73 20 28 74 68 65 20  n.;; files (the 
0110: 22 53 6f 66 74 77 61 72 65 22 29 2c 20 74 6f 20  "Software"), to 
0120: 64 65 61 6c 20 69 6e 20 74 68 65 20 53 6f 66 74  deal in the Soft
0130: 77 61 72 65 20 77 69 74 68 6f 75 74 20 72 65 73  ware without res
0140: 74 72 69 63 74 69 6f 6e 2c 0a 3b 3b 20 69 6e 63  triction,.;; inc
0150: 6c 75 64 69 6e 67 20 77 69 74 68 6f 75 74 20 6c  luding without l
0160: 69 6d 69 74 61 74 69 6f 6e 20 74 68 65 20 72 69  imitation the ri
0170: 67 68 74 73 20 74 6f 20 75 73 65 2c 20 63 6f 70  ghts to use, cop
0180: 79 2c 20 6d 6f 64 69 66 79 2c 20 6d 65 72 67 65  y, modify, merge
0190: 2c 0a 3b 3b 20 70 75 62 6c 69 73 68 2c 20 64 69  ,.;; publish, di
01a0: 73 74 72 69 62 75 74 65 2c 20 73 75 62 6c 69 63  stribute, sublic
01b0: 65 6e 73 65 2c 20 61 6e 64 2f 6f 72 20 73 65 6c  ense, and/or sel
01c0: 6c 20 63 6f 70 69 65 73 20 6f 66 20 74 68 65 20  l copies of the 
01d0: 53 6f 66 74 77 61 72 65 2c 0a 3b 3b 20 61 6e 64  Software,.;; and
01e0: 20 74 6f 20 70 65 72 6d 69 74 20 70 65 72 73 6f   to permit perso
01f0: 6e 73 20 74 6f 20 77 68 6f 6d 20 74 68 65 20 53  ns to whom the S
0200: 6f 66 74 77 61 72 65 20 69 73 20 66 75 72 6e 69  oftware is furni
0210: 73 68 65 64 20 74 6f 20 64 6f 20 73 6f 2c 0a 3b  shed to do so,.;
0220: 3b 20 73 75 62 6a 65 63 74 20 74 6f 20 74 68 65  ; subject to the
0230: 20 66 6f 6c 6c 6f 77 69 6e 67 20 63 6f 6e 64 69   following condi
0240: 74 69 6f 6e 73 3a 0a 0a 3b 3b 20 54 68 65 20 61  tions:..;; The a
0250: 62 6f 76 65 20 63 6f 70 79 72 69 67 68 74 20 6e  bove copyright n
0260: 6f 74 69 63 65 20 61 6e 64 20 74 68 69 73 20 70  otice and this p
0270: 65 72 6d 69 73 73 69 6f 6e 20 6e 6f 74 69 63 65  ermission notice
0280: 20 73 68 61 6c 6c 20 62 65 0a 3b 3b 20 69 6e 63   shall be.;; inc
0290: 6c 75 64 65 64 20 69 6e 20 61 6c 6c 20 63 6f 70  luded in all cop
02a0: 69 65 73 20 6f 72 20 73 75 62 73 74 61 6e 74 69  ies or substanti
02b0: 61 6c 20 70 6f 72 74 69 6f 6e 73 20 6f 66 20 74  al portions of t
02c0: 68 65 20 53 6f 66 74 77 61 72 65 2e 0a 0a 3b 3b  he Software...;;
02d0: 20 54 48 45 20 53 4f 46 54 57 41 52 45 20 49 53   THE SOFTWARE IS
02e0: 20 50 52 4f 56 49 44 45 44 20 22 41 53 20 49 53   PROVIDED "AS IS
02f0: 22 2c 20 57 49 54 48 4f 55 54 20 57 41 52 52 41  ", WITHOUT WARRA
0300: 4e 54 59 20 4f 46 20 41 4e 59 20 4b 49 4e 44 2c  NTY OF ANY KIND,
0310: 0a 3b 3b 20 45 58 50 52 45 53 53 20 4f 52 20 49  .;; EXPRESS OR I
0320: 4d 50 4c 49 45 44 2c 20 49 4e 43 4c 55 44 49 4e  MPLIED, INCLUDIN
0330: 47 20 42 55 54 20 4e 4f 54 20 4c 49 4d 49 54 45  G BUT NOT LIMITE
0340: 44 20 54 4f 20 54 48 45 20 57 41 52 52 41 4e 54  D TO THE WARRANT
0350: 49 45 53 20 4f 46 0a 3b 3b 20 4d 45 52 43 48 41  IES OF.;; MERCHA
0360: 4e 54 41 42 49 4c 49 54 59 2c 20 46 49 54 4e 45  NTABILITY, FITNE
0370: 53 53 20 46 4f 52 20 41 20 50 41 52 54 49 43 55  SS FOR A PARTICU
0380: 4c 41 52 20 50 55 52 50 4f 53 45 20 41 4e 44 0a  LAR PURPOSE AND.
0390: 3b 3b 20 4e 4f 4e 49 4e 46 52 49 4e 47 45 4d 45  ;; NONINFRINGEME
03a0: 4e 54 2e 20 52 45 4d 45 4d 42 45 52 2c 20 54 48  NT. REMEMBER, TH
03b0: 45 52 45 20 49 53 20 4e 4f 20 53 43 48 45 4d 45  ERE IS NO SCHEME
03c0: 20 55 4e 44 45 52 47 52 4f 55 4e 44 2e 20 49 4e   UNDERGROUND. IN
03d0: 20 4e 4f 20 45 56 45 4e 54 0a 3b 3b 20 53 48 41   NO EVENT.;; SHA
03e0: 4c 4c 20 54 48 45 20 41 55 54 48 4f 52 53 20 4f  LL THE AUTHORS O
03f0: 52 20 43 4f 50 59 52 49 47 48 54 20 48 4f 4c 44  R COPYRIGHT HOLD
0400: 45 52 53 20 42 45 20 4c 49 41 42 4c 45 20 46 4f  ERS BE LIABLE FO
0410: 52 20 41 4e 59 20 43 4c 41 49 4d 2c 0a 3b 3b 20  R ANY CLAIM,.;; 
0420: 44 41 4d 41 47 45 53 20 4f 52 20 4f 54 48 45 52  DAMAGES OR OTHER
0430: 20 4c 49 41 42 49 4c 49 54 59 2c 20 57 48 45 54   LIABILITY, WHET
0440: 48 45 52 20 49 4e 20 41 4e 20 41 43 54 49 4f 4e  HER IN AN ACTION
0450: 20 4f 46 20 43 4f 4e 54 52 41 43 54 2c 20 54 4f   OF CONTRACT, TO
0460: 52 54 20 4f 52 0a 3b 3b 20 4f 54 48 45 52 57 49  RT OR.;; OTHERWI
0470: 53 45 2c 20 41 52 49 53 49 4e 47 20 46 52 4f 4d  SE, ARISING FROM
0480: 2c 20 4f 55 54 20 4f 46 20 4f 52 20 49 4e 20 43  , OUT OF OR IN C
0490: 4f 4e 4e 45 43 54 49 4f 4e 20 57 49 54 48 20 54  ONNECTION WITH T
04a0: 48 45 20 53 4f 46 54 57 41 52 45 20 4f 52 0a 3b  HE SOFTWARE OR.;
04b0: 3b 20 54 48 45 20 55 53 45 20 4f 52 20 4f 54 48  ; THE USE OR OTH
04c0: 45 52 20 44 45 41 4c 49 4e 47 53 20 49 4e 20 54  ER DEALINGS IN T
04d0: 48 45 20 53 4f 46 54 57 41 52 45 2e 0a 0a 3b 3b  HE SOFTWARE...;;
04e0: 20 54 68 69 73 20 74 65 73 74 20 73 75 69 74 65   This test suite
04f0: 20 68 61 73 20 62 65 65 6e 20 73 75 63 63 65 73   has been succes
0500: 73 66 75 6c 6c 79 20 72 75 6e 20 6f 6e 20 49 6b  sfully run on Ik
0510: 61 72 75 73 20 28 30 2e 30 2e 33 29 2c 0a 3b 3b  arus (0.0.3),.;;
0520: 20 4c 61 72 63 65 6e 79 20 28 30 2e 39 37 29 2c   Larceny (0.97),
0530: 20 61 6e 64 20 50 4c 54 20 53 63 68 65 6d 65 20   and PLT Scheme 
0540: 28 34 2e 32 2e 31 2e 37 29 2e 0a 0a 3b 3b 20 54  (4.2.1.7)...;; T
0550: 6f 20 72 75 6e 3a 0a 3b 3b 20 20 20 20 63 70 20  o run:.;;    cp 
0560: 73 72 66 69 2d 31 30 31 2e 73 6c 73 20 73 72 66  srfi-101.sls srf
0570: 69 2f 25 33 41 31 30 31 2e 73 6c 73 0a 3b 3b 20  i/%3A101.sls.;; 
0580: 20 20 20 69 6b 61 72 75 73 20 2d 2d 72 36 72 73     ikarus --r6rs
0590: 2d 73 63 72 69 70 74 20 73 72 66 69 2d 31 30 31  -script srfi-101
05a0: 2d 74 65 73 74 73 2e 73 6c 73 0a 3b 3b 20 20 20  -tests.sls.;;   
05b0: 20 6c 61 72 63 65 6e 79 20 2d 72 36 72 73 20 2d   larceny -r6rs -
05c0: 70 61 74 68 20 2e 20 2d 70 72 6f 67 72 61 6d 20  path . -program 
05d0: 73 72 66 69 2d 31 30 31 2d 74 65 73 74 73 2e 73  srfi-101-tests.s
05e0: 6c 73 0a 3b 3b 20 20 20 20 70 6c 74 2d 72 36 72  ls.;;    plt-r6r
05f0: 73 20 2b 2b 70 61 74 68 20 2e 20 73 72 66 69 2d  s ++path . srfi-
0600: 31 30 31 2d 74 65 73 74 73 2e 73 6c 73 0a 0a 28  101-tests.sls..(
0610: 69 6d 70 6f 72 74 20 28 65 78 63 65 70 74 20 28  import (except (
0620: 72 6e 72 73 20 62 61 73 65 29 0a 20 20 20 20 20  rnrs base).     
0630: 20 20 20 20 20 20 20 20 20 20 20 71 75 6f 74 65             quote
0640: 20 70 61 69 72 3f 20 63 6f 6e 73 20 63 61 72 20   pair? cons car 
0650: 63 64 72 20 0a 20 20 20 20 20 20 20 20 20 20 20  cdr .           
0660: 20 20 20 20 20 63 61 61 72 20 63 61 64 72 20 63       caar cadr c
0670: 64 64 72 20 63 64 61 72 0a 20 20 20 20 20 20 20  ddr cdar.       
0680: 20 20 20 20 20 20 20 20 20 63 61 61 61 72 20 63           caaar c
0690: 61 61 64 72 20 63 61 64 64 72 20 63 61 64 61 72  aadr caddr cadar
06a0: 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20  .               
06b0: 20 63 64 61 61 72 20 63 64 61 64 72 20 63 64 64   cdaar cdadr cdd
06c0: 64 72 20 63 64 64 61 72 0a 20 20 20 20 20 20 20  dr cddar.       
06d0: 20 20 20 20 20 20 20 20 20 63 61 61 61 61 72 20           caaaar 
06e0: 63 61 61 61 64 72 20 63 61 61 64 64 72 20 63 61  caaadr caaddr ca
06f0: 61 64 61 72 0a 20 20 20 20 20 20 20 20 20 20 20  adar.           
0700: 20 20 20 20 20 63 61 64 61 61 72 20 63 61 64 61       cadaar cada
0710: 64 72 20 63 61 64 64 64 72 20 63 61 64 64 61 72  dr cadddr caddar
0720: 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20  .               
0730: 20 63 64 61 61 61 72 20 63 64 61 61 64 72 20 63   cdaaar cdaadr c
0740: 64 61 64 64 72 20 63 64 61 64 61 72 0a 20 20 20  daddr cdadar.   
0750: 20 20 20 20 20 20 20 20 20 20 20 20 20 63 64 64               cdd
0760: 61 61 72 20 63 64 64 61 64 72 20 63 64 64 64 64  aar cddadr cdddd
0770: 72 20 63 64 64 64 61 72 0a 20 20 20 20 20 20 20  r cdddar.       
0780: 20 20 20 20 20 20 20 20 20 6e 75 6c 6c 3f 20 6c           null? l
0790: 69 73 74 3f 20 6c 69 73 74 20 6c 65 6e 67 74 68  ist? list length
07a0: 20 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20   .              
07b0: 20 20 61 70 70 65 6e 64 20 72 65 76 65 72 73 65    append reverse
07c0: 20 6c 69 73 74 2d 74 61 69 6c 0a 20 20 20 20 20   list-tail.     
07d0: 20 20 20 20 20 20 20 20 20 20 20 6c 69 73 74 2d             list-
07e0: 72 65 66 20 6d 61 70 20 66 6f 72 2d 65 61 63 68  ref map for-each
07f0: 29 0a 20 20 20 20 20 20 20 20 28 70 72 65 66 69  ).        (prefi
0800: 78 20 28 72 6e 72 73 20 62 61 73 65 29 20 72 36  x (rnrs base) r6
0810: 3a 29 0a 20 20 20 20 20 20 20 20 28 72 6e 72 73  :).        (rnrs
0820: 20 65 78 63 65 70 74 69 6f 6e 73 29 0a 20 20 20   exceptions).   
0830: 20 20 20 20 20 28 73 75 72 66 61 67 65 20 73 31       (surfage s1
0840: 30 31 20 72 61 6e 64 6f 6d 2d 61 63 63 65 73 73  01 random-access
0850: 2d 6c 69 73 74 73 29 29 0a 0a 28 64 65 66 69 6e  -lists))..(defin
0860: 65 20 28 63 68 65 63 6b 2d 65 78 70 65 63 74 20  e (check-expect 
0870: 63 20 65 29 0a 20 20 28 69 66 20 28 70 61 69 72  c e).  (if (pair
0880: 3f 20 63 29 0a 20 20 20 20 20 20 28 62 65 67 69  ? c).      (begi
0890: 6e 20 28 61 73 73 65 72 74 20 28 70 61 69 72 3f  n (assert (pair?
08a0: 20 65 29 29 0a 20 20 20 20 20 20 20 20 20 20 20   e)).           
08b0: 20 20 28 63 68 65 63 6b 2d 65 78 70 65 63 74 20    (check-expect 
08c0: 28 63 61 72 20 63 29 0a 20 20 20 20 20 20 20 20  (car c).        
08d0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
08e0: 20 20 20 28 63 61 72 20 65 29 29 0a 20 20 20 20     (car e)).    
08f0: 20 20 20 20 20 20 20 20 20 28 63 68 65 63 6b 2d           (check-
0900: 65 78 70 65 63 74 20 28 63 64 72 20 63 29 0a 20  expect (cdr c). 
0910: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
0920: 20 20 20 20 20 20 20 20 20 20 28 63 64 72 20 65            (cdr e
0930: 29 29 29 0a 20 20 20 20 20 20 28 61 73 73 65 72  ))).      (asser
0940: 74 20 28 65 71 75 61 6c 3f 20 63 20 65 29 29 29  t (equal? c e)))
0950: 29 0a 0a 28 64 65 66 69 6e 65 2d 73 79 6e 74 61  )..(define-synta
0960: 78 20 63 68 65 63 6b 2d 65 72 72 6f 72 0a 20 20  x check-error.  
0970: 28 73 79 6e 74 61 78 2d 72 75 6c 65 73 20 28 29  (syntax-rules ()
0980: 0a 20 20 20 20 28 28 5f 20 65 29 0a 20 20 20 20  .    ((_ e).    
0990: 20 28 6c 65 74 20 28 28 66 20 28 63 6f 6e 73 20   (let ((f (cons 
09a0: 30 20 30 29 29 29 0a 20 20 20 20 20 20 20 28 67  0 0))).       (g
09b0: 75 61 72 64 20 28 67 20 28 28 65 71 3f 20 66 20  uard (g ((eq? f 
09c0: 67 29 20 28 61 73 73 65 72 74 20 23 66 29 29 0a  g) (assert #f)).
09d0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
09e0: 20 28 65 6c 73 65 20 27 4f 4b 29 29 0a 20 20 20   (else 'OK)).   
09f0: 20 20 20 20 20 20 20 20 20 20 20 28 62 65 67 69             (begi
0a00: 6e 20 65 0a 20 20 20 20 20 20 20 20 20 20 20 20  n e.            
0a10: 20 20 20 20 20 20 20 20 20 28 72 61 69 73 65 20           (raise 
0a20: 66 29 29 29 29 29 29 29 0a 0a 3b 20 71 75 6f 74  f)))))))..; quot
0a30: 65 20 20 0a 0a 3b 20 42 75 67 20 69 6e 20 4c 61  e  ..; Bug in La
0a40: 72 63 65 6e 79 20 70 72 65 76 65 6e 74 73 20 74  rceny prevents t
0a50: 68 69 73 20 66 72 6f 6d 20 77 6f 72 6b 69 6e 67  his from working
0a60: 0a 3b 20 68 74 74 70 73 3a 2f 2f 74 72 61 63 2e  .; https://trac.
0a70: 63 63 73 2e 6e 65 75 2e 65 64 75 2f 74 72 61 63  ccs.neu.edu/trac
0a80: 2f 6c 61 72 63 65 6e 79 2f 74 69 63 6b 65 74 2f  /larceny/ticket/
0a90: 36 35 36 0a 3b 28 63 68 65 63 6b 2d 65 78 70 65  656.;(check-expe
0aa0: 63 74 20 28 71 75 6f 74 65 20 35 29 20 28 72 36  ct (quote 5) (r6
0ab0: 3a 71 75 6f 74 65 20 35 29 29 0a 3b 28 63 68 65  :quote 5)).;(che
0ac0: 63 6b 2d 65 78 70 65 63 74 20 28 71 75 6f 74 65  ck-expect (quote
0ad0: 20 78 29 20 28 72 36 3a 71 75 6f 74 65 20 78 29   x) (r6:quote x)
0ae0: 29 0a 0a 28 63 68 65 63 6b 2d 65 78 70 65 63 74  )..(check-expect
0af0: 20 28 6c 65 74 20 28 28 66 20 28 6c 61 6d 62 64   (let ((f (lambd
0b00: 61 20 28 29 20 27 28 78 29 29 29 29 0a 20 20 20  a () '(x)))).   
0b10: 20 20 20 20 20 20 20 20 20 20 20 20 20 28 65 71               (eq
0b20: 3f 20 28 66 29 20 28 66 29 29 29 0a 20 20 20 20  ? (f) (f))).    
0b30: 20 20 20 20 20 20 20 20 20 20 23 74 29 0a 0a 28            #t)..(
0b40: 63 68 65 63 6b 2d 65 78 70 65 63 74 20 27 28 31  check-expect '(1
0b50: 20 32 20 33 29 20 28 6c 69 73 74 20 31 20 32 20   2 3) (list 1 2 
0b60: 33 29 29 0a 0a 3b 20 70 61 69 72 3f 0a 28 63 68  3))..; pair?.(ch
0b70: 65 63 6b 2d 65 78 70 65 63 74 20 28 70 61 69 72  eck-expect (pair
0b80: 3f 20 28 63 6f 6e 73 20 27 61 20 27 62 29 29 20  ? (cons 'a 'b)) 
0b90: 23 74 29 0a 28 63 68 65 63 6b 2d 65 78 70 65 63  #t).(check-expec
0ba0: 74 20 28 70 61 69 72 3f 20 28 6c 69 73 74 20 27  t (pair? (list '
0bb0: 61 20 27 62 20 27 63 29 29 20 23 74 29 0a 28 63  a 'b 'c)) #t).(c
0bc0: 68 65 63 6b 2d 65 78 70 65 63 74 20 28 70 61 69  heck-expect (pai
0bd0: 72 3f 20 27 28 29 29 20 23 66 29 0a 28 63 68 65  r? '()) #f).(che
0be0: 63 6b 2d 65 78 70 65 63 74 20 28 70 61 69 72 3f  ck-expect (pair?
0bf0: 20 27 23 28 61 20 62 29 29 20 23 66 29 0a 0a 3b   '#(a b)) #f)..;
0c00: 20 63 6f 6e 73 0a 28 63 68 65 63 6b 2d 65 78 70   cons.(check-exp
0c10: 65 63 74 20 28 63 6f 6e 73 20 27 61 20 27 28 29  ect (cons 'a '()
0c20: 29 20 28 6c 69 73 74 20 27 61 29 29 0a 28 63 68  ) (list 'a)).(ch
0c30: 65 63 6b 2d 65 78 70 65 63 74 20 28 63 6f 6e 73  eck-expect (cons
0c40: 20 28 6c 69 73 74 20 27 61 29 20 28 6c 69 73 74   (list 'a) (list
0c50: 20 27 62 20 27 63 20 27 64 29 29 0a 20 20 20 20   'b 'c 'd)).    
0c60: 20 20 20 20 20 20 20 20 20 20 28 6c 69 73 74 20            (list 
0c70: 28 6c 69 73 74 20 27 61 29 20 27 62 20 27 63 20  (list 'a) 'b 'c 
0c80: 27 64 29 29 0a 28 63 68 65 63 6b 2d 65 78 70 65  'd)).(check-expe
0c90: 63 74 20 28 63 6f 6e 73 20 22 61 22 20 28 6c 69  ct (cons "a" (li
0ca0: 73 74 20 27 62 20 27 63 29 29 0a 20 20 20 20 20  st 'b 'c)).     
0cb0: 20 20 20 20 20 20 20 20 20 28 6c 69 73 74 20 22           (list "
0cc0: 61 22 20 27 62 20 27 63 29 29 0a 28 63 68 65 63  a" 'b 'c)).(chec
0cd0: 6b 2d 65 78 70 65 63 74 20 28 63 6f 6e 73 20 27  k-expect (cons '
0ce0: 61 20 33 29 0a 20 20 20 20 20 20 20 20 20 20 20  a 3).           
0cf0: 20 20 20 28 63 6f 6e 73 20 27 61 20 33 29 29 0a     (cons 'a 3)).
0d00: 28 63 68 65 63 6b 2d 65 78 70 65 63 74 20 28 63  (check-expect (c
0d10: 6f 6e 73 20 28 6c 69 73 74 20 27 61 20 27 62 29  ons (list 'a 'b)
0d20: 20 27 63 29 0a 20 20 20 20 20 20 20 20 20 20 20   'c).           
0d30: 20 20 20 28 63 6f 6e 73 20 28 6c 69 73 74 20 27     (cons (list '
0d40: 61 20 27 62 29 20 27 63 29 29 0a 0a 3b 20 63 61  a 'b) 'c))..; ca
0d50: 72 0a 28 63 68 65 63 6b 2d 65 78 70 65 63 74 20  r.(check-expect 
0d60: 28 63 61 72 20 28 6c 69 73 74 20 27 61 20 27 62  (car (list 'a 'b
0d70: 20 27 63 29 29 0a 20 20 20 20 20 20 20 20 20 20   'c)).          
0d80: 20 20 20 20 27 61 29 0a 28 63 68 65 63 6b 2d 65      'a).(check-e
0d90: 78 70 65 63 74 20 28 63 61 72 20 28 6c 69 73 74  xpect (car (list
0da0: 20 28 6c 69 73 74 20 27 61 29 20 27 62 20 27 63   (list 'a) 'b 'c
0db0: 20 27 64 29 29 0a 20 20 20 20 20 20 20 20 20 20   'd)).          
0dc0: 20 20 20 20 28 6c 69 73 74 20 27 61 29 29 0a 28      (list 'a)).(
0dd0: 63 68 65 63 6b 2d 65 78 70 65 63 74 20 28 63 61  check-expect (ca
0de0: 72 20 28 63 6f 6e 73 20 31 20 32 29 29 20 31 29  r (cons 1 2)) 1)
0df0: 0a 28 63 68 65 63 6b 2d 65 72 72 6f 72 20 28 63  .(check-error (c
0e00: 61 72 20 27 28 29 29 29 0a 0a 3b 20 63 64 72 0a  ar '()))..; cdr.
0e10: 28 63 68 65 63 6b 2d 65 78 70 65 63 74 20 28 63  (check-expect (c
0e20: 64 72 20 28 6c 69 73 74 20 28 6c 69 73 74 20 27  dr (list (list '
0e30: 61 29 20 27 62 20 27 63 20 27 64 29 29 0a 20 20  a) 'b 'c 'd)).  
0e40: 20 20 20 20 20 20 20 20 20 20 20 20 28 6c 69 73              (lis
0e50: 74 20 27 62 20 27 63 20 27 64 29 29 0a 28 63 68  t 'b 'c 'd)).(ch
0e60: 65 63 6b 2d 65 78 70 65 63 74 20 28 63 64 72 20  eck-expect (cdr 
0e70: 28 63 6f 6e 73 20 31 20 32 29 29 0a 20 20 20 20  (cons 1 2)).    
0e80: 20 20 20 20 20 20 20 20 20 20 32 29 0a 28 63 68            2).(ch
0e90: 65 63 6b 2d 65 72 72 6f 72 20 28 63 64 72 20 27  eck-error (cdr '
0ea0: 28 29 29 29 0a 0a 3b 20 6e 75 6c 6c 3f 0a 28 63  ()))..; null?.(c
0eb0: 68 65 63 6b 2d 65 78 70 65 63 74 20 28 65 71 3f  heck-expect (eq?
0ec0: 20 6e 75 6c 6c 3f 20 72 36 3a 6e 75 6c 6c 3f 29   null? r6:null?)
0ed0: 20 23 74 29 0a 28 63 68 65 63 6b 2d 65 78 70 65   #t).(check-expe
0ee0: 63 74 20 28 6e 75 6c 6c 3f 20 27 28 29 29 20 23  ct (null? '()) #
0ef0: 74 29 0a 28 63 68 65 63 6b 2d 65 78 70 65 63 74  t).(check-expect
0f00: 20 28 6e 75 6c 6c 3f 20 28 63 6f 6e 73 20 31 20   (null? (cons 1 
0f10: 32 29 29 20 23 66 29 0a 28 63 68 65 63 6b 2d 65  2)) #f).(check-e
0f20: 78 70 65 63 74 20 28 6e 75 6c 6c 3f 20 34 29 20  xpect (null? 4) 
0f30: 23 66 29 0a 0a 3b 20 6c 69 73 74 3f 0a 28 63 68  #f)..; list?.(ch
0f40: 65 63 6b 2d 65 78 70 65 63 74 20 28 6c 69 73 74  eck-expect (list
0f50: 3f 20 28 6c 69 73 74 20 27 61 20 27 62 20 27 63  ? (list 'a 'b 'c
0f60: 29 29 20 23 74 29 0a 28 63 68 65 63 6b 2d 65 78  )) #t).(check-ex
0f70: 70 65 63 74 20 28 6c 69 73 74 3f 20 27 28 29 29  pect (list? '())
0f80: 20 23 74 29 0a 28 63 68 65 63 6b 2d 65 78 70 65   #t).(check-expe
0f90: 63 74 20 28 6c 69 73 74 3f 20 28 63 6f 6e 73 20  ct (list? (cons 
0fa0: 27 61 20 27 62 29 29 20 23 66 29 0a 0a 3b 20 6c  'a 'b)) #f)..; l
0fb0: 69 73 74 0a 28 63 68 65 63 6b 2d 65 78 70 65 63  ist.(check-expec
0fc0: 74 20 28 6c 69 73 74 20 27 61 20 28 2b 20 33 20  t (list 'a (+ 3 
0fd0: 34 29 20 27 63 29 0a 20 20 20 20 20 20 20 20 20  4) 'c).         
0fe0: 20 20 20 20 20 28 6c 69 73 74 20 27 61 20 37 20       (list 'a 7 
0ff0: 27 63 29 29 0a 28 63 68 65 63 6b 2d 65 78 70 65  'c)).(check-expe
1000: 63 74 20 28 6c 69 73 74 29 20 27 28 29 29 0a 0a  ct (list) '())..
1010: 3b 20 6d 61 6b 65 2d 6c 69 73 74 0a 28 63 68 65  ; make-list.(che
1020: 63 6b 2d 65 78 70 65 63 74 20 28 6c 65 6e 67 74  ck-expect (lengt
1030: 68 20 28 6d 61 6b 65 2d 6c 69 73 74 20 35 29 29  h (make-list 5))
1040: 20 35 29 0a 28 63 68 65 63 6b 2d 65 78 70 65 63   5).(check-expec
1050: 74 20 28 6d 61 6b 65 2d 6c 69 73 74 20 35 20 30  t (make-list 5 0
1060: 29 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20  ).              
1070: 28 6c 69 73 74 20 30 20 30 20 30 20 30 20 30 29  (list 0 0 0 0 0)
1080: 29 0a 0a 3b 20 6c 65 6e 67 74 68 0a 28 63 68 65  )..; length.(che
1090: 63 6b 2d 65 78 70 65 63 74 20 28 6c 65 6e 67 74  ck-expect (lengt
10a0: 68 20 28 6c 69 73 74 20 27 61 20 27 62 20 27 63  h (list 'a 'b 'c
10b0: 29 29 20 33 29 0a 28 63 68 65 63 6b 2d 65 78 70  )) 3).(check-exp
10c0: 65 63 74 20 28 6c 65 6e 67 74 68 20 28 6c 69 73  ect (length (lis
10d0: 74 20 27 61 20 28 6c 69 73 74 20 27 62 29 20 28  t 'a (list 'b) (
10e0: 6c 69 73 74 20 27 63 29 29 29 20 33 29 0a 28 63  list 'c))) 3).(c
10f0: 68 65 63 6b 2d 65 78 70 65 63 74 20 28 6c 65 6e  heck-expect (len
1100: 67 74 68 20 27 28 29 29 20 30 29 0a 0a 3b 20 61  gth '()) 0)..; a
1110: 70 70 65 6e 64 0a 28 63 68 65 63 6b 2d 65 78 70  ppend.(check-exp
1120: 65 63 74 20 28 61 70 70 65 6e 64 20 28 6c 69 73  ect (append (lis
1130: 74 20 27 78 29 20 28 6c 69 73 74 20 27 79 29 29  t 'x) (list 'y))
1140: 20 28 6c 69 73 74 20 27 78 20 27 79 29 29 0a 28   (list 'x 'y)).(
1150: 63 68 65 63 6b 2d 65 78 70 65 63 74 20 28 61 70  check-expect (ap
1160: 70 65 6e 64 20 28 6c 69 73 74 20 27 61 29 20 28  pend (list 'a) (
1170: 6c 69 73 74 20 27 62 20 27 63 20 27 64 29 29 20  list 'b 'c 'd)) 
1180: 28 6c 69 73 74 20 27 61 20 27 62 20 27 63 20 27  (list 'a 'b 'c '
1190: 64 29 29 0a 28 63 68 65 63 6b 2d 65 78 70 65 63  d)).(check-expec
11a0: 74 20 28 61 70 70 65 6e 64 20 28 6c 69 73 74 20  t (append (list 
11b0: 27 61 20 28 6c 69 73 74 20 27 62 29 29 20 28 6c  'a (list 'b)) (l
11c0: 69 73 74 20 28 6c 69 73 74 20 27 63 29 29 29 20  ist (list 'c))) 
11d0: 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 28  .              (
11e0: 6c 69 73 74 20 27 61 20 28 6c 69 73 74 20 27 62  list 'a (list 'b
11f0: 29 20 28 6c 69 73 74 20 27 63 29 29 29 0a 28 63  ) (list 'c))).(c
1200: 68 65 63 6b 2d 65 78 70 65 63 74 20 28 61 70 70  heck-expect (app
1210: 65 6e 64 20 28 6c 69 73 74 20 27 61 20 27 62 29  end (list 'a 'b)
1220: 20 28 63 6f 6e 73 20 27 63 20 27 64 29 29 20 0a   (cons 'c 'd)) .
1230: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 28 63                (c
1240: 6f 6e 73 20 27 61 20 28 63 6f 6e 73 20 27 62 20  ons 'a (cons 'b 
1250: 28 63 6f 6e 73 20 27 63 20 27 64 29 29 29 29 0a  (cons 'c 'd)))).
1260: 28 63 68 65 63 6b 2d 65 78 70 65 63 74 20 28 61  (check-expect (a
1270: 70 70 65 6e 64 20 27 28 29 20 27 61 29 20 27 61  ppend '() 'a) 'a
1280: 29 0a 0a 3b 20 72 65 76 65 72 73 65 0a 28 63 68  )..; reverse.(ch
1290: 65 63 6b 2d 65 78 70 65 63 74 20 28 72 65 76 65  eck-expect (reve
12a0: 72 73 65 20 28 6c 69 73 74 20 27 61 20 27 62 20  rse (list 'a 'b 
12b0: 27 63 29 29 0a 20 20 20 20 20 20 20 20 20 20 20  'c)).           
12c0: 20 20 20 28 6c 69 73 74 20 27 63 20 27 62 20 27     (list 'c 'b '
12d0: 61 29 29 0a 28 63 68 65 63 6b 2d 65 78 70 65 63  a)).(check-expec
12e0: 74 20 28 72 65 76 65 72 73 65 20 28 6c 69 73 74  t (reverse (list
12f0: 20 27 61 20 28 6c 69 73 74 20 27 62 20 27 63 29   'a (list 'b 'c)
1300: 20 27 64 20 28 6c 69 73 74 20 27 65 20 28 6c 69   'd (list 'e (li
1310: 73 74 20 27 66 29 29 29 29 0a 20 20 20 20 20 20  st 'f)))).      
1320: 20 20 20 20 20 20 20 20 28 6c 69 73 74 20 28 6c          (list (l
1330: 69 73 74 20 27 65 20 28 6c 69 73 74 20 27 66 29  ist 'e (list 'f)
1340: 29 20 27 64 20 28 6c 69 73 74 20 27 62 20 27 63  ) 'd (list 'b 'c
1350: 29 20 27 61 29 29 0a 0a 3b 20 6c 69 73 74 2d 74  ) 'a))..; list-t
1360: 61 69 6c 0a 28 63 68 65 63 6b 2d 65 78 70 65 63  ail.(check-expec
1370: 74 20 28 6c 69 73 74 2d 74 61 69 6c 20 28 6c 69  t (list-tail (li
1380: 73 74 20 27 61 20 27 62 20 27 63 20 27 64 29 20  st 'a 'b 'c 'd) 
1390: 32 29 0a 20 20 20 20 20 20 20 20 20 20 20 20 20  2).             
13a0: 20 28 6c 69 73 74 20 27 63 20 27 64 29 29 0a 0a   (list 'c 'd))..
13b0: 3b 20 6c 69 73 74 2d 72 65 66 0a 28 63 68 65 63  ; list-ref.(chec
13c0: 6b 2d 65 78 70 65 63 74 20 28 6c 69 73 74 2d 72  k-expect (list-r
13d0: 65 66 20 28 6c 69 73 74 20 27 61 20 27 62 20 27  ef (list 'a 'b '
13e0: 63 20 27 64 29 20 32 29 20 27 63 29 0a 0a 3b 20  c 'd) 2) 'c)..; 
13f0: 6c 69 73 74 2d 73 65 74 0a 28 63 68 65 63 6b 2d  list-set.(check-
1400: 65 78 70 65 63 74 20 28 6c 69 73 74 2d 73 65 74  expect (list-set
1410: 20 28 6c 69 73 74 20 27 61 20 27 62 20 27 63 20   (list 'a 'b 'c 
1420: 27 64 29 20 32 20 27 78 29 0a 20 20 20 20 20 20  'd) 2 'x).      
1430: 20 20 20 20 20 20 20 20 28 6c 69 73 74 20 27 61          (list 'a
1440: 20 27 62 20 27 78 20 27 64 29 29 0a 0a 3b 20 6c   'b 'x 'd))..; l
1450: 69 73 74 2d 72 65 66 2f 75 70 64 61 74 65 0a 28  ist-ref/update.(
1460: 6c 65 74 2d 76 61 6c 75 65 73 20 28 28 28 61 20  let-values (((a 
1470: 62 29 20 0a 20 20 20 20 20 20 20 20 20 20 20 20  b) .            
1480: 20 20 28 6c 69 73 74 2d 72 65 66 2f 75 70 64 61    (list-ref/upda
1490: 74 65 20 28 6c 69 73 74 20 37 20 38 20 39 20 31  te (list 7 8 9 1
14a0: 30 29 20 32 20 2d 29 29 29 0a 20 20 28 63 68 65  0) 2 -))).  (che
14b0: 63 6b 2d 65 78 70 65 63 74 20 61 20 39 29 0a 20  ck-expect a 9). 
14c0: 20 28 63 68 65 63 6b 2d 65 78 70 65 63 74 20 62   (check-expect b
14d0: 20 28 6c 69 73 74 20 37 20 38 20 2d 39 20 31 30   (list 7 8 -9 10
14e0: 29 29 29 0a 0a 3b 20 6d 61 70 0a 28 63 68 65 63  )))..; map.(chec
14f0: 6b 2d 65 78 70 65 63 74 20 28 6d 61 70 20 63 61  k-expect (map ca
1500: 64 72 20 28 6c 69 73 74 20 28 6c 69 73 74 20 27  dr (list (list '
1510: 61 20 27 62 29 20 28 6c 69 73 74 20 27 64 20 27  a 'b) (list 'd '
1520: 65 29 20 28 6c 69 73 74 20 27 67 20 27 68 29 29  e) (list 'g 'h))
1530: 29 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20  ).              
1540: 28 6c 69 73 74 20 27 62 20 27 65 20 27 68 29 29  (list 'b 'e 'h))
1550: 0a 28 63 68 65 63 6b 2d 65 78 70 65 63 74 20 28  .(check-expect (
1560: 6d 61 70 20 28 6c 61 6d 62 64 61 20 28 6e 29 20  map (lambda (n) 
1570: 28 65 78 70 74 20 6e 20 6e 29 29 0a 20 20 20 20  (expt n n)).    
1580: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 28                 (
1590: 6c 69 73 74 20 31 20 32 20 33 20 34 20 35 29 29  list 1 2 3 4 5))
15a0: 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 28  .              (
15b0: 6c 69 73 74 20 31 20 34 20 32 37 20 32 35 36 20  list 1 4 27 256 
15c0: 33 31 32 35 29 29 0a 28 63 68 65 63 6b 2d 65 78  3125)).(check-ex
15d0: 70 65 63 74 20 28 6d 61 70 20 2b 20 28 6c 69 73  pect (map + (lis
15e0: 74 20 31 20 32 20 33 29 20 28 6c 69 73 74 20 34  t 1 2 3) (list 4
15f0: 20 35 20 36 29 29 0a 20 20 20 20 20 20 20 20 20   5 6)).         
1600: 20 20 20 20 20 28 6c 69 73 74 20 35 20 37 20 39       (list 5 7 9
1610: 29 29 0a 0a 3b 20 66 6f 72 2d 65 61 63 68 0a 28  ))..; for-each.(
1620: 63 68 65 63 6b 2d 65 78 70 65 63 74 20 28 6c 65  check-expect (le
1630: 74 20 28 28 76 20 28 6d 61 6b 65 2d 76 65 63 74  t ((v (make-vect
1640: 6f 72 20 35 29 29 29 0a 20 20 20 20 20 20 20 20  or 5))).        
1650: 20 20 20 20 20 20 20 20 28 66 6f 72 2d 65 61 63          (for-eac
1660: 68 20 28 6c 61 6d 62 64 61 20 28 69 29 0a 20 20  h (lambda (i).  
1670: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
1680: 20 20 20 20 20 20 20 20 20 20 28 76 65 63 74 6f            (vecto
1690: 72 2d 73 65 74 21 20 76 20 69 20 28 2a 20 69 20  r-set! v i (* i 
16a0: 69 29 29 29 0a 20 20 20 20 20 20 20 20 20 20 20  i))).           
16b0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 28                 (
16c0: 6c 69 73 74 20 30 20 31 20 32 20 33 20 34 29 29  list 0 1 2 3 4))
16d0: 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20  .               
16e0: 20 76 29 0a 20 20 20 20 20 20 20 20 20 20 20 20   v).            
16f0: 20 20 27 23 28 30 20 31 20 34 20 39 20 31 36 29    '#(0 1 4 9 16)
1700: 29 0a 0a 3b 20 72 61 6e 64 6f 6d 2d 61 63 63 65  )..; random-acce
1710: 73 73 2d 6c 69 73 74 2d 3e 6c 69 6e 65 61 72 2d  ss-list->linear-
1720: 61 63 63 65 73 73 2d 6c 69 73 74 0a 3b 20 6c 69  access-list.; li
1730: 6e 65 61 72 2d 61 63 63 65 73 73 2d 6c 69 73 74  near-access-list
1740: 2d 3e 72 61 6e 64 6f 6d 2d 61 63 63 65 73 73 2d  ->random-access-
1750: 6c 69 73 74 0a 28 63 68 65 63 6b 2d 65 78 70 65  list.(check-expe
1760: 63 74 20 28 72 61 6e 64 6f 6d 2d 61 63 63 65 73  ct (random-acces
1770: 73 2d 6c 69 73 74 2d 3e 6c 69 6e 65 61 72 2d 61  s-list->linear-a
1780: 63 63 65 73 73 2d 6c 69 73 74 20 27 28 29 29 20  ccess-list '()) 
1790: 27 28 29 29 0a 28 63 68 65 63 6b 2d 65 78 70 65  '()).(check-expe
17a0: 63 74 20 28 6c 69 6e 65 61 72 2d 61 63 63 65 73  ct (linear-acces
17b0: 73 2d 6c 69 73 74 2d 3e 72 61 6e 64 6f 6d 2d 61  s-list->random-a
17c0: 63 63 65 73 73 2d 6c 69 73 74 20 27 28 29 29 20  ccess-list '()) 
17d0: 27 28 29 29 0a 0a 28 63 68 65 63 6b 2d 65 78 70  '())..(check-exp
17e0: 65 63 74 20 28 72 61 6e 64 6f 6d 2d 61 63 63 65  ect (random-acce
17f0: 73 73 2d 6c 69 73 74 2d 3e 6c 69 6e 65 61 72 2d  ss-list->linear-
1800: 61 63 63 65 73 73 2d 6c 69 73 74 20 28 6c 69 73  access-list (lis
1810: 74 20 31 20 32 20 33 29 29 0a 20 20 20 20 20 20  t 1 2 3)).      
1820: 20 20 20 20 20 20 20 20 28 72 36 3a 6c 69 73 74          (r6:list
1830: 20 31 20 32 20 33 29 29 0a 0a 28 63 68 65 63 6b   1 2 3))..(check
1840: 2d 65 78 70 65 63 74 20 28 6c 69 6e 65 61 72 2d  -expect (linear-
1850: 61 63 63 65 73 73 2d 6c 69 73 74 2d 3e 72 61 6e  access-list->ran
1860: 64 6f 6d 2d 61 63 63 65 73 73 2d 6c 69 73 74 20  dom-access-list 
1870: 28 72 36 3a 6c 69 73 74 20 31 20 32 20 33 29 29  (r6:list 1 2 3))
1880: 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 28  .              (
1890: 6c 69 73 74 20 31 20 32 20 33 29 29 0a           list 1 2 3)).