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

count

Conformance: SketchyLISP Extension

Purpose: Recursively count the atoms of a list. Members of all sublists are included.

Arguments:
X - list

Implementation:

(define (count x)
  (cond ((null? x) 0)
    ((pair? x)
      (+ (count (car x))
         (count (cdr x))))
    (else 1)))

Example:

(count '(a b (c (d) e) ((f)))) 
=> 6

See also:
depth, length.