t3x.org
/
nss
/
depth.html
(Nils' Scheme Snippets)
Paren matching: ON
|
Category: lists
|
Overview
|
Scheme Books
|
License
(depth list) => integer
Purpose
Compute the depth of a list.
Arguments
a
list
Example
(depth '(a (b (c d (e))))) => 4
(
define
(
depth a
)
(
if
(
pair?
a
)
(
+
1
(
apply max
(
map
depth a
)
)
)
0
)
)
Copyright (C) 2007
Nils M Holm
<
nmh @ t3x . org
>