Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
29
Task/Tokenize-a-string/ACL2/tokenize-a-string.acl2
Normal file
29
Task/Tokenize-a-string/ACL2/tokenize-a-string.acl2
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
(defun split-at (xs delim)
|
||||
(if (or (endp xs) (eql (first xs) delim))
|
||||
(mv nil (rest xs))
|
||||
(mv-let (before after)
|
||||
(split-at (rest xs) delim)
|
||||
(mv (cons (first xs) before) after))))
|
||||
|
||||
(defun split (xs delim)
|
||||
(if (endp xs)
|
||||
nil
|
||||
(mv-let (before after)
|
||||
(split-at xs delim)
|
||||
(cons before (split after delim)))))
|
||||
|
||||
(defun css->strs (css)
|
||||
(if (endp css)
|
||||
nil
|
||||
(cons (coerce (first css) 'string)
|
||||
(css->strs (rest css)))))
|
||||
|
||||
(defun split-str (str delim)
|
||||
(css->strs (split (coerce str 'list) delim)))
|
||||
|
||||
(defun print-with (strs delim)
|
||||
(if (endp strs)
|
||||
(cw "~%")
|
||||
(progn$ (cw (first strs))
|
||||
(cw (coerce (list delim) 'string))
|
||||
(print-with (rest strs) delim))))
|
||||
Loading…
Add table
Add a link
Reference in a new issue