SketchyLISP Reference |
Copyright (C) 2006 Nils M Holm |
<<[ndivide] | [Index] | [negative?]>> |
Conformance: SketchyLISP Core
Purpose: Compute the negative value of a number.
Arguments:
X - number
Implementation:
(define (negate x) (letrec ((_negate (lambda (x) (cond ((eq? (car x) '-) (cdr x)) ((eq? (car x) '+) (cons '- (cdr x))) (#t (cons '- x)))))) (list->integer (_negate (integer->list x)) #t)))
Example:
(negate 125) => -125
See also:
digits,
-,
negative?.
<<[ndivide] | [Index] | [negative?]>> |