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

negate

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)))
           (else (cons '- x))))))
    (cond ((zero? x) x)
      (else (list->integer
              (_negate (integer->list x)) #t)))))

Example:

(negate 125) 
=> -125

See also:
digits, -, negative?.