Re: Interesting Side-Effects Problem & Solution

Subject: Re: Interesting Side-Effects Problem & Solution
From: Chris Maden <crism@xxxxxxxxxxx>
Date: Mon, 14 Dec 1998 22:55:07 -0500 (EST)
[Avi Kivity]
> My data contains empty <page> elements interspersed with the 
> content elements (no, I'm not using them to control pagination). The
> problem is to locate the nearest <page> element that precedes some
> given element in tree order. This <page> element may be a sibling node,
> or it may occur as some other type of relative (cousin-node?).


> (define (interesting-rule parameter)
>     (lambda(sosofo snl)
>          ...
>          (do-something-with parameter)
>          ...
>          (cons 
>                 a-sosofo
>                  (interesting-rule (+ parameter 1))  ;successors use a
> different rule
>          )
>          ...
>     )
> )

Interesting.  I prefer another approach for this particular problem.
The list of <page>s is generated within each construction rule, and
then iterated over until one is found whose (all-element-number) is
greater than the current node.  It's probably heavier on the
processor, but it means that you can process arbitrary nodes and get
the right results.  For example, in your case, determining the page of
a cross-reference destination would probably be difficult.

<!ENTITY crism PUBLIC "-//O'Reilly//NONSGML Christopher R. Maden//EN"
"<URL> <TEL>+1.617.499.7487
<USMAIL>90 Sherman Street, Cambridge, MA 02140 USA" NDATA SGML.Geek>

 DSSSList info and archive:

Current Thread