Skip to content

Instantly share code, notes, and snippets.

@wardenlym
Last active February 25, 2016 02:44
Show Gist options
  • Save wardenlym/3f97f1ff2dbe4c671858 to your computer and use it in GitHub Desktop.
Save wardenlym/3f97f1ff2dbe4c671858 to your computer and use it in GitHub Desktop.
Toys
;; learning The Little Schemer
;; Chapter 1. Toys
(def car first)
(def cdr rest)
(def cons clojure.core/cons)
(def eq? =)
(def list? clojure.core/list?)
(def atom?
(fn [x]
(not (list? x))))
(def s-exp?
(fn [x]
(or (atom? x) (list? x))))
(def null?
(fn [x]
(if (atom? x) (car x) ;raise a exception
(and (list? x) (empty? x)))))
@wardenlym
Copy link
Author

try use gist

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment