node-list-filter, node-list-map return a reversed result

Subject: node-list-filter, node-list-map return a reversed result
From: Heiko Kirschke <Heiko.Kirschke@xxxxxxx>
Date: Tue, 28 Apr 1998 14:34:17 +0200
Hi,

the definition of node-list-filter as given in the DSSSL
specification in section 10.2.2:

(define (node-list-filter proc nl)
    (node-list-reduce nl
		      (lambda (result snl)
			(if (proc snl)
			    (node-list snl result)
			  result))
		      (empty-node-list)))

returns a proper node list, but the node list is reversed w.r.t. the
source list passed in argument `nl'. To keep the ordering of the
source list, its definition should be changed to:

(define (my-node-list-filter proc nl)
  (node-list-reduce nl
		    (lambda (result snl)
		      (if (proc snl)
			  (node-list result snl)
			  result))
		    (empty-node-list)))

Assuming that (node-list) does a destructive concatenation of its
arguments, the definition given in the DSSSL specification will run
faster than the latter one.

Same considerations hold for (node-list-map).

BTW, is this a bug or not? From section 10.1.2 can be deduced that
node-lists are ordered (otherwise they would have been named
`node-sets', I guess). 

Viele Gruesse, Heiko


 DSSSList info and archive:  http://www.mulberrytech.com/dsssl/dssslist


Current Thread