~subsetpark/ec

ref: a37c903188ba035322c030f56c766089eab36556 ec/src/print.janet -rw-r--r-- 392 bytes
a37c9031 — Zach Smith Bugfix: make-element in vector math as well 10 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
(use fugue)

(import /src/calc)

(defgeneric p
  [val] (describe val))

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

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

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

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

(defmethod p calc/Vector
  [v]
  (let [inner (map p (v :data))]
    (string "[" (string/join inner " ") "]")))