aboutsummaryrefslogtreecommitdiff
path: root/clojure/src
diff options
context:
space:
mode:
authorJoel Martin <github@martintribe.org>2014-12-18 20:33:49 -0600
committerJoel Martin <github@martintribe.org>2015-01-09 16:16:50 -0600
commitb8ee29b22fbaa7a01f2754b4d6dd9af52e02017c (patch)
treef4d977ed220e9a3f665cfbf4f68770a81e4c2095 /clojure/src
parentaaba249304b184e12e2445ab22d66df1f39a51a5 (diff)
downloadmal-b8ee29b22fbaa7a01f2754b4d6dd9af52e02017c.tar.gz
mal-b8ee29b22fbaa7a01f2754b4d6dd9af52e02017c.zip
All: add keywords.
Also, fix nth and count to match cloure.
Diffstat (limited to 'clojure/src')
-rw-r--r--clojure/src/core.clj20
1 files changed, 7 insertions, 13 deletions
diff --git a/clojure/src/core.clj b/clojure/src/core.clj
index 6b0d9b5..4438e29 100644
--- a/clojure/src/core.clj
+++ b/clojure/src/core.clj
@@ -5,11 +5,6 @@
(defn mal_throw [obj]
(throw (ex-info "mal exception" {:data obj})))
-;; Number functions
-
-(defn time-ms []
- (System/currentTimeMillis))
-
;; Metadata functions
;; - store metadata at :meta key of the real metadata
(defn mal_with_meta [obj m]
@@ -19,10 +14,6 @@
(defn mal_meta [obj]
(:meta (meta obj)))
-;; Atom functions
-(defn atom? [atm]
- (= (type atm) clojure.lang.Atom))
-
;; core_ns is core namespaces functions
(def core_ns
[['= =]
@@ -30,7 +21,10 @@
['nil? nil?]
['true? true?]
['false? false?]
+ ['symbol symbol]
['symbol? symbol?]
+ ['keyword keyword]
+ ['keyword? keyword?]
['pr-str pr-str]
['str str]
@@ -47,7 +41,7 @@
['- -]
['* *]
['/ /]
- ['time-ms time-ms]
+ ['time-ms (fn time-ms [] (System/currentTimeMillis))]
['list list]
['list? seq?]
@@ -59,8 +53,8 @@
['dissoc dissoc]
['get get]
['contains? contains?]
- ['keys keys]
- ['vals vals]
+ ['keys (fn [hm] (let [ks (keys hm)] (if (nil? ks) '() ks)))]
+ ['vals (fn [hm] (let [vs (vals hm)] (if (nil? vs) '() vs)))]
['sequential? sequential?]
['cons cons]
@@ -77,7 +71,7 @@
['with-meta mal_with_meta]
['meta mal_meta]
['atom atom]
- ['atom? atom?]
+ ['atom? (fn atom? [atm] (= (type atm) clojure.lang.Atom))]
['deref deref]
['reset! reset!]
['swap! swap!]])