Returns the node immediately following the nl node list.
(define (ifollow nl)
(node-list-map (lambda (snl)
(let loop ((rest (siblings snl)))
(cond ((node-list-empty? rest)
(empty-node-list))
((node-list=? (node-list-first rest) snl)
(node-list-first (node-list-rest rest)))
(else
(loop (node-list-rest rest))))))
nl)) |
Returns the node immediately preceding the nl node list.
(define (ipreced nl)
(node-list-map (lambda (snl)
(let loop ((prev (empty-node-list))
(rest (siblings snl)))
(cond ((node-list-empty? rest)
(empty-node-list))
((node-list=? (node-list-first rest) snl)
prev)
(else
(loop (node-list-first rest)
(node-list-rest rest))))))
nl)) |
Returns the preceding sibling element or empty node list if this is the first child.
(define (ipreced nl)
(node-list-map (lambda (snl)
(let loop ((prev (empty-node-list))
(rest (siblings snl)))
(cond ((node-list-empty? rest)
(empty-node-list))
((node-list=? (node-list-first rest) snl)
prev)
(else
(loop (node-list-first rest)
(node-list-rest rest))))))
nl)) |
(node-list-filter proc nl) |
This procedure is defined in the DSSSL standard. Returns a
node-list containing just those members of nl
for which proc applied to a singleton node-list
containing just that member does not return #f.
The DSSSL standard (ISO/IEC 10179) implementation of
node-list-filter reverses the order of the
nodes passed to it. This altered version keeps the nodes in order.
;; (node-list-filter) from ISO/IEC 10179 with small change to avoid
;; reversing the order of nodes
(define (node-list-filter proc nl)
(node-list-reduce nl
(lambda (result snl)
(if (proc snl)
(node-list result snl)
result))
(empty-node-list))) |
Returns the last node in the nl node list.
(define (node-list-last nl)
(node-list-ref nl
(- (node-list-length nl) 1))) |
Returns the number of nodes in the nl node list.
(define (node-list-length nl)
(node-list-reduce nl
(lambda (result snl)
(+ result 1))
0)) |
(node-list-reduce nl combine init) |
If the node-list nl is empty, returns init. If not, returns the result of applying node-list-reduce to:
(define (node-list-reduce nl combine init)
(if (node-list-empty? nl)
init
(node-list-reduce (node-list-rest nl)
combine
(combine init (node-list-first nl))))) |
(node-list-reduce nl proc init) |
(define (node-list-reduce nl proc init)
(if (node-list-empty? nl)
init
(node-list-reduce (node-list-rest nl)
proc
(proc init (node-list-first nl))))) |
(node-list-some? proc nl) |
Returns the node-list comprising the elements of node-list nl for which procedure proc returns #t.
(define (node-list-some? proc nl)
(node-list-reduce nl
(lambda (result snl)
(if (or result (proc snl))
#t
#f))
#f)) |