Blinking primes

This is an updated uLisp version of the classic Aduino Blink program, traditionally used to verify that your Arduino board is working correctly.

This one blinks out the series of prime numbers, starting with 2, 3, 5, 7, 11, etc, up to the largest integer that uLisp can represent, 32767. You could also use this to demonstrate the existence of intelligent life to visiting aliens.

First, the routine pri returns t if its argument is prime, and nil if it's composite:

(defun pri (n)
  (let ((d 2))
    (loop
     (when (> (* d d) n) (return t))
     (when (zerop (mod n d)) (return nil))
     (incf d))))

Here's the Blink program:

(defun bli (pin)
  (pinmode pin t)
  (dotimes (x 32767)
    (when (and (> x 1) (pri x))
      (dotimes (f (* x 2))
        (digitalwrite pin (evenp f))
        (delay 250))
      (delay 1500))))

Call it with the pin number corresponding to the LED on your board; for example, on an Arduino Uno:

(bli 13)

It will run on any uLisp platform.