4
$\begingroup$

Bug introduced in 11.3 and persisting through 12.3


Only the first one recognizes a zero-length sequence between non-X's.

SequenceSplit[{1, 2, X, 3, X, X, 4, 5, X}, s : {X ...} :> s]
SequenceSplit[{1, 2, X, 3, X, X, 4, 5, X}, s : {(X | X) ...} :> s]
SequenceSplit[{1, 2, X, 3, X, X, 4, 5, X}, s : {(X | 5) ...} :> s]
(* {{}, {1}, {}, {2}, {X}, {3}, {X, X}, {4}, {}, {5}, {X}} *)
(* {{1, 2}, {X}, {3}, {X, X}, {4, 5}, {X}} *)
(* {{1, 2}, {X}, {3}, {X, X}, {4}, {5, X}} *)

MatchQ works as expected.

MatchQ[{}, {X ...}]
MatchQ[{}, {(X | X) ...}]
MatchQ[{}, {(X | 5) ...}]
(* True, True, True *)

I want to SequenceSplit around sequences of the form {(X | Y | Z)...} including empty ones; why can't I do this? Is it a bug?

$\endgroup$
2
  • $\begingroup$ Maybe you could try: SequenceSplit[{1, 2, X, 3, X, X, 4, 5, X}, {s : {X ...} :> s, s : {(X | X) ...} :> s}] $\endgroup$
    – Carl Woll
    Jun 22 '21 at 17:48
  • 1
    $\begingroup$ I can't see anything wrong with what you are doing. And it doesn't look like it's working as documented. $\endgroup$
    – mikado
    Jun 22 '21 at 17:55
4
$\begingroup$

Well, at least there's a workaround.

SequenceSplit[list, {s : {(X | Y | Z)...} :> s, {} -> {}}]

Edit: answer from Wolfram Technical Support - "It does appear that SequenceSplit is not behaving properly. I have forwarded an issue report to our developers with the information you provided"

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.