| 
 
Subject: Re: Numbering sections - erratum From: Daniel Speck <dspeck@xxxxxxxxxxxx> Date: Tue, 11 Nov 1997 09:07:52 -0500  | 
Richard Light wrote:
...
> 
> You need to declare your 'countable elements' as a list of strings:
> 
> (define (countable-elements)
>  (list "XXX" "YYY" "ZZZ" ...)
> )
First, instead of defining a procedure that returns a constant list you
could just define a variable whose value is the list:
(define countable-elements '("XXX" "YYY" "ZZZ"))
> I thought that I had tested the use of a (countable-elements)-type
> procedure as a means of specifying the list of GI's, and found it to
> work.  However, I can't have done, because it doesn't!
> 
> You can get around this problem by specifying the list of GI's directly
> within the routine:
> 
> (define (preced-count node)
>       (node-list-length
>             (node-list-filter
>                 (lambda (n1)
>                         (case (gi n1)
>                           (("XXX" "YYY" "ZZZ" ...) #t)
>                           (else #f)
>                         )
>                 )
>                 (preced node)
>             )
>       )
> )
> 
> but this isn't very elegant.
You really aren't making much use of the (case ...) construct here. an
(if (member? (gi nl) countable-elements ... ...) might be more
appropriate. 
> 
> My original idea - of declaring the list of fields as a procedure - is
> with hindsight pretty silly anyway.  What you want to do is to pass the
> list of fields as an argument to the (preced-count) procedure; something
> like:
> 
> (define (preced-count node gilist)
>       (node-list-length
>             (node-list-filter
>                 (lambda (n1)
>                         (case (gi n1)
>                           (gilist #t)
>                           (else #f)
>                         )
>                 )
>                 (preced node)
>             )
>       )
> )
> 
> Can anyone advise how you pass a list of strings as an argument in this
> way?  Jade complains about the 'gilist' within the (case ...) statement
> when I use the syntax above since it is trying to interpret it as a
> procedure.
The (case ...) construct does not evaluate the "datum" part of each
case-clause. 
I would just use the following as the lambda expression:
(lambda (nl)
  (member? (gi nl) gilist))
-dan
-- 
Daniel Speck                              e-mail: dspeck@xxxxxxxxxxxx
Research Engineer                          voice:     +1 301.548.7818
Thomson Technology Services Group            fax:     +1 301.527.4094
1375 Piccard Drive, Rockville, MD 20850      WWW:    www.thomtech.com
 DSSSList info and archive:  http://www.mulberrytech.com/dsssl/dssslist
| Current Thread | 
|---|
  | 
| <- Previous | Index | Next -> | 
|---|---|---|
| Re: Numbering sections - erratum, Paul Prescod | Thread | (match-element?), Chris Maden | 
| Re: Numbering sections - erratum, Paul Prescod | Date | Left/Right alternating headers in J, Norman Walsh | 
| Month |