Aaron N. Tubbs bio photo

Aaron N. Tubbs

Dragon chaser.

Twitter Facebook Google+ LinkedIn Github

I’ve been teaching myself Scheme, as a way to keep my brain occupied when I burn out on the math side of Project Euler. Unfortunately, I worry I may be losing my edge. When asked to implement (= m n) in terms of primitives previously constructed1, my first go was:

(define o=
  (lambda (m n)
    (cond
      ((and (zero? m) (zero? n)) #t)
      ((or (zero? m) (zero? n)) #f)
      (else (o= (sub1 m) (sub1 n))))))

When, of course, the obvious answer is:

(define o=
  (lambda (m n)
    (cond
      ((zero? m) (zero? n))
      ((zero? n) #f)
      (else (o= (sub1 m) (sub1 n))))))

What’s depressing is not that I don’t know Scheme, but that my ability to even put together some simple logic is completely broken.

1 (define sub1 (lambda (x) (- x 1)))