2021-12-12 10:43:57 +00:00
|
|
|
(defn eq? (a b)
|
|
|
|
(eq a b))
|
|
|
|
|
|
|
|
(defn atom? (x)
|
|
|
|
(atom x))
|
|
|
|
|
|
|
|
(defn string? (x)
|
|
|
|
(eq? (type x) "string"))
|
|
|
|
|
|
|
|
(defn boolean? (x)
|
|
|
|
(eq? (type x) "boolean"))
|
|
|
|
|
|
|
|
(defn symbol? (x)
|
|
|
|
(eq? (type x) "symbol"))
|
|
|
|
|
|
|
|
(defn number? (x)
|
|
|
|
(eq? (type x) "number"))
|
|
|
|
|
|
|
|
(defn list? (x)
|
|
|
|
(eq? (type x) "list"))
|
|
|
|
|
|
|
|
(defn function? (x)
|
|
|
|
(eq? (type x) "function"))
|
|
|
|
|
|
|
|
(defn lambda? (x)
|
|
|
|
(eq? (type x) "lambda"))
|
|
|
|
|
|
|
|
(def null '())
|
|
|
|
|
|
|
|
(defn null? (x)
|
|
|
|
(eq? x null))
|
|
|
|
|
2022-08-25 06:48:19 +00:00
|
|
|
(defn not (x)
|
|
|
|
(eq? x false))
|
|
|
|
|
2022-07-02 13:24:30 +00:00
|
|
|
(defn rest (a)
|
|
|
|
(cdr a))
|
2021-12-12 10:43:57 +00:00
|
|
|
|
2022-07-02 13:24:30 +00:00
|
|
|
(defn first (a)
|
|
|
|
(car a))
|
2021-12-12 10:43:57 +00:00
|
|
|
|
2022-07-02 13:24:30 +00:00
|
|
|
(defn second (a)
|
|
|
|
(first (rest a)))
|
2021-12-12 10:43:57 +00:00
|
|
|
|
2022-07-02 13:24:30 +00:00
|
|
|
(defn third (a)
|
|
|
|
(second (rest a)))
|
|
|
|
|
|
|
|
(defn append (a b)
|
|
|
|
(cond
|
|
|
|
((null? a) b)
|
|
|
|
(true (cons (first a) (append (rest a) b)))))
|
|
|
|
|
|
|
|
(defn reverse (a)
|
|
|
|
(cond
|
|
|
|
((null? a) a)
|
|
|
|
(true (append (reverse (rest a)) (cons (first a) '())))))
|
|
|
|
|
|
|
|
(defn read-line ()
|
2022-08-25 06:48:19 +00:00
|
|
|
(decode-string (reverse (rest (reverse (read-file-bytes "/dev/console" 256))))))
|
|
|
|
|
|
|
|
(defn read-char ()
|
|
|
|
(decode-string (read-file-bytes "/dev/console" 4)))
|
|
|
|
|
|
|
|
(defn print (exp)
|
|
|
|
(do (append-file-bytes "/dev/console" (encode-string (string exp))) '()))
|
2022-06-06 14:02:34 +00:00
|
|
|
|
|
|
|
(defn println (exp)
|
|
|
|
(do (print exp) (print "\n")))
|
2022-08-25 06:48:19 +00:00
|
|
|
|
|
|
|
(defn uptime ()
|
|
|
|
(decode-number (read-file-bytes "/dev/clk/uptime" 8)))
|
|
|
|
|
|
|
|
(defn realtime ()
|
|
|
|
(decode-number (read-file-bytes "realtime" 8)))
|
|
|
|
|
|
|
|
(defn write-file (path str)
|
|
|
|
(write-file-bytes path (encode-string str)))
|
|
|
|
|
|
|
|
(defn append-file (path str)
|
|
|
|
(append-file-bytes path (encode-string str)))
|
|
|
|
|
|
|
|
(defn regex-match? (pattern str)
|
|
|
|
(not (null? (regex-find pattern str))))
|