component-child-number
PrevNext

Name

component-child-number — Find child-number within a component

Synopsis

(component-child-number inputnd complist)

Description

Finds the first ancestor of inputnd in complist and then counts all the elements of type inputnd from that point on and returns the number of inputnd. (This is like a recursive-child-number starting at the first parent of inputnd in complist.)

Author

Norman Walsh, <ndw@nwalsh.com>

Source Code

(define (component-child-number inputnd complist)
  ;; Find child-number within a component
  (let ((nd (ancestor-member inputnd complist)))
    (let loop ((nl (select-elements (descendants nd) (gi inputnd)))
	       (num 1))
      (if (node-list-empty? nl)
	  0
	  (if (node-list=? (node-list-first nl) inputnd)
	      num
	      (if (string=? (gi (node-list-first nl)) (gi inputnd))
		  (loop (node-list-rest nl) (+ num 1))
		  (loop (node-list-rest nl) num)))))))

PrevHomeNext
case-fold-upUpconstant-list
 
 

Copyright © 1997 Norman Walsh