blob: e099e262d2292dfbf79ca01478b3058db6d164c3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
(in-package #:str)
(declaim (optimize (speed 3) (safety 0)))
(declaim (ftype (function ((or pathname string)) (values string &optional)) read-file))
(defun read-file (path)
(with-open-file (file path)
(let* ((size (file-length file))
(buf (make-string size)))
(read-sequence buf file)
buf)))
(declaim (ftype (function (simple-string simple-string) (values (cons string) &optional)) split))
(defun split (input delimiter)
(defun split-rec (result start)
(let ((next (search delimiter input :start2 start)))
(if next
(split-rec (queue:add result (subseq input start next)) (min (+ (length delimiter) next)
(length input)))
(queue:add result (subseq input start next)))))
(queue:to-list (split-rec (queue:new) 0)))
|