Primes by Trial Division - Golden Common LISP

29 March 2020

Early versions of Gold Hill's Golden Common LISP only somewhat resemble Common Lisp.

(defun mod (x y) (- x (* y (/& x y))))

(defun divp (n list)
  (eq (catch 'ISDIV (mapc #'(lambda (p)
                   (cond ((zerop (mod n p)) (throw 'ISDIV T)))) list))
               T))

(defun primes (n)
  (prog (count primes)
    (setq count 3)
    (setq primes (list 2))
    NEXT (cond ((< (length primes) n)
                (cond ((divp count primes) nil)
                      (T (nconc primes (list count)))))
               (T (return primes)))
    (setq count (+ count 1))
    (go NEXT)))

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026

Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Primes Benchmark Source

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

Primes Benchmark Results

Other LISPs

Cambridge LISP

Common LISP

Domain Lisp

Golden Common LISP

INTERLISP

Interlisp/65

LISP/80

Pearl LISP

Scheme R³

XLISP