diff options
Diffstat (limited to 'clojure/src')
| -rw-r--r-- | clojure/src/core.clj | 11 | ||||
| -rw-r--r-- | clojure/src/stepA_more.clj | 1 |
2 files changed, 9 insertions, 3 deletions
diff --git a/clojure/src/core.clj b/clojure/src/core.clj index 73d8fb4..6b0d9b5 100644 --- a/clojure/src/core.clj +++ b/clojure/src/core.clj @@ -5,7 +5,12 @@ (defn mal_throw [obj] (throw (ex-info "mal exception" {:data obj}))) -;; Metadata +;; Number functions + +(defn time-ms [] + (System/currentTimeMillis)) + +;; Metadata functions ;; - store metadata at :meta key of the real metadata (defn mal_with_meta [obj m] (let [new-meta (assoc (meta obj) :meta m)] @@ -14,8 +19,7 @@ (defn mal_meta [obj] (:meta (meta obj))) - -;; Atoms +;; Atom functions (defn atom? [atm] (= (type atm) clojure.lang.Atom)) @@ -43,6 +47,7 @@ ['- -] ['* *] ['/ /] + ['time-ms time-ms] ['list list] ['list? seq?] diff --git a/clojure/src/stepA_more.clj b/clojure/src/stepA_more.clj index d45d86a..9739760 100644 --- a/clojure/src/stepA_more.clj +++ b/clojure/src/stepA_more.clj @@ -154,6 +154,7 @@ (env/env-set repl-env 'eval (fn [ast] (EVAL ast repl-env))) ;; core.mal: defined using the language itself +(rep "(def! *host-language* \"clojure\")") (rep "(def! not (fn* [a] (if a false true)))") (rep "(def! load-file (fn* [f] (eval (read-string (str \"(do \" (slurp f) \")\")))))") (rep "(defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs) (if (> (count xs) 1) (nth xs 1) (throw \"odd number of forms to cond\")) (cons 'cond (rest (rest xs)))))))") |
