Primes by Trial Division - Cambridge LISP

27 November 2017

Acorn Cambridge LISP appears to be a variant of MACLISP. The primary difference from other LISP systems is that return can only appear at the top level of a prog block. Returning from within mapc is not allowed.

(de divp (n list)
  (eq (catch isdiv (mapc list (lambda (p)
                     (cond ((zerop (remainder n p)) (throw isdiv t))))))
    t))

(de primes (n)
  (prog (count primes)
    (setq count 3)
    (setq primes (list 2))
    NEXT (cond ((lessp (length primes) n)
                (cond ((divp count primes) nil)
                      (t (nconc primes (list count)))))
               (t (return primes)))
    (setq count (plus 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