Primes by Trial Division - Interlisp/65

29 March 2022

This version of Interlisp for Atari 6502 is surprisingly capable, but unfortunately omits several key functions the other versions rely on. MEMBER seems to work only on non-numeric atoms; no implementation of REMAINDER, MOD, LESSP, or MAPC. Mathematical operators are symbolic (+, *, /) except for subtraction (SUB).

As a consequence, this implementation is philosophically more similar to the C implementation, though the division test is implemented recursively, rather than iteratively.

Variant C

(DEFINEQ DIVP (LAMBDA (X LISZT)
  (PROG (Y)
    (SETQ Y (CAR LISZT))
    (COND ((# Y)
           (PROG (I Z)
             (SETQ Z (/ X Y))
             (SETQ I (INT Z))
             (COND ((EQ Z I) (RETURN T))
                   (T (DIVP X (CDR LISZT))))))
           (T NIL)))))

(DEFINEQ PRIMES (LAMBDA (N)
        (PROG (COUNT PRIMES)
            (SETQ COUNT 3)
            (SETQ PRIMES (LIST 2))
       NEXT (COND ((> N (LENGTH PRIMES))
                  (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