Unscape all strings when parsing
This commit is contained in:
+24
-10
@@ -82,26 +82,40 @@ the (rest) of the last element of the sequence."
|
||||
(mutate e (pair (first e) elem)))
|
||||
seq)
|
||||
|
||||
(defun incr (val)
|
||||
(+ val 1))
|
||||
|
||||
(defun decr (val)
|
||||
(- val 1))
|
||||
|
||||
(defun append (seq elem)
|
||||
(extend seq (pair elem nil)))
|
||||
|
||||
(defun length (seq)
|
||||
(if (nil? seq)
|
||||
0
|
||||
(incr (length (rest seq)))))
|
||||
|
||||
(defmacro n-times (@times @action)
|
||||
(unless (<= (eval @times) 0)
|
||||
(eval @action)
|
||||
(macro-define @args (pair (pair - (pair (eval @times) (pair 1 nil))) (pair @action nil)))
|
||||
;; [o|o] --------------------------> [o|o] -> nil
|
||||
;; | |
|
||||
;; V V
|
||||
;; [o|o] -> [o|o] -> [o|o]-> nil action
|
||||
;; | | |
|
||||
;; V V V
|
||||
;; - times 1
|
||||
(eval (pair n-times @args))))
|
||||
(eval (list n-times (list - @times 1) @action))))
|
||||
|
||||
(defmacro for (@symbol @from @to :rest @for-body)
|
||||
(if (< (eval @from) (eval @to))
|
||||
(macro-define @op incr)
|
||||
(if (> (eval @from) (eval @to))
|
||||
(macro-define @op decr)
|
||||
(macro-define @op nil)))
|
||||
(when @op
|
||||
(macro-define (eval @symbol) (eval @from))
|
||||
(eval (pair prog @for-body))
|
||||
(eval (extend (list for @symbol (@op @from) @to) @for-body))))
|
||||
|
||||
(defun range (:keys from :defaults-to 0 to)
|
||||
"Returns a sequence of numbers starting with the number defined
|
||||
by the key 'from' and ends with the number defined in 'to'."
|
||||
(if (<= from to)
|
||||
(if (< from to)
|
||||
(pair from (range :from (+ 1 from) :to to))
|
||||
nil))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user