blob: 4438e29d359915e73bc0a9f78547bda1b79c6304 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
(ns core
(:require [readline]))
;; Errors/exceptions
(defn mal_throw [obj]
(throw (ex-info "mal exception" {:data obj})))
;; 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)]
(with-meta obj new-meta)))
(defn mal_meta [obj]
(:meta (meta obj)))
;; core_ns is core namespaces functions
(def core_ns
[['= =]
['throw mal_throw]
['nil? nil?]
['true? true?]
['false? false?]
['symbol symbol]
['symbol? symbol?]
['keyword keyword]
['keyword? keyword?]
['pr-str pr-str]
['str str]
['prn prn]
['println println]
['readline readline/readline]
['read-string reader/read-string]
['slurp slurp]
['< <]
['<= <=]
['> >]
['>= >=]
['+ +]
['- -]
['* *]
['/ /]
['time-ms (fn time-ms [] (System/currentTimeMillis))]
['list list]
['list? seq?]
['vector vector]
['vector? vector?]
['hash-map hash-map]
['map? map?]
['assoc assoc]
['dissoc dissoc]
['get get]
['contains? contains?]
['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]
['concat concat]
['nth nth]
['first first]
['rest rest]
['empty? empty?]
['count count]
['conj conj]
['apply apply]
['map #(doall (map %1 %2))]
['with-meta mal_with_meta]
['meta mal_meta]
['atom atom]
['atom? (fn atom? [atm] (= (type atm) clojure.lang.Atom))]
['deref deref]
['reset! reset!]
['swap! swap!]])
|