~subsetpark/ec

ref: ffc6859813b20596fc58632b7f8c47d60d42d6be ec/src/print.janet -rw-r--r-- 591 bytes
ffc68598 — Zach Smith add license 11 months ago
                                                                                
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
(use fugue)

(import /src/calc)

(defmulti p [calc/Int]
  [n] (string (n :value)))

(defmulti p [calc/Float]
  [n] (string (n :value)))

(defmulti p [calc/Operation]
  [o] (string (o :type)))

(defmulti p [calc/Adverb]
  [a] (string (a :type)))

(varfn join [q] nil)

(defmulti p [calc/Quotation] [q] (join q "(" ")"))

(defmulti p [calc/Vector] [v] (join v "[" "]"))

(varfn join
  [q l r]
  (let [inner (map p (q :data))]
    (string l (string/join inner " ") r)))

(defmulti p [:nil] [_] "")

(defmulti p [:array] [t] (string/join (map p t) " "))

(defmulti p [_]
  [val] (describe val))