Generalizing SPLIT-SEQUENCE to work with sequences for delimiters?
myrkraverk opened this issue · comments
Hi,
I have a partial implementation of split-sequence that works with
subsequences instead of element delimiters. Partial as in: works for
my use case. It's not hard to finish it and make it work with either
elements or sequences.
Would that be a welcome contribution?
Example:
CL-USER(57): foo
#(2 3)
CL-USER(58): bar
#(1 1 2 3 4 5 2 3)
CL-USER(59): (split-sequence-2:split-sequence-2 foo bar :remove-empty-subseqs t)
(#(1 1) #(4 5))
8
This would break the current semantics when split-sequence
ing a sequence whose elements are sequences, so the new behaviour you propose would need to either be subject to some keyword argument or a different function, right?
Can you show me an example of that? It doesn't seem to work with a vector of vectors.
SPLIT-SEQUENCE> (split-sequence '(cut here)
'((a b) (cut here) (c d) (cut here) (e f))
:test #'equal)
(((A B)) ((C D)) ((E F)))
5
Splitting by a subsequence is outside the scope if this library. Closing.
@myrkraverk Use CL-PPCRE
for that.
CL-USER> (cl-ppcre:split "asd" "qweasdqwefghasdzxcasdfgh")
("qwe" "qwefgh" "zxc" "fgh")