Skip to content

Instantly share code, notes, and snippets.

@mkumm
Created March 8, 2021 18:54
Show Gist options
  • Save mkumm/0a397f5df9d18139bccb55e9e07b1a03 to your computer and use it in GitHub Desktop.
Save mkumm/0a397f5df9d18139bccb55e9e07b1a03 to your computer and use it in GitHub Desktop.
Scheme for Chapter 2 - The Little Schemer
#lang Scheme
(define atom?
(λ (x)
(and (not (pair? x)) (not (null? x)))))
(define lat?
(λ (l)
(cond
((null? l) #t)
((atom? (car l)) (lat? (cdr l)))
(else #f))))
(define member?
(λ (a lat)
(cond
((null? lat) #f)
(else (or (eq? (car lat) a)
(member? a (cdr lat)))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment