Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions core/sequence.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@


(defun split-sequence (delimiter seq
&key (count nil) (remove-empty-subseqs nil)
&key (count nil) (remove-empty-subseqs t)
(from-end nil) (start 0) (end nil)
(key nil key-supplied)
(test nil test-supplied)
Expand Down Expand Up @@ -69,7 +69,7 @@
:finally (return (values subseqs right)))))))

(defun split-sequence-if (predicate seq
&key (count nil) (remove-empty-subseqs nil)
&key (count nil) (remove-empty-subseqs t)
(from-end nil) (start 0) (end nil)
(key nil key-supplied))
"Return a list of subsequences in SEQ delimited by items, satisfying PREDICATE.
Expand Down Expand Up @@ -122,7 +122,7 @@
:finally (return (values subseqs right)))))))

(defun split-sequence-if-not (predicate seq
&key (count nil) (remove-empty-subseqs nil)
&key (count nil) (remove-empty-subseqs t)
(from-end nil) (start 0) (end nil)
(key nil key-supplied))
"Return a list of subsequences in SEQ delimited by items, satisfying
Expand Down
3 changes: 1 addition & 2 deletions core/string.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@

(defun split-string (string)
"Split STRING by WHITE-CHAR-P."
(rutils.sequence:split-sequence-if #'white-char-p string
:remove-empty-subseqs t))
(rutils.sequence:split-sequence-if #'white-char-p string))

(defun substr (string start &optional end)
"Efficient substring of STRING from START to END (optional),
Expand Down
13 changes: 6 additions & 7 deletions test/sequence-test.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
(should be equal '("foo" "bar")
(split-sequence #\Space "foo bar"))
(should be equal '("foo" "bar")
(split-sequence #\Space "foo bar" :remove-empty-subseqs t))
(split-sequence #\Space "foo bar"))
(should be equal '("foo" "" "bar" "baz")
(split-sequence #\Space "foo bar baz"))
(split-sequence #\Space "foo bar baz" :remove-empty-subseqs nil))
(should be equal '("foo" "bar" "baz")
(split-sequence " " "foo bar baz" :test 'string=))
(should be equal '("foo" "bar" "baz")
Expand Down Expand Up @@ -44,9 +44,9 @@
(should be equal '("foo" "bar")
(split-sequence-if space-char-p "foo bar"))
(should be equal '("foo" "bar")
(split-sequence-if space-char-p "foo bar" :remove-empty-subseqs t))
(split-sequence-if space-char-p "foo bar"))
(should be equal '("foo" "" "bar" "baz")
(split-sequence-if space-char-p "foo bar baz"))
(split-sequence-if space-char-p "foo bar baz" :remove-empty-subseqs nil))
(should be equal '("foo")
(split-sequence-if space-char-p "foo bar baz" :count 1))
(should be equal '("baz")
Expand All @@ -67,10 +67,9 @@
(should be equal '("foo" "bar")
(split-sequence-if-not 'alpha-char-p "foo bar"))
(should be equal '("foo" "bar")
(split-sequence-if-not 'alpha-char-p "foo bar"
:remove-empty-subseqs t))
(split-sequence-if-not 'alpha-char-p "foo bar"))
(should be equal '("foo" "" "bar" "baz")
(split-sequence-if-not 'alpha-char-p "foo bar baz"))
(split-sequence-if-not 'alpha-char-p "foo bar baz" :remove-empty-subseqs nil))
(should be equal '("foo")
(split-sequence-if-not 'alpha-char-p "foo bar baz" :count 1))
(should be equal '("baz")
Expand Down