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.)
(define (component-child-number inputnd complist) ;; Find child-number within a component (let loop ((nl (component-descendant-node-list inputnd complist)) (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))))))