Last active
February 25, 2016 02:44
-
-
Save wardenlym/3f97f1ff2dbe4c671858 to your computer and use it in GitHub Desktop.
Toys
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; 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))))) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
try use gist