SketchyLISP Reference |
Copyright (C) 2006 Nils M Holm |
[-/-] | [Index] | [+]>> |
Conformance: R5RS
Purpose: Multiply numbers.
Arguments:
A... - numbers
Implementation:
(define (* . a) (letrec ((_itimes (lambda (a b) (cond ; avoid leading zeroes in result ((zero? a) 0) ; handle signs ((eq? (negative? a) (negative? b)) (n* (abs a) (abs b))) (#t (negate (n* (abs a) (abs b))))))) (i* (lambda (a b) (_itimes (integer a) (integer b))))) (reduce i* a 1)))
Example:
(* 2 3 4) => 24
See also:
digits,
+,
-,
quotient,
remainder,
n*.
[-/-] | [Index] | [+]>> |