nth-node

Name

nth-node -- Return a specific node in a node list (by numeric index)

Synopsis

(nth-node nl k)

Description

Returns the kth node in nl. The first node in the node list has the index "1".

Author

Norman Walsh, <ndw@nwalsh.com>

Source Code

(define (nth-node nl k)
  ;; Return a specific node in a node list (by numeric index)
  (if (equal? k 1)
      (node-list-first nl)
      (nth-node (node-list-rest nl) (- k 1))))