3
$\begingroup$

I have part of a code that looks like this:

horpatt = (* some code giving a List of n elements *);
verpatt = (* some code giving a List of n elements *);
tabpatt = Riffle[horpatt, verpatt] (* some ReplaceAll code *);

It is run several times with different values of the first two variables. Sometimes it produces this warning:

Riffle::rspec:
The third argument {2,-1,2} should be a positive integer or a list with three integers

which doesn't seem to be documented anywhere on the Internet. I try to see what might be wrong with the first two variables with the following code:

tabpatt = Check[
  Riffle[horpatt, verpatt] (* some code *),
  riffletrack = {horpatt, verpatt}; Abort[]
];

riffletrack gives me exact values of horpatt and verpatt that causes the warning. But when I try those values, the warning doesn't actually occur.

horpatt = {{"S", "Q", "U", "I", "Z"}, {"V", "U", "L", "G", "O"}, {Null, "O", Null, "G", "O"}, {"S", "T", "E", "E", "N"}, {Null, "H", Null, "D", "S"}};
verpatt = {{"S", "V", Null, "S", Null}, {"Q", "U", "O", "T", "H"}, {"U", "L", Null, "E", Null}, {"I", "G", "G", "E", "D"}, {"Z", "O", "O", "N", "S"}};
tabpatt = Riffle[horpatt, verpatt] /. Null -> _

Even more strangely,

Riffle[horpatt, verpatt, {2, -1, 2}] /. Null -> _

doesn't produce a warning, but a desired result that is identical to both of the following:

Riffle[horpatt, verpatt] /. Null -> _
Riffle[horpatt, verpatt, {2, 10, 2}] /. Null -> _

I'm not even sure what questions to ask. Does Mathematica automatically insert {2, -1, 2} as a third argument into Riffle? The warning seems to suggest that such argument doesn't work but why does it work? Why is there the warning in the first place? Should I always insert a proper third argument (akin to {2, 10, 2} above) to avoid this seemingly random warning? Is this a bug?

I'm using Mathematica 10.0.2.0 for Mac.

Update

I have actually put {2, 10, 2} as a third argument into my code:

tabpatt = Riffle[horpatt, verpatt, {2, 10, 2}] (* some ReplaceAll code *);

After many iterations, Mathematica eventually gives several instances of:

Riffle::rspec:
The third argument {2,10,2} should be a positive integer or a list with three integers

I'm pretty sure there's a bug in there somewhere.

$\endgroup$
3
  • $\begingroup$ Actually the syntax you have discovered isn't completely undocumented: the 5th example under the "Scope" section suggests that such generalization could work: "Cyclically riffle in x and y: Riffle[{1, 2, 3, 4, 5, 6, 7, 8, 9}, {x, y}, {5, -1, 2}]." $\endgroup$ May 10, 2016 at 7:17
  • $\begingroup$ The issue is not readily reproducible; it appears at random. The code just before 'Even more strangely' had given me the issue (I caught it with Check); running it again didn't. $\endgroup$
    – Taiki
    May 10, 2016 at 13:31
  • $\begingroup$ I suggest you to contact the tech support on this issue. $\endgroup$ May 18, 2016 at 2:37

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.