1 ;;;; fret-diagrams.scm --
3 ;;;; source file of the GNU LilyPond music typesetter
5 ;;;; (c) 2004--2006 Carl D. Sorensen <c_sorensen@byu.edu>
7 (define (fret-parse-marking-list marking-list fret-count)
8 (let* ((fret-range (list 1 fret-count))
13 (let parse-item ((mylist marking-list))
14 (if (not (null? mylist))
15 (let* ((my-item (car mylist)) (my-code (car my-item)))
17 ((or (eq? my-code 'open)(eq? my-code 'mute))
18 (set! xo-list (cons* my-item xo-list)))
20 (set! barre-list (cons* (cdr my-item) barre-list)))
21 ((eq? my-code 'place-fret)
22 (set! dot-list (cons* (cdr my-item) dot-list))))
23 (parse-item (cdr mylist)))))
25 ;; calculate fret-range
26 (let ((maxfret 0) (minfret 99))
27 (let updatemax ((fret-list dot-list))
30 (let ((fretval (second (car fret-list))))
31 (if (> fretval maxfret) (set! maxfret fretval))
32 (if (< fretval minfret) (set! minfret fretval))
33 (updatemax (cdr fret-list)))))
34 (if (> maxfret fret-count)
35 (set! fret-range (list minfret
36 (let ((upfret (- (+ minfret fret-count) 1)))
37 (if (> maxfret upfret) maxfret upfret)))))
38 ; subtract fret from dots
39 (set! dot-list (subtract-base-fret (- (car fret-range) 1) dot-list)))
40 (acons 'fret-range fret-range
41 (acons 'barre-list barre-list
42 (acons 'dot-list dot-list
43 (acons 'xo-list xo-list '()))))))
47 (define (subtract-base-fret base-fret dot-list)
48 "Subtract @var{base-fret} from every fret in @var{dot-list}"
51 (let ((this-list (car dot-list)))
52 (cons* (list (car this-list) (- (second this-list) base-fret) (if (null? (cddr this-list))
55 (subtract-base-fret base-fret (cdr dot-list))))))
57 (define (sans-serif-stencil layout props mag text)
58 "create a stencil in sans-serif font based on @var{layout} and @var{props}
59 with magnification @varr{mag} of the string @var{text}."
60 (let* ((my-props (prepend-alist-chain 'font-size (stepmag mag)
61 (prepend-alist-chain 'font-family 'sans props))))
62 (interpret-markup layout my-props text)))
65 (define (draw-strings string-count fret-range th size)
66 "Draw the strings (vertical lines) for a fret diagram with
67 @var{string-count} strings and frets as indicated in @var{fret-range}.
68 Line thickness is given by @var{th}, fret & string spacing by
70 (let* ((fret-count (+ (- (cadr fret-range) (car fret-range)) 1))
71 (sl (* (+ fret-count 1) size))
73 (half-thickness (* sth 0.5))
75 (string-stencil (ly:make-stencil (list 'draw-line sth 0 0 0 sl)
76 (cons (- half-thickness) half-thickness)
77 (cons (- half-thickness) (+ sl half-thickness)))))
78 (if (= string-count 1)
80 (ly:stencil-combine-at-edge
81 (draw-strings (- string-count 1) fret-range th size) X RIGHT
85 (define (draw-fret-lines fret-count string-count th size)
86 "Draw @var{fret-count} frets (horizontal lines) for a fret diagram
87 with @var{string-count} strings. Line thickness is given by @var{th},
88 fret & string spacing by @var{size}. "
89 (let* ((fret-length (* (- string-count 1) size))
91 (half-thickness (* sth 0.5))
93 (fret-line (ly:make-stencil (list 'draw-line sth half-thickness size (- fret-length half-thickness) size)
95 (cons (- size half-thickness) (+ size half-thickness)))))
98 (ly:stencil-combine-at-edge fret-line Y UP
99 (draw-fret-lines (- fret-count 1) string-count th size)
102 (define (draw-thick-top-fret props string-count th size)
103 "Draw a thick top fret for a fret diagram whose base fret is not 1."
104 (let* ((sth (* th size))
105 ; (top-fret-thick (* sth (chain-assoc-get 'top-fret-thickness props 3.0)))
106 (top-fret-thick (* sth 3.0))
107 ; (top-half-thick (* top-fret-thick 0.5))
108 (half-thick (* sth 0.5))
110 (x2 (+ half-thick (* size (- string-count 1))))
112 (y2 (+ top-fret-thick half-thick))
113 (x-extent (cons (- x1) x2))
114 (y-extent (cons 0 y2)))
115 (ly:make-stencil (list 'round-filled-box x1 x2 y1 y2 sth)
119 (define (draw-frets layout props fret-range string-count th size)
120 "Draw the frets (horizontal lines) for a fret diagram with
121 @var{string-count} strings and frets as indicated in @var{fret-range}.
122 Line thickness is given by @var{th}, fret & string spacing by
124 (let* ((fret-count (+ (- (cadr fret-range) (car fret-range)) 1))
125 (fret-length (* (- string-count 1) size))
126 (half-thickness (* th 0.5))
127 (base-fret (car fret-range)))
128 (ly:stencil-combine-at-edge
129 (draw-fret-lines fret-count string-count th size) Y UP
131 (draw-thick-top-fret props string-count th size)
132 (draw-fret-lines 1 string-count th size))
136 (define (draw-dots layout props string-count fret-range size finger-code
137 dot-position dot-radius dot-thickness dot-list)
138 "Make dots for fret diagram."
140 (let* ((scale-dot-radius (* size dot-radius))
141 (scale-dot-thick (* size dot-thickness))
142 (dot-color (chain-assoc-get 'dot-color props 'black))
143 ; (finger-xoffset (chain-assoc-get 'finger-xoffset props -0.25))
144 ; (finger-yoffset (chain-assoc-get 'finger-yoffset props (- size)))
145 (finger-xoffset -0.25)
146 (finger-yoffset (- (* size 0.5)))
147 ; (dot-label-font-mag (* scale-dot-radius (chain-assoc-get 'dot-label-font-mag props 1.0)))
148 (dot-label-font-mag scale-dot-radius)
149 ; (string-label-font-mag (* size (chain-assoc-get 'label-font-mag props 0.7)))
150 (string-label-font-mag (* size 0.6))
151 (fret-count (+ (- (cadr fret-range) (car fret-range) 1)))
152 (mypair (car dot-list))
153 (restlist (cdr dot-list))
154 (xpos (* size (- string-count (car mypair))))
155 ;TODO -- figure out what 4 is and get rid of it
157 (ypos (* size (+ 4 (- fret-count (cadr mypair) dot-position ))))
158 (extent (cons (- scale-dot-radius) scale-dot-radius))
159 (finger (caddr mypair))
160 (finger (if (number? finger) (number->string finger) finger))
161 (dotstencil (if (eq? dot-color 'white)
163 (make-circle-stencil scale-dot-radius scale-dot-thick #t)
166 (- scale-dot-radius (* 0.5 scale-dot-thick)) 0 #t)
168 (make-circle-stencil scale-dot-radius scale-dot-thick #t)))
169 (positioned-dot (begin
170 ;(display dotstencil)
171 (ly:stencil-translate-axis
172 (ly:stencil-translate-axis dotstencil xpos X)
176 (if (or (eq? finger '())(eq? finger-code 'none))
178 (if (eq? finger-code 'in-dot)
179 (let* ((finger-label (centered-stencil
180 (sans-serif-stencil layout props
181 dot-label-font-mag finger))))
182 (ly:stencil-translate-axis
183 (ly:stencil-translate-axis
186 (if (eq? dot-color 'white)
188 (ly:stencil-in-color finger-label 1 1 1)))
191 (if (eq? finger-code 'below-string)
194 (ly:stencil-translate-axis
195 (ly:stencil-translate-axis
196 (centered-stencil (sans-serif-stencil layout props
197 string-label-font-mag finger))
199 (* size finger-yoffset) Y))
205 (draw-dots layout props string-count fret-range size finger-code
206 dot-position dot-radius dot-thickness restlist)
207 labeled-dot-stencil))))
209 (define (draw-xo layout props string-count fret-range size xo-list)
210 "Put open and mute string indications on diagram, as contained in @var{xo-list}."
211 (let* ((fret-count (+ (- (cadr fret-range) (car fret-range) 1)))
212 ; (xo-font-mag (* size (chain-assoc-get 'xo-font-magnification props 0.5)))
213 (xo-font-mag (* size 0.5))
214 ; (xo-horizontal-offset (* size (chain-assoc-get 'xo-horizontal-offset props -0.35)))
215 (xo-horizontal-offset (* size -0.35))
216 (mypair (car xo-list))
217 (restlist (cdr xo-list))
218 (glyph-string (if (eq? (car mypair) 'mute) "X" "O"))
219 (xpos (+ (* (- string-count (cadr mypair)) size) xo-horizontal-offset ))
220 (glyph-stencil (ly:stencil-translate-axis
221 (sans-serif-stencil layout props (* size xo-font-mag) glyph-string) xpos X)))
225 (draw-xo layout props string-count fret-range size restlist)
228 (define (make-bezier-sandwich-list left right bottom height thickness)
229 " Make the argument list for a horizontal bezier sandwich from
230 @var{left} to @var{right} with a bottom at @var{bottom}, a height of
231 @var{height}, and a thickness of @var{thickness}."
232 (let* ((width (+ (- right left) 1))
233 (x1 (+ (* width thickness) left))
234 (x2 (- right (* width thickness)))
235 (bottom-control-point-height (+ bottom (- height thickness)))
236 (top-control-point-height (+ bottom height)))
237 ; order of points is: left cp low, right cp low, right end low, left end low
238 ; right cp high, left cp high, left end high, right end high.
239 (list (cons x1 bottom-control-point-height) (cons x2 bottom-control-point-height) (cons right bottom) (cons left bottom)
240 (cons x2 top-control-point-height) (cons x1 top-control-point-height) (cons left bottom) (cons right bottom))))
242 (define (draw-barre layout props string-count fret-range size finger-code dot-position dot-radius barre-list)
243 "Create barre indications for a fret diagram"
244 (if (not (null? barre-list))
245 (let* ((string1 (caar barre-list))
246 (string2 (cadar barre-list))
247 (fret (caddar barre-list))
248 (barre-type (chain-assoc-get 'barre-type props 'curved))
249 (scale-dot-radius (* size dot-radius))
250 (barre-vertical-offset (chain-assoc-get 'barre-vertical-offset props 0.5))
251 ;; 2 is 1 for empty fret at bottom of figure + 1 for interval (top-fret - fret + 1) -- not an arbitrary constant
252 (dot-center-y (* size
253 (- (+ 2 (- (cadr fret-range) fret)) dot-position)))
254 (bottom (+ dot-center-y (* barre-vertical-offset scale-dot-radius)))
255 (left (* size (- string-count string1)))
256 (right (* size (- string-count string2)))
257 ;; (bezier-thick (chain-assoc-get 'bezier-thickness props 0.1))
259 ;; (bezier-height (chain-assoc-get 'bezier-height props 0.5))
261 (bezier-list (make-bezier-sandwich-list left right bottom (* size bezier-height) (* size bezier-thick)))
262 (barre-stencil (if (eq? barre-type 'straight)
263 (ly:make-stencil (list 'draw-line (* size dot-radius) left dot-center-y right dot-center-y)
265 (cons (- dot-center-y scale-dot-radius) (+ dot-center-y scale-dot-radius)))
266 (ly:make-stencil (list 'bezier-sandwich `(quote ,bezier-list) (* size bezier-thick))
268 (cons bottom (+ bottom (* size bezier-height)))))))
269 (if (not (null? (cdr barre-list)))
270 (ly:stencil-add barre-stencil
271 (draw-barre layout props string-count fret-range size finger-code
272 dot-position dot-radius (cdr barre-list)))
275 (define (stepmag mag)
276 "Calculate the font step necessary to get a desired magnification"
277 (* 6 (/ (log mag) (log 2))))
279 (define (label-fret layout props string-count fret-range size)
280 "Label the base fret on a fret diagram"
281 (let* ((base-fret (car fret-range))
282 ; (label-font-mag (chain-assoc-get 'label-font-mag props 0.7))
284 ; (label-vertical-offset (chain-assoc-get 'fret-label-vertical-offset props -0.2))
285 (label-vertical-offset -0.2)
286 (number-type (chain-assoc-get 'number-type props 'roman-lower))
287 (fret-count (+ (- (cadr fret-range) (car fret-range)) 1))
290 ((equal? number-type 'roman-lower) (format #f "~(~:@r~)" base-fret))
291 ((equal? number-type 'roman-upper) (format #f "~:@r" base-fret))
292 ((equal? 'arabic number-type) (format #f "~d" base-fret))
293 (else (format #f "~(~:@r~)" base-fret)))))
294 (ly:stencil-translate-axis
295 (sans-serif-stencil layout props (* size label-font-mag) label-text)
296 (* size (+ fret-count label-vertical-offset)) Y)))
298 (define-builtin-markup-command (fret-diagram-verbose layout props marking-list)
300 "Make a fret diagram containing the symbols indicated in @var{marking-list}
305 \\markup \\fret-diagram-verbose #'((mute 6) (mute 5) (open 4)
306 (place-fret 3 2) (place-fret 2 3) (place-fret 1 2))
309 will produce a standard D chord diagram without fingering indications.
311 Possible elements in @var{marking-list}:
313 @item (mute string-number)
314 Place a small 'x' at the top of string @var{string-number}
316 @item (open string-number)
317 Place a small 'o' at the top of string @var{string-number}
319 @item (barre start-string end-string fret-number)
320 Place a barre indicator (much like a tie) from string @var{start-string}to string @var{end-string} at fret @var{fret-number}
322 @item (place-fret string-number fret-number finger-value)
324 Place a fret playing indication on string @var{string-number} at fret
325 @var{fret-number} with an optional fingering label @var{finger-value}.
326 By default, the fret playing indicator is a solid dot. This can be
327 changed by setting the value of the variable @var{dot-color}. If the
328 @var{finger} part of the place-fret element is present,
329 @var{finger-value} will be displayed according to the setting of the
330 variable @var{finger-code}. There is no limit to the number of fret
331 indications per string.
338 (make-fret-diagram layout props marking-list))
340 (define (make-fret-diagram layout props marking-list)
341 " Make a fret diagram markup"
343 ; note: here we get items from props that are needed in this routine, or that are needed in more than one
344 ; of the procedures called from this routine. If they're only used in one of the sub-procedure, they're
345 ; obtained in that procedure
347 (size (chain-assoc-get 'size props 1.0)) ; needed for everything
348 ;TODO -- get string-count directly from length of stringTunings; requires FretDiagram engraver, which is not yet available
349 ;TODO -- adjust padding for fret label? it appears to be too close to dots
350 (string-count (chain-assoc-get 'string-count props 6)) ; needed for everything
351 (fret-count (chain-assoc-get 'fret-count props 4)) ; needed for everything
352 (finger-code (chain-assoc-get 'finger-code props 'none)) ; needed for both draw-dots and draw-barre
353 (default-dot-radius (if (eq? finger-code 'in-dot) 0.425 0.25)) ; bigger dots if labeled
354 (default-dot-position (if (eq? finger-code 'in-dot) (- 0.95 default-dot-radius) 0.6)) ; move up to make room for bigger if labeled
355 (dot-radius (chain-assoc-get 'dot-radius props default-dot-radius)) ; needed for both draw-dots and draw-barre
356 (dot-position (chain-assoc-get 'dot-position props default-dot-position)) ; needed for both draw-dots and draw-barre
357 (th (* (ly:output-def-lookup layout 'line-thickness)
358 (chain-assoc-get 'thickness props 0.5))) ; needed for both draw-frets and draw-strings
360 (alignment (chain-assoc-get 'align-dir props -0.4)) ; needed only here
361 ; (xo-padding (* th (chain-assoc-get 'padding props 2))) ; needed only here
362 (label-space (* 0.25 size))
363 (xo-padding (* th size 5))
364 (label-dir (chain-assoc-get 'label-dir props RIGHT))
365 (parameters (fret-parse-marking-list marking-list fret-count))
366 (dot-list (cdr (assoc 'dot-list parameters)))
367 (xo-list (cdr (assoc 'xo-list parameters)))
368 (fret-range (cdr (assoc 'fret-range parameters)))
369 (barre-list (cdr (assoc 'barre-list parameters)))
370 (fret-diagram-stencil (ly:stencil-add
371 (draw-strings string-count fret-range th size)
372 (draw-frets layout props fret-range string-count th size))))
373 (if (not (null? barre-list))
374 (set! fret-diagram-stencil (ly:stencil-add
375 (draw-barre layout props string-count fret-range size finger-code
376 dot-position dot-radius barre-list)
377 fret-diagram-stencil)))
378 (if (not (null? dot-list))
379 (set! fret-diagram-stencil (ly:stencil-add
381 (draw-dots layout props string-count fret-range size finger-code
382 dot-position dot-radius th dot-list))))
383 (if (not (null? xo-list))
384 (set! fret-diagram-stencil (ly:stencil-combine-at-edge
385 fret-diagram-stencil Y UP
386 (draw-xo layout props string-count fret-range size xo-list) xo-padding)))
387 (if (> (car fret-range) 1)
388 (set! fret-diagram-stencil
389 (ly:stencil-combine-at-edge fret-diagram-stencil X label-dir
390 (label-fret layout props string-count fret-range size) label-space)))
391 (ly:stencil-aligned-to fret-diagram-stencil X alignment)
394 (define-builtin-markup-command (fret-diagram layout props definition-string)
400 \\markup \\fret-diagram #\"s:0.75;6-x;5-x;4-o;3-2;2-3;1-2;\"
403 for fret spacing 3/4 of staff space, D chord diagram
405 Syntax rules for @var{definition-string}:
409 Diagram items are separated by semicolons.
416 s:number -- set the fret spacing of the diagram (in staff spaces). Default 1
419 t:number -- set the line thickness (in staff spaces). Default 0.05
422 h:number -- set the height of the diagram in frets. Default 4
425 w:number -- set the width of the diagram in strings. Default 6
428 f:number -- set fingering label type (0 = none, 1 = in circle on string, 2 = below string) Default 0
431 d:number -- set radius of dot, in terms of fret spacing. Default 0.25
434 p:number -- set the position of the dot in the fret space. 0.5 is centered; 1 is on lower fret bar,
435 0 is on upper fret bar. Default 0.6
438 c:string1-string2-fret -- include a barre mark from string1 to string2 on fret
441 string-fret -- place a dot on string at fret. If fret is o, string is identified
442 as open. If fret is x, string is identified as muted.
445 string-fret-fingering -- place a dot on string at fret, and label with fingering as
451 Note: There is no limit to the number of fret indications per string.
455 (let ((definition-list (fret-parse-definition-string props definition-string)))
456 (make-fret-diagram layout (car definition-list) (cdr definition-list))))
458 (define (fret-parse-definition-string props definition-string)
459 "parse a fret diagram string and return a pair containing:
460 props, modified as necessary by the definition-string
461 a fret-indication list with the appropriate values"
462 (let* ((fret-count 4)
464 (fret-range (list 1 fret-count))
470 (items (string-split definition-string #\;)))
471 (let parse-item ((myitems items))
472 (if (not (null? (cdr myitems)))
473 (let ((test-string (car myitems)))
474 (case (car (string->list (substring test-string 0 1)))
475 ((#\s) (let ((size (get-numeric-from-key test-string)))
476 (set! new-props (acons 'size size new-props))))
477 ((#\f) (let* ((finger-code (get-numeric-from-key test-string))
478 (finger-id (case finger-code
481 ((2) 'below-string))))
483 (acons 'finger-code finger-id new-props))))
484 ((#\c) (set! output-list (cons-fret (cons 'barre (numerify (string-split (substring test-string 2) #\-)))
486 ((#\h) (let ((fret-count (get-numeric-from-key test-string)))
487 (set! new-props (acons 'fret-count fret-count new-props))))
488 ((#\w) (let ((string-count (get-numeric-from-key test-string)))
489 (set! new-props (acons 'string-count string-count new-props))))
490 ((#\d) (let ((dot-size (get-numeric-from-key test-string)))
491 (set! new-props (acons 'dot-radius dot-size new-props))))
492 ((#\p) (let ((dot-position (get-numeric-from-key test-string)))
493 (set! new-props (acons 'dot-position dot-position new-props))))
495 (let ((this-list (string-split test-string #\-)))
496 (if (string->number (cadr this-list))
497 (set! output-list (cons-fret (cons 'place-fret (numerify this-list)) output-list))
498 (if (equal? (cadr this-list) "x" )
499 (set! output-list (cons-fret (list 'mute (string->number (car this-list))) output-list))
500 (set! output-list (cons-fret (list 'open (string->number (car this-list))) output-list)))))))
501 (parse-item (cdr myitems)))))
502 (if (eq? new-props '())
503 `(,props . ,output-list)
504 `(,(cons new-props props) . ,output-list))))
506 (define (cons-fret new-value old-list)
507 " Put together a fret-list in the format desired by parse-string "
508 (if (eq? old-list '())
510 (cons* new-value old-list)))
512 (define (get-numeric-from-key keystring)
513 "Get the numeric value from a key of the form k:val"
514 (string->number (substring keystring 2 (string-length keystring))))
516 (define (numerify mylist)
517 "Convert string values to numeric or character"
520 (let ((numeric-value (string->number (car mylist))))
522 (cons* numeric-value (numerify (cdr mylist)))
523 (cons* (car (string->list (car mylist))) (numerify (cdr mylist)))))))
525 (define-builtin-markup-command (fret-diagram-terse layout props definition-string)
527 "Make a fret diagram markup using terse string-based syntax.
531 \\markup \\fret-diagram-terse #\"x;x;o;2;3;2;\"
533 for a D chord diagram.
535 Syntax rules for @var{definition-string}:
539 Strings are terminated by semicolons; the number of semicolons
540 is the number of strings in the diagram.
543 Mute strings are indicated by \"x\".
546 Open strings are indicated by \"o\".
549 A number indicates a fret indication at that fret.
552 If there are multiple fret indicators desired on a string, they
553 should be separated by spaces.
556 Fingerings are given by following the fret number with a \"-\",
557 followed by the finger indicator, e.g. 3-2 for playing the third
558 fret with the second finger.
561 Where a barre indicator is desired, follow the fret (or fingering) symbol
562 with \"-(\" to start a barre and \"-)\" to end the barre.
564 ;TODO -- change syntax to fret\string-finger
565 (let ((definition-list (fret-parse-terse-definition-string props definition-string)))
566 (make-fret-diagram layout (car definition-list) (cdr definition-list))))
568 (define (fret-parse-terse-definition-string props definition-string)
569 "parse a fret diagram string that uses terse syntax; return a pair containing:
570 props, modified to include the string-count determined by the definition-string
571 a fret-indication list with the appropriate values"
572 ;TODO -- change syntax to fret\string-finger
573 (let* ((barre-start-list '())
576 (items (string-split definition-string #\;))
577 (string-count (- (length items) 1)))
578 (let parse-item ((myitems items))
579 (if (not (null? (cdr myitems)))
580 (let* ((test-string (car myitems))
581 (current-string (- (length myitems) 1))
582 (indicators (string-split test-string #\ )))
583 (let parse-indicators ((myindicators indicators))
584 (if (not (eq? '() myindicators))
585 (let* ((this-list (string-split (car myindicators) #\-))
586 (max-element-index (- (length this-list) 1))
587 (last-element (car (list-tail this-list max-element-index)))
588 (fret (if (string->number (car this-list)) (string->number (car this-list)) (car this-list))))
589 (if (equal? last-element "(")
591 (set! barre-start-list (cons-fret (list current-string fret) barre-start-list))
592 (set! this-list (list-head this-list max-element-index))))
593 (if (equal? last-element ")")
594 (let* ((this-barre (get-sub-list fret barre-start-list))
595 (insert-index (- (length this-barre) 1)))
596 (set! output-list (cons-fret (cons* 'barre (car this-barre) current-string (cdr this-barre))
598 (set! this-list (list-head this-list max-element-index))))
600 (set! output-list (cons-fret (cons* 'place-fret current-string (drop-paren (numerify this-list))) output-list))
601 (if (equal? (car this-list) "x" )
602 (set! output-list (cons-fret (list 'mute current-string) output-list))
603 (set! output-list (cons-fret (list 'open current-string) output-list))))
604 (parse-indicators (cdr myindicators)))))
605 (parse-item (cdr myitems)))))
606 (set! new-props (acons 'string-count string-count new-props))
608 `(,(cons new-props props) . ,output-list)))
610 (define (drop-paren item-list)
611 " drop a final parentheses from a fret indication list resulting from a terse string specification of barre."
612 (if (> (length item-list) 0)
613 (let* ((max-index (- (length item-list) 1))
614 (last-element (car (list-tail item-list max-index))))
615 (if (or (equal? last-element ")") (equal? last-element "("))
616 (list-head item-list max-index)
620 (define (get-sub-list value master-list)
621 " Get a sub-list whose cadr is equal to @var{value} from @var{master-list}"
622 (if (eq? master-list '())
624 (let ((sublist (car master-list)))
625 (if (equal? (cadr sublist) value)
627 (get-sub-list value (cdr master-list))))))