SketchyLISP Reference |
Copyright (C) 2007 Nils M Holm |
<<[count] | [Index] | [digits]>> |
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
<<[count] | [Index] | [digits]>> |