t3x.org / sketchy / library / depth.html
SketchyLISP
Reference
  Copyright (C) 2007
Nils M Holm

depth

Conformance: SketchyLISP Extension

Purpose: Compute the depth of a list. The depth of a list is the maximum number of nested lists enclosing any atom of the list. The depth of an atom is 0.

Arguments:
A - list

Implementation:

(define (depth a)
  (cond ((pair? a)
      (+ 1 (fold-left max 0 (map depth a))))
    (else 0)))

Example:

(depth '(a b (c (d) e) ((f)))) 
=> 3

See also:
count, length.