SketchyLISP Reference |
Copyright (C) 2006 Nils M Holm |
<<[map] | [Index] | [member]>> |
Conformance: R5RS
Purpose: Find the maximum of a list of numbers.
Arguments:
A - number
B... - numbers
Implementation:
(define (max a . b) (letrec ((_max (lambda (a) (cond ((null? (cdr a)) (car a)) ((> (car a) (cadr a)) (_max (cons (car a) (cddr a)))) (#t (_max (cdr a))))))) (cond ((null? b) a) (#t (_max (cons a b))))))
Example:
(max -25 5 25 0 -5) => 25
<<[map] | [Index] | [member]>> |