Quantcast
Viewing all articles
Browse latest Browse all 186

Why is SequencePosition or SequenceCases so slow on large lists?

I observed that SequencePosition or Sequence Cases on a list of around 60'000 digits is so slow that I had to sort out to string pattern matching.Is this normal behavior or should Wolfram have a look at it?Let me demonstrate it on the first 500 digits of Pi:

t = Flatten[RealDigits[N[Pi, 500]]]SequencePosition[t, {3 .., 8 ..}] // Timing{23.2813, {{18, 19}, {25, 27}, {26, 27}, {124, 125}, {171, 172}, {197, 198}, {383, 384}, {431, 432}, {489, 490}}}ts = TextString[Row[t]];StringPosition[ts, "3" .. ~~ "8" ..] // Timing{0.015625, {{18, 19}, {25, 27}, {26, 27}, {124, 125}, {171, 172}, {197, 198}, {383, 384}, {431, 432}, {489, 490}}}

Many thanks for your thoughts.Markus


Viewing all articles
Browse latest Browse all 186

Trending Articles