From b8ee29b22fbaa7a01f2754b4d6dd9af52e02017c Mon Sep 17 00:00:00 2001 From: Joel Martin Date: Thu, 18 Dec 2014 20:33:49 -0600 Subject: All: add keywords. Also, fix nth and count to match cloure. --- clojure/src/core.clj | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) (limited to 'clojure/src') 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!]]) -- cgit v1.2.3