Artifact
ef0ccfe6b0fe9b22150b7832db37ed2a4f544316:
- File
items.scm
— part of check-in
[0a116daff3]
at
2012-04-01 23:29:41
on branch trunk
— Updated copyrights
(user:
mrwellan
size: 5187)
0000: 0a 3b 3b 20 43 6f 70 79 72 69 67 68 74 20 32 30 .;; Copyright 20
0010: 30 36 2d 32 30 31 32 2c 20 4d 61 74 74 68 65 77 06-2012, Matthew
0020: 20 57 65 6c 6c 61 6e 64 2e 0a 3b 3b 20 0a 3b 3b Welland..;; .;;
0030: 20 20 54 68 69 73 20 70 72 6f 67 72 61 6d 20 69 This program i
0040: 73 20 6d 61 64 65 20 61 76 61 69 6c 61 62 6c 65 s made available
0050: 20 75 6e 64 65 72 20 74 68 65 20 47 4e 55 20 47 under the GNU G
0060: 50 4c 20 76 65 72 73 69 6f 6e 20 32 2e 30 20 6f PL version 2.0 o
0070: 72 0a 3b 3b 20 20 67 72 65 61 74 65 72 2e 20 53 r.;; greater. S
0080: 65 65 20 74 68 65 20 61 63 63 6f 6d 70 61 6e 79 ee the accompany
0090: 69 6e 67 20 66 69 6c 65 20 43 4f 50 59 49 4e 47 ing file COPYING
00a0: 20 66 6f 72 20 64 65 74 61 69 6c 73 2e 0a 3b 3b for details..;;
00b0: 20 0a 3b 3b 20 20 54 68 69 73 20 70 72 6f 67 72 .;; This progr
00c0: 61 6d 20 69 73 20 64 69 73 74 72 69 62 75 74 65 am is distribute
00d0: 64 20 57 49 54 48 4f 55 54 20 41 4e 59 20 57 41 d WITHOUT ANY WA
00e0: 52 52 41 4e 54 59 3b 20 77 69 74 68 6f 75 74 20 RRANTY; without
00f0: 65 76 65 6e 20 74 68 65 0a 3b 3b 20 20 69 6d 70 even the.;; imp
0100: 6c 69 65 64 20 77 61 72 72 61 6e 74 79 20 6f 66 lied warranty of
0110: 20 4d 45 52 43 48 41 4e 54 41 42 49 4c 49 54 59 MERCHANTABILITY
0120: 20 6f 72 20 46 49 54 4e 45 53 53 20 46 4f 52 20 or FITNESS FOR
0130: 41 20 50 41 52 54 49 43 55 4c 41 52 0a 3b 3b 20 A PARTICULAR.;;
0140: 20 50 55 52 50 4f 53 45 2e 0a 0a 0a 3b 3b 20 28 PURPOSE....;; (
0150: 64 65 66 69 6e 65 20 69 74 65 6d 64 61 74 20 27 define itemdat '
0160: 28 28 72 69 70 65 6e 65 73 73 20 20 20 20 22 67 ((ripeness "g
0170: 72 65 65 6e 20 72 69 70 65 20 6f 76 65 72 72 69 reen ripe overri
0180: 70 65 22 29 0a 3b 3b 20 09 09 20 20 20 20 20 28 pe").;; .. (
0190: 74 65 6d 70 65 72 61 74 75 72 65 20 22 63 6f 6f temperature "coo
01a0: 6c 20 6d 65 64 69 75 6d 20 68 6f 74 22 29 0a 3b l medium hot").;
01b0: 3b 20 09 09 20 20 20 20 20 28 73 65 61 73 6f 6e ; .. (season
01c0: 20 20 20 20 20 20 22 73 75 6d 6d 65 72 20 77 69 "summer wi
01d0: 6e 74 65 72 20 66 61 6c 6c 20 73 70 72 69 6e 67 nter fall spring
01e0: 22 29 29 29 0a 0a 28 64 65 63 6c 61 72 65 20 28 ")))..(declare (
01f0: 75 6e 69 74 20 69 74 65 6d 73 29 29 0a 28 64 65 unit items)).(de
0200: 63 6c 61 72 65 20 28 75 73 65 73 20 63 6f 6d 6d clare (uses comm
0210: 6f 6e 29 29 0a 0a 28 69 6e 63 6c 75 64 65 20 22 on))..(include "
0220: 63 6f 6d 6d 6f 6e 5f 72 65 63 6f 72 64 73 2e 73 common_records.s
0230: 63 6d 22 29 0a 0a 3b 3b 20 50 75 74 73 20 6f 75 cm")..;; Puts ou
0240: 74 20 61 6c 6c 20 63 6f 6d 62 69 6e 61 74 69 6f t all combinatio
0250: 6e 73 0a 28 64 65 66 69 6e 65 20 28 70 72 6f 63 ns.(define (proc
0260: 65 73 73 2d 69 74 65 6d 6c 69 73 74 20 68 69 65 ess-itemlist hie
0270: 72 64 65 70 74 68 20 63 75 72 72 69 74 65 6d 6b rdepth curritemk
0280: 65 79 20 69 74 65 6d 6c 69 73 74 29 0a 20 20 28 ey itemlist). (
0290: 6c 65 74 20 28 28 72 65 73 20 27 28 29 29 29 0a let ((res '())).
02a0: 20 20 20 20 28 69 66 20 28 6e 6f 74 20 68 69 65 (if (not hie
02b0: 72 64 65 70 74 68 29 0a 09 28 73 65 74 21 20 68 rdepth)..(set! h
02c0: 69 65 72 64 65 70 74 68 20 28 6c 65 6e 67 74 68 ierdepth (length
02d0: 20 69 74 65 6d 6c 69 73 74 29 29 29 0a 20 20 20 itemlist))).
02e0: 20 28 6c 65 74 20 6c 6f 6f 70 20 28 28 68 65 64 (let loop ((hed
02f0: 20 28 63 61 72 20 69 74 65 6d 6c 69 73 74 29 29 (car itemlist))
0300: 0a 09 20 20 20 20 20 20 20 28 74 61 6c 20 28 63 .. (tal (c
0310: 64 72 20 69 74 65 6d 6c 69 73 74 29 29 29 0a 20 dr itemlist))).
0320: 20 20 20 20 20 28 69 66 20 28 6e 75 6c 6c 3f 20 (if (null?
0330: 74 61 6c 29 0a 09 20 20 28 66 6f 72 2d 65 61 63 tal).. (for-eac
0340: 68 20 28 6c 61 6d 62 64 61 20 28 69 74 65 6d 29 h (lambda (item)
0350: 0a 09 09 20 20 20 20 20 20 28 69 66 20 28 3e 20 ... (if (>
0360: 28 6c 65 6e 67 74 68 20 63 75 72 72 69 74 65 6d (length curritem
0370: 6b 65 79 29 20 28 2d 20 68 69 65 72 64 65 70 74 key) (- hierdept
0380: 68 20 32 29 29 0a 09 09 09 20 20 28 73 65 74 21 h 2)).... (set!
0390: 20 72 65 73 20 28 61 70 70 65 6e 64 20 72 65 73 res (append res
03a0: 20 28 6c 69 73 74 20 28 61 70 70 65 6e 64 20 63 (list (append c
03b0: 75 72 72 69 74 65 6d 6b 65 79 20 28 6c 69 73 74 urritemkey (list
03c0: 20 28 6c 69 73 74 20 28 63 61 72 20 68 65 64 29 (list (car hed)
03d0: 20 69 74 65 6d 29 29 29 29 29 29 29 29 0a 09 09 item))))))))...
03e0: 20 20 20 20 28 63 61 64 72 20 68 65 64 29 29 0a (cadr hed)).
03f0: 09 20 20 28 62 65 67 69 6e 0a 09 20 20 20 20 28 . (begin.. (
0400: 66 6f 72 2d 65 61 63 68 20 28 6c 61 6d 62 64 61 for-each (lambda
0410: 20 28 69 74 65 6d 29 0a 09 09 09 28 73 65 74 21 (item)....(set!
0420: 20 72 65 73 20 28 61 70 70 65 6e 64 20 72 65 73 res (append res
0430: 20 28 70 72 6f 63 65 73 73 2d 69 74 65 6d 6c 69 (process-itemli
0440: 73 74 20 68 69 65 72 64 65 70 74 68 20 28 61 70 st hierdepth (ap
0450: 70 65 6e 64 20 63 75 72 72 69 74 65 6d 6b 65 79 pend curritemkey
0460: 20 28 6c 69 73 74 20 28 6c 69 73 74 20 28 63 61 (list (list (ca
0470: 72 20 68 65 64 29 20 69 74 65 6d 29 29 29 20 74 r hed) item))) t
0480: 61 6c 29 29 29 29 0a 09 09 20 20 20 20 20 20 28 al))))... (
0490: 63 61 64 72 20 68 65 64 29 29 0a 09 20 20 20 20 cadr hed))..
04a0: 28 6c 6f 6f 70 20 28 63 61 72 20 74 61 6c 29 28 (loop (car tal)(
04b0: 63 64 72 20 74 61 6c 29 29 29 29 29 0a 20 20 20 cdr tal))))).
04c0: 20 72 65 73 29 29 0a 0a 3b 3b 20 50 75 74 73 20 res))..;; Puts
04d0: 6f 75 74 20 61 6c 6c 20 63 6f 6d 62 69 6e 61 74 out all combinat
04e0: 69 6f 6e 73 0a 28 64 65 66 69 6e 65 20 28 70 72 ions.(define (pr
04f0: 6f 63 65 73 73 2d 69 74 65 6d 6c 69 73 74 20 68 ocess-itemlist h
0500: 69 65 72 64 65 70 74 68 20 63 75 72 72 69 74 65 ierdepth currite
0510: 6d 6b 65 79 20 69 74 65 6d 6c 69 73 74 29 0a 20 mkey itemlist).
0520: 20 28 6c 65 74 20 28 28 72 65 73 20 27 28 29 29 (let ((res '())
0530: 29 0a 20 20 20 20 28 69 66 20 28 6e 6f 74 20 68 ). (if (not h
0540: 69 65 72 64 65 70 74 68 29 0a 09 28 73 65 74 21 ierdepth)..(set!
0550: 20 68 69 65 72 64 65 70 74 68 20 28 6c 65 6e 67 hierdepth (leng
0560: 74 68 20 69 74 65 6d 6c 69 73 74 29 29 29 0a 20 th itemlist))).
0570: 20 20 20 28 6c 65 74 20 6c 6f 6f 70 20 28 28 68 (let loop ((h
0580: 65 64 20 28 63 61 72 20 69 74 65 6d 6c 69 73 74 ed (car itemlist
0590: 29 29 0a 09 20 20 20 20 20 20 20 28 74 61 6c 20 )).. (tal
05a0: 28 63 64 72 20 69 74 65 6d 6c 69 73 74 29 29 29 (cdr itemlist)))
05b0: 0a 20 20 20 20 20 20 28 69 66 20 28 6e 75 6c 6c . (if (null
05c0: 3f 20 74 61 6c 29 0a 09 20 20 28 66 6f 72 2d 65 ? tal).. (for-e
05d0: 61 63 68 20 28 6c 61 6d 62 64 61 20 28 69 74 65 ach (lambda (ite
05e0: 6d 29 0a 09 09 20 20 20 20 20 20 28 69 66 20 28 m)... (if (
05f0: 3e 20 28 6c 65 6e 67 74 68 20 63 75 72 72 69 74 > (length currit
0600: 65 6d 6b 65 79 29 20 28 2d 20 68 69 65 72 64 65 emkey) (- hierde
0610: 70 74 68 20 32 29 29 0a 09 09 09 20 20 28 73 65 pth 2)).... (se
0620: 74 21 20 72 65 73 20 28 61 70 70 65 6e 64 20 72 t! res (append r
0630: 65 73 20 28 6c 69 73 74 20 28 61 70 70 65 6e 64 es (list (append
0640: 20 63 75 72 72 69 74 65 6d 6b 65 79 20 28 6c 69 curritemkey (li
0650: 73 74 20 28 6c 69 73 74 20 28 63 61 72 20 68 65 st (list (car he
0660: 64 29 20 69 74 65 6d 29 29 29 29 29 29 29 29 0a d) item)))))))).
0670: 09 09 20 20 20 20 28 63 61 64 72 20 68 65 64 29 .. (cadr hed)
0680: 29 0a 09 20 20 28 62 65 67 69 6e 0a 09 20 20 20 ).. (begin..
0690: 20 28 66 6f 72 2d 65 61 63 68 20 28 6c 61 6d 62 (for-each (lamb
06a0: 64 61 20 28 69 74 65 6d 29 0a 09 09 09 28 73 65 da (item)....(se
06b0: 74 21 20 72 65 73 20 28 61 70 70 65 6e 64 20 72 t! res (append r
06c0: 65 73 20 28 70 72 6f 63 65 73 73 2d 69 74 65 6d es (process-item
06d0: 6c 69 73 74 20 68 69 65 72 64 65 70 74 68 20 28 list hierdepth (
06e0: 61 70 70 65 6e 64 20 63 75 72 72 69 74 65 6d 6b append curritemk
06f0: 65 79 20 28 6c 69 73 74 20 28 6c 69 73 74 20 28 ey (list (list (
0700: 63 61 72 20 68 65 64 29 20 69 74 65 6d 29 29 29 car hed) item)))
0710: 20 74 61 6c 29 29 29 29 0a 09 09 20 20 20 20 20 tal))))...
0720: 20 28 63 61 64 72 20 68 65 64 29 29 0a 09 20 20 (cadr hed))..
0730: 20 20 28 6c 6f 6f 70 20 28 63 61 72 20 74 61 6c (loop (car tal
0740: 29 28 63 64 72 20 74 61 6c 29 29 29 29 29 0a 20 )(cdr tal))))).
0750: 20 20 20 72 65 73 29 29 0a 0a 3b 3b 20 28 69 74 res))..;; (it
0760: 65 6d 2d 61 73 73 6f 63 2d 3e 69 74 65 6d 2d 6c em-assoc->item-l
0770: 69 73 74 20 27 28 28 22 41 4e 49 4d 41 4c 22 20 ist '(("ANIMAL"
0780: 22 45 6c 65 70 68 61 6e 74 20 4c 69 6f 6e 22 29 "Elephant Lion")
0790: 28 22 53 45 41 53 4f 4e 22 20 22 53 70 72 69 6e ("SEASON" "Sprin
07a0: 67 20 46 61 6c 6c 22 29 29 29 0a 3b 3b 20 20 20 g Fall"))).;;
07b0: 3d 3e 20 28 28 28 22 41 4e 49 4d 41 4c 22 20 22 => ((("ANIMAL" "
07c0: 45 6c 65 70 68 61 6e 74 22 29 20 28 22 53 45 41 Elephant") ("SEA
07d0: 53 4f 4e 22 20 22 53 70 72 69 6e 67 22 29 29 20 SON" "Spring"))
07e0: 0a 3b 3b 20 20 20 20 20 20 20 28 28 22 41 4e 49 .;; (("ANI
07f0: 4d 41 4c 22 20 22 45 6c 65 70 68 61 6e 74 22 29 MAL" "Elephant")
0800: 20 28 22 53 45 41 53 4f 4e 22 20 22 46 61 6c 6c ("SEASON" "Fall
0810: 22 29 29 20 0a 3b 3b 20 20 20 20 20 20 20 28 28 ")) .;; ((
0820: 22 41 4e 49 4d 41 4c 22 20 22 4c 69 6f 6e 22 29 "ANIMAL" "Lion")
0830: 20 20 20 20 20 28 22 53 45 41 53 4f 4e 22 20 22 ("SEASON" "
0840: 53 70 72 69 6e 67 22 29 29 0a 3b 3b 20 20 20 20 Spring")).;;
0850: 20 20 20 28 28 22 41 4e 49 4d 41 4c 22 20 22 4c (("ANIMAL" "L
0860: 69 6f 6e 22 29 20 20 20 20 20 28 22 53 45 41 53 ion") ("SEAS
0870: 4f 4e 22 20 22 46 61 6c 6c 22 29 29 29 0a 28 64 ON" "Fall"))).(d
0880: 65 66 69 6e 65 20 28 69 74 65 6d 2d 61 73 73 6f efine (item-asso
0890: 63 2d 3e 69 74 65 6d 2d 6c 69 73 74 20 69 74 65 c->item-list ite
08a0: 6d 73 64 61 74 29 0a 20 20 28 69 66 20 28 61 6e msdat). (if (an
08b0: 64 20 69 74 65 6d 73 64 61 74 20 28 6e 6f 74 20 d itemsdat (not
08c0: 28 6e 75 6c 6c 3f 20 69 74 65 6d 73 64 61 74 29 (null? itemsdat)
08d0: 29 29 0a 20 20 20 20 20 20 28 6c 65 74 20 28 28 )). (let ((
08e0: 69 74 65 6d 6c 73 74 20 28 66 69 6c 74 65 72 20 itemlst (filter
08f0: 28 6c 61 6d 62 64 61 20 28 78 29 0a 09 09 09 20 (lambda (x)....
0900: 20 20 20 20 20 20 28 6c 69 73 74 3f 20 78 29 29 (list? x))
0910: 0a 09 09 09 20 20 20 20 20 28 6d 61 70 20 28 6c .... (map (l
0920: 61 6d 62 64 61 20 28 78 29 0a 09 09 09 09 20 20 ambda (x).....
0930: 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 36 (debug:print 6
0940: 20 22 69 74 65 6d 2d 61 73 73 6f 63 2d 3e 69 74 "item-assoc->it
0950: 65 6d 2d 6c 69 73 74 20 78 3a 20 22 20 78 29 0a em-list x: " x).
0960: 09 09 09 09 20 20 20 20 28 69 66 20 28 3c 20 28 .... (if (< (
0970: 6c 65 6e 67 74 68 20 78 29 20 32 29 0a 09 09 09 length x) 2)....
0980: 09 09 28 62 65 67 69 6e 0a 09 09 09 09 09 20 20 ..(begin......
0990: 28 64 65 62 75 67 3a 70 72 69 6e 74 20 30 20 22 (debug:print 0 "
09a0: 45 52 52 4f 52 3a 20 6d 61 6c 66 6f 72 6d 65 64 ERROR: malformed
09b0: 20 69 74 65 6d 73 20 73 70 65 63 20 22 20 28 73 items spec " (s
09c0: 74 72 69 6e 67 2d 69 6e 74 65 72 73 70 65 72 73 tring-interspers
09d0: 65 20 78 20 22 20 22 29 29 0a 09 09 09 09 09 20 e x " "))......
09e0: 20 28 6c 69 73 74 20 28 63 61 72 20 78 29 27 28 (list (car x)'(
09f0: 29 29 29 0a 09 09 09 09 09 28 6c 65 74 20 28 28 )))......(let ((
0a00: 6e 61 6d 65 20 28 63 61 72 20 78 29 29 0a 09 09 name (car x))...
0a10: 09 09 09 20 20 20 20 20 20 28 69 74 65 6d 73 20 ... (items
0a20: 28 63 61 64 72 20 78 29 29 29 0a 09 09 09 09 09 (cadr x)))......
0a30: 20 20 28 6c 69 73 74 20 6e 61 6d 65 20 28 73 74 (list name (st
0a40: 72 69 6e 67 2d 73 70 6c 69 74 20 69 74 65 6d 73 ring-split items
0a50: 29 29 29 29 29 0a 09 09 09 09 20 20 69 74 65 6d )))))..... item
0a60: 73 64 61 74 29 29 29 29 0a 09 28 6c 65 74 20 28 sdat))))..(let (
0a70: 28 64 65 62 75 67 6c 65 76 65 6c 20 35 29 29 0a (debuglevel 5)).
0a80: 09 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 . (debug:print
0a90: 35 20 22 69 74 65 6d 2d 61 73 73 6f 63 2d 3e 69 5 "item-assoc->i
0aa0: 74 65 6d 2d 6c 69 73 74 3a 20 69 74 65 6d 73 64 tem-list: itemsd
0ab0: 61 74 20 3d 3e 20 69 74 65 6d 6c 73 74 20 22 29 at => itemlst ")
0ac0: 0a 09 20 20 28 69 66 20 28 3e 3d 20 2a 76 65 72 .. (if (>= *ver
0ad0: 62 6f 73 69 74 79 2a 20 35 29 0a 09 20 20 20 20 bosity* 5)..
0ae0: 20 20 28 62 65 67 69 6e 0a 09 09 28 70 70 20 69 (begin...(pp i
0af0: 74 65 6d 73 64 61 74 29 0a 09 09 28 70 72 69 6e temsdat)...(prin
0b00: 74 20 22 20 3d 3e 20 22 29 0a 09 09 28 70 70 20 t " => ")...(pp
0b10: 69 74 65 6d 6c 73 74 29 29 29 29 0a 09 28 69 66 itemlst))))..(if
0b20: 20 28 3e 20 28 6c 65 6e 67 74 68 20 69 74 65 6d (> (length item
0b30: 6c 73 74 29 20 30 29 0a 09 20 20 20 20 28 70 72 lst) 0).. (pr
0b40: 6f 63 65 73 73 2d 69 74 65 6d 6c 69 73 74 20 23 ocess-itemlist #
0b50: 66 20 27 28 29 20 69 74 65 6d 6c 73 74 29 0a 09 f '() itemlst)..
0b60: 20 20 20 20 27 28 29 29 29 0a 20 20 20 20 20 20 '())).
0b70: 27 28 29 29 29 20 3b 3b 20 72 65 74 75 72 6e 20 '())) ;; return
0b80: 61 20 6c 69 73 74 20 63 6f 6e 73 69 73 74 69 6e a list consistin
0b90: 67 20 6f 6e 20 61 20 73 69 6e 67 6c 65 20 6e 75 g on a single nu
0ba0: 6c 6c 20 6c 69 73 74 20 66 6f 72 20 6e 6f 6e 2d ll list for non-
0bb0: 69 74 65 6d 20 72 75 6e 73 0a 20 20 20 20 20 20 item runs.
0bc0: 20 20 20 20 20 20 3b 3b 20 4e 6f 70 65 2c 20 6e ;; Nope, n
0bd0: 6f 74 20 6e 6f 77 2c 20 72 65 74 75 72 6e 20 6e ot now, return n
0be0: 75 6c 6c 20 61 73 20 6f 66 20 36 2f 36 2f 32 30 ull as of 6/6/20
0bf0: 31 31 0a 0a 3b 3b 20 28 69 74 65 6d 2d 74 61 62 11..;; (item-tab
0c00: 6c 65 2d 3e 69 74 65 6d 2d 6c 69 73 74 20 27 28 le->item-list '(
0c10: 28 22 41 4e 49 4d 41 4c 22 20 22 45 6c 65 70 68 ("ANIMAL" "Eleph
0c20: 61 6e 74 20 4c 69 6f 6e 22 29 28 22 53 45 41 53 ant Lion")("SEAS
0c30: 4f 4e 22 20 22 53 70 72 69 6e 67 20 57 69 6e 74 ON" "Spring Wint
0c40: 65 72 22 29 29 29 0a 3b 3b 20 20 20 3d 3e 20 28 er"))).;; => (
0c50: 28 28 22 41 4e 49 4d 41 4c 22 20 22 45 6c 65 70 (("ANIMAL" "Elep
0c60: 68 61 6e 74 22 29 28 22 53 45 41 53 4f 4e 22 20 hant")("SEASON"
0c70: 22 53 70 72 69 6e 67 22 29 29 0a 3b 3b 20 20 20 "Spring")).;;
0c80: 20 20 20 20 28 28 22 41 4e 49 4d 41 4c 22 20 22 (("ANIMAL" "
0c90: 4c 69 6f 6e 22 29 20 20 20 20 28 22 53 45 41 53 Lion") ("SEAS
0ca0: 4f 4e 22 20 22 57 69 6e 74 65 72 22 29 29 29 0a ON" "Winter"))).
0cb0: 28 64 65 66 69 6e 65 20 28 69 74 65 6d 2d 74 61 (define (item-ta
0cc0: 62 6c 65 2d 3e 69 74 65 6d 2d 6c 69 73 74 20 69 ble->item-list i
0cd0: 74 65 6d 74 61 62 6c 65 29 0a 20 20 28 6c 65 74 temtable). (let
0ce0: 20 28 28 6e 65 77 6c 73 74 20 28 6d 61 70 20 28 ((newlst (map (
0cf0: 6c 61 6d 62 64 61 20 28 78 29 0a 09 09 20 20 20 lambda (x)...
0d00: 20 20 20 20 28 69 66 20 28 3e 20 28 6c 65 6e 67 (if (> (leng
0d10: 74 68 20 78 29 20 31 29 0a 09 09 09 20 20 20 28 th x) 1).... (
0d20: 6c 69 73 74 20 28 63 61 72 20 78 29 0a 09 09 09 list (car x)....
0d30: 09 20 28 73 74 72 69 6e 67 2d 73 70 6c 69 74 20 . (string-split
0d40: 28 63 61 64 72 20 78 29 29 29 0a 09 09 09 20 20 (cadr x)))....
0d50: 20 28 6c 69 73 74 20 78 20 27 28 29 29 29 29 0a (list x '()))).
0d60: 09 09 20 20 20 20 20 69 74 65 6d 74 61 62 6c 65 .. itemtable
0d70: 29 29 0a 09 28 72 65 73 20 20 20 20 20 27 28 29 ))..(res '()
0d80: 29 29 20 3b 3b 20 61 20 6c 69 73 74 20 6f 66 20 )) ;; a list of
0d90: 69 74 65 6d 73 0a 20 20 20 20 28 6c 65 74 20 6c items. (let l
0da0: 6f 6f 70 20 28 28 69 6e 64 78 20 20 20 20 30 29 oop ((indx 0)
0db0: 0a 09 20 20 20 20 20 20 20 28 69 74 65 6d 20 20 .. (item
0dc0: 20 27 28 29 29 20 3b 3b 20 61 6e 20 69 74 65 6d '()) ;; an item
0dd0: 20 77 69 6c 6c 20 62 65 20 28 28 4b 45 59 4e 41 will be ((KEYNA
0de0: 4d 45 31 20 56 41 4c 31 29 28 4b 45 59 4e 41 4d ME1 VAL1)(KEYNAM
0df0: 45 32 20 56 41 4c 32 29 20 2e 2e 2e 29 0a 09 20 E2 VAL2) ...)..
0e00: 20 20 20 20 20 20 28 65 6c 66 6c 61 67 20 20 23 (elflag #
0e10: 66 29 29 0a 20 20 20 20 20 20 28 66 6f 72 2d 65 f)). (for-e
0e20: 61 63 68 20 28 6c 61 6d 62 64 61 20 28 72 6f 77 ach (lambda (row
0e30: 29 0a 09 09 20 20 28 6c 65 74 20 28 28 72 6f 77 )... (let ((row
0e40: 6e 61 6d 65 20 28 63 61 72 20 72 6f 77 29 29 0a name (car row)).
0e50: 09 09 09 28 72 6f 77 64 61 74 20 20 28 63 61 64 ...(rowdat (cad
0e60: 72 20 72 6f 77 29 29 29 0a 09 09 20 20 20 20 28 r row)))... (
0e70: 73 65 74 21 20 69 74 65 6d 20 28 61 70 70 65 6e set! item (appen
0e80: 64 20 69 74 65 6d 20 0a 09 09 09 09 20 20 20 20 d item .....
0e90: 20 20 20 28 6c 69 73 74 20 0a 09 09 09 09 09 28 (list ......(
0ea0: 69 66 20 28 3c 20 69 6e 64 78 20 28 6c 65 6e 67 if (< indx (leng
0eb0: 74 68 20 72 6f 77 64 61 74 29 29 0a 09 09 09 09 th rowdat)).....
0ec0: 09 20 20 20 20 28 6c 65 74 20 28 28 6e 65 77 20 . (let ((new
0ed0: 28 6c 69 73 74 20 72 6f 77 6e 61 6d 65 20 28 6c (list rowname (l
0ee0: 69 73 74 2d 72 65 66 20 72 6f 77 64 61 74 20 69 ist-ref rowdat i
0ef0: 6e 64 78 29 29 29 29 0a 09 09 09 09 09 20 20 20 ndx))))......
0f00: 20 20 20 3b 3b 20 28 64 65 62 75 67 3a 70 72 69 ;; (debug:pri
0f10: 6e 74 20 30 20 22 4e 65 77 3a 20 22 20 6e 65 77 nt 0 "New: " new
0f20: 29 0a 09 09 09 09 09 20 20 20 20 20 20 28 73 65 )...... (se
0f30: 74 21 20 65 6c 66 6c 61 67 20 23 74 29 0a 09 09 t! elflag #t)...
0f40: 09 09 09 20 20 20 20 20 20 6e 65 77 0a 09 09 09 ... new....
0f50: 09 09 20 20 20 20 20 20 29 20 3b 3b 20 69 2e 65 .. ) ;; i.e
0f60: 2e 20 68 61 64 20 61 74 20 6c 65 61 73 74 20 6f . had at least o
0f70: 6e 20 6c 65 67 69 74 20 76 61 6c 75 65 20 74 6f n legit value to
0f80: 20 75 73 65 0a 09 09 09 09 09 20 20 20 20 28 6c use...... (l
0f90: 69 73 74 20 72 6f 77 6e 61 6d 65 20 22 2d 22 29 ist rowname "-")
0fa0: 29 29 29 29 29 29 0a 09 09 6e 65 77 6c 73 74 29 ))))))...newlst)
0fb0: 0a 20 20 20 20 20 20 28 69 66 20 65 6c 66 6c 61 . (if elfla
0fc0: 67 0a 09 20 20 28 62 65 67 69 6e 0a 09 20 20 20 g.. (begin..
0fd0: 20 28 73 65 74 21 20 72 65 73 20 28 61 70 70 65 (set! res (appe
0fe0: 6e 64 20 72 65 73 20 28 6c 69 73 74 20 69 74 65 nd res (list ite
0ff0: 6d 29 29 29 0a 09 20 20 20 20 28 6c 6f 6f 70 20 m))).. (loop
1000: 28 2b 20 69 6e 64 78 20 31 29 0a 09 09 20 20 27 (+ indx 1)... '
1010: 28 29 0a 09 09 20 20 23 66 29 29 29 0a 20 20 20 ()... #f))).
1020: 20 20 20 72 65 73 29 29 29 0a 20 20 20 20 20 20 res))).
1030: 20 20 20 20 20 20 3b 3b 20 4e 6f 70 65 2c 20 6e ;; Nope, n
1040: 6f 74 20 6e 6f 77 2c 20 72 65 74 75 72 6e 20 6e ot now, return n
1050: 75 6c 6c 20 61 73 20 6f 66 20 36 2f 36 2f 32 30 ull as of 6/6/20
1060: 31 31 0a 09 09 0a 28 64 65 66 69 6e 65 20 28 63 11....(define (c
1070: 68 65 63 6b 2d 76 61 6c 69 64 2d 69 74 65 6d 73 heck-valid-items
1080: 20 63 6c 61 73 73 20 69 74 65 6d 29 0a 20 20 28 class item). (
1090: 6c 65 74 20 28 28 76 61 6c 69 64 2d 76 61 6c 75 let ((valid-valu
10a0: 65 73 20 28 6c 65 74 20 28 28 73 20 28 63 6f 6e es (let ((s (con
10b0: 66 69 67 2d 6c 6f 6f 6b 75 70 20 2a 63 6f 6e 66 fig-lookup *conf
10c0: 69 67 64 61 74 2a 20 22 76 61 6c 69 64 76 61 6c igdat* "validval
10d0: 75 65 73 22 20 63 6c 61 73 73 29 29 29 0a 09 09 ues" class)))...
10e0: 09 28 69 66 20 73 20 28 73 74 72 69 6e 67 2d 73 .(if s (string-s
10f0: 70 6c 69 74 20 73 29 20 23 66 29 29 29 29 0a 20 plit s) #f)))).
1100: 20 20 20 28 69 66 20 76 61 6c 69 64 2d 76 61 6c (if valid-val
1110: 75 65 73 0a 09 28 69 66 20 28 6d 65 6d 62 65 72 ues..(if (member
1120: 20 69 74 65 6d 20 76 61 6c 69 64 2d 76 61 6c 75 item valid-valu
1130: 65 73 29 0a 09 20 20 20 20 69 74 65 6d 20 23 66 es).. item #f
1140: 29 0a 09 69 74 65 6d 29 29 29 0a 0a 28 64 65 66 )..item)))..(def
1150: 69 6e 65 20 28 69 74 65 6d 73 3a 67 65 74 2d 69 ine (items:get-i
1160: 74 65 6d 73 2d 66 72 6f 6d 2d 63 6f 6e 66 69 67 tems-from-config
1170: 20 74 63 6f 6e 66 69 67 29 0a 20 20 28 6c 65 74 tconfig). (let
1180: 2a 20 28 3b 3b 20 64 62 20 69 73 20 61 6c 77 61 * (;; db is alwa
1190: 79 73 20 61 74 20 2a 74 6f 70 70 61 74 68 2a 2f ys at *toppath*/
11a0: 64 62 2f 6d 65 67 61 74 65 73 74 2e 64 62 0a 09 db/megatest.db..
11b0: 20 28 69 74 65 6d 73 20 20 20 20 20 20 20 28 68 (items (h
11c0: 61 73 68 2d 74 61 62 6c 65 2d 72 65 66 2f 64 65 ash-table-ref/de
11d0: 66 61 75 6c 74 20 74 63 6f 6e 66 69 67 20 22 69 fault tconfig "i
11e0: 74 65 6d 73 22 20 27 28 29 29 29 0a 09 20 28 69 tems" '())).. (i
11f0: 74 65 6d 73 74 61 62 6c 65 20 20 28 68 61 73 68 temstable (hash
1200: 2d 74 61 62 6c 65 2d 72 65 66 2f 64 65 66 61 75 -table-ref/defau
1210: 6c 74 20 74 63 6f 6e 66 69 67 20 22 69 74 65 6d lt tconfig "item
1220: 73 74 61 62 6c 65 22 20 27 28 29 29 29 29 0a 20 stable" '()))).
1230: 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 (debug:print
1240: 35 20 22 69 74 65 6d 73 3a 20 22 20 69 74 65 6d 5 "items: " item
1250: 73 20 22 20 69 74 65 6d 73 74 61 62 6c 65 3a 20 s " itemstable:
1260: 22 20 69 74 65 6d 73 74 61 62 6c 65 29 0a 20 20 " itemstable).
1270: 20 20 28 73 65 74 21 20 69 74 65 6d 73 20 28 6d (set! items (m
1280: 61 70 20 28 6c 61 6d 62 64 61 20 28 69 74 65 6d ap (lambda (item
1290: 29 0a 09 09 20 20 20 20 20 20 20 28 69 66 20 28 )... (if (
12a0: 70 72 6f 63 65 64 75 72 65 3f 20 28 63 61 64 72 procedure? (cadr
12b0: 20 69 74 65 6d 29 29 0a 09 09 09 20 20 20 28 6c item)).... (l
12c0: 69 73 74 20 28 63 61 72 20 69 74 65 6d 29 28 28 ist (car item)((
12d0: 63 61 64 72 20 69 74 65 6d 29 29 29 0a 09 09 09 cadr item)))....
12e0: 20 20 20 69 74 65 6d 29 29 0a 09 09 20 20 20 20 item))...
12f0: 20 69 74 65 6d 73 29 29 0a 20 20 20 20 28 73 65 items)). (se
1300: 74 21 20 69 74 65 6d 73 74 61 62 6c 65 20 28 6d t! itemstable (m
1310: 61 70 20 28 6c 61 6d 62 64 61 20 28 69 74 65 6d ap (lambda (item
1320: 29 0a 09 09 09 20 20 20 20 28 69 66 20 28 70 72 ).... (if (pr
1330: 6f 63 65 64 75 72 65 3f 20 28 63 61 64 72 20 69 ocedure? (cadr i
1340: 74 65 6d 29 29 0a 09 09 09 09 28 6c 69 73 74 20 tem)).....(list
1350: 28 63 61 72 20 69 74 65 6d 29 28 28 63 61 64 72 (car item)((cadr
1360: 20 69 74 65 6d 29 29 29 0a 09 09 09 09 69 74 65 item))).....ite
1370: 6d 29 29 0a 09 09 09 20 20 69 74 65 6d 73 74 61 m)).... itemsta
1380: 62 6c 65 29 29 0a 20 20 20 20 28 69 66 20 28 6f ble)). (if (o
1390: 72 20 28 6e 6f 74 20 28 6e 75 6c 6c 3f 20 69 74 r (not (null? it
13a0: 65 6d 73 29 29 28 6e 6f 74 20 28 6e 75 6c 6c 3f ems))(not (null?
13b0: 20 69 74 65 6d 73 74 61 62 6c 65 29 29 29 0a 09 itemstable)))..
13c0: 28 61 70 70 65 6e 64 20 28 69 74 65 6d 2d 61 73 (append (item-as
13d0: 73 6f 63 2d 3e 69 74 65 6d 2d 6c 69 73 74 20 69 soc->item-list i
13e0: 74 65 6d 73 29 0a 09 09 28 69 74 65 6d 2d 74 61 tems)...(item-ta
13f0: 62 6c 65 2d 3e 69 74 65 6d 2d 6c 69 73 74 20 69 ble->item-list i
1400: 74 65 6d 73 74 61 62 6c 65 29 29 0a 09 27 28 28 temstable))..'((
1410: 29 29 29 29 29 0a 0a 3b 3b 20 28 70 70 20 28 69 )))))..;; (pp (i
1420: 74 65 6d 2d 61 73 73 6f 63 2d 3e 69 74 65 6d 2d tem-assoc->item-
1430: 6c 69 73 74 20 69 74 65 6d 64 61 74 29 29 0a 0a list itemdat))..
1440: 0a 09 0a ...