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

length

Conformance: R5RS Scheme

Purpose: Compute the length of a list.

Arguments:
X - list

Model:

(define (length x)
  (cond ((null? x) 0)
    (else (n+ (length (cdr x)) 1))))

Implementation:

(define (length x)
  (letrec
    ((_length
       (lambda (x r)
         (cond ((null? x) r)
           (else (_length (cdr x) (n+ r 1)))))))
    (_length x 0)))

Example:

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

See also:
digits, append, list-tail.