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)))