split-by->split-by-first, split-completely->split-by-completely
This commit is contained in:
@@ -6,19 +6,19 @@
|
||||
(string clist)
|
||||
(coerce clist 'string)))
|
||||
|
||||
(defun split-by (lst delim)
|
||||
(defun split-by-first (lst delim)
|
||||
"Splits LST by the first instance of DELIM"
|
||||
(let ((pos (position delim lst)))
|
||||
(if pos
|
||||
(cons (subseq lst 0 pos) (list (subseq lst (+ pos 1))))
|
||||
(error (format nil "No instance of ~a was found in ~a" delim lst)))))
|
||||
|
||||
(defun split-completely (lst delim)
|
||||
(defun split-by-completely (lst delim)
|
||||
(if (or (null lst) (not (cdr lst)))
|
||||
(cons (list (car lst)) nil)
|
||||
(if (member delim lst)
|
||||
(destructuring-bind (first rest) (split-by lst delim)
|
||||
(cons first (split-completely rest delim)))
|
||||
(destructuring-bind (first rest) (split-by-first lst delim)
|
||||
(cons first (split-by-completely rest delim)))
|
||||
(list lst))))
|
||||
|
||||
(defun get-lines (input-string)
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
"Split each LINE in LINES by space"
|
||||
(mapcar (lambda (line)
|
||||
(mapcar #'clist-to-string
|
||||
(split-completely (string-to-clist line) #\Space)))
|
||||
(split-by-completely (string-to-clist line) #\Space)))
|
||||
lines))
|
||||
|
||||
(defun is-token-cmd? (token)
|
||||
|
||||
Reference in New Issue
Block a user