Primes by Trial Division - Pearl LISP

13 October 2016

Pearl LISP is essentially Common LISP, but has some provincial oddities around TAG forms and returning from a PROG or NIL block.

(defun divp (n plist)
  (mapc #'(lambda (p)
              (cond ((zerop (mod n p)) (return-from divp T)))) plist)
  (return-from divp nil))

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

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

Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Primes Benchmark Source

Online Manuals

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