http://t3x.org/mcl/nmath.html   (light|dark)

MICRO COMMON LISP

Natural Number Math Library

This is a REPL session with the MICRO COMMON LISP natural number math library. Note that numbers are represented by lists of digits, so the number 123 is represented by the list (1 2 3) The digits themselves are just symbols.

MICRO COMMON LISP 03
5116 NODES

* (load "src/nmath")
T

* (gc)
3123            ; 5116-3123 = 1993 nodes, not a small program

* 1
? undefined: 1  ; the one is just a symbol!

* (plus '(1 2 3) '(4 5 6))
(5 7 9)

* (difference '(7) '(5))
(2)

* (difference '(5) '(7))
NEGATIVE

* (load "src/expt")      ; EXPT function
T

* (load "src/length")    ; LENGTH function
T

* (expt '(2) '(1 0 0))  ; this will take a while ...
(1 2 6 7 6 5 0 6 0 0 2 2 8 2 2 9 4 0 1 4 9 6 7 0 3 2 0 5 3 7 6)

* (length *)
(3 1)

* (load "src/gcdlcm")
T

* (gcd '(3 2) '(3 6))
(4)

* (lcm '(3 2) '(3 6))
(2 8 8)

* (load "src/sqrt")
T

* (sqrt '(1 5 1 2 9))
(1 2 3)

*

contact | privacy