Bug introduced in 8.0.0 and fixed in 8.0.1

Is this a bug or my MMA went insane or I'm missing something?

LengthWhile[Reverse@IntegerDigits[1000], # == 0 &]

works fine, but with SameQ instead of Equal, or with PossibleZeroQ it doesn't

In[32]:= LengthWhile[Reverse@IntegerDigits[1000], # === 0 &]

Out[32]= 0

In[33]:= LengthWhile[Reverse@IntegerDigits[1000], PossibleZeroQ]

Out[33]= 0

It doesn't particularly happen with 1000, it was just an example.

  • $\begingroup$ must be your version. with 8.0.4 on mac 10.6.8 both inputs return 3 $\endgroup$ Commented Feb 1, 2012 at 3:55
  • 8
    $\begingroup$ Bug in V8.0.0 that was fixed in V8.0.1. $\endgroup$ Commented Feb 1, 2012 at 3:57
  • $\begingroup$ @Artes Yeah, I'm testing it in W7. Funny thing is that it works if I evaluate in place the list and write {0, 0, 0, 1} instead... Even when it isn't HoldFirst or anything. Anyway, I'm happy it has been fixed $\endgroup$
    – Rojo
    Commented Feb 1, 2012 at 4:00
  • $\begingroup$ @BrettChampion Ok, shouldn't you put that as an answer? Or should I just close this cause it was fixed? Answers won't get better than yours $\endgroup$
    – Rojo
    Commented Feb 1, 2012 at 4:14
  • $\begingroup$ You may also find the comments to this answer: stackoverflow.com/questions/4181470/… interesting. $\endgroup$ Commented Feb 1, 2012 at 7:43

1 Answer 1


Looks like a bug in V8.0.0 that was fixed in V8.0.1.

Seems to be triggered in part when the argument is a packed array:

(* V8.0.0 *)
In[2]:= digits = Reverse@IntegerDigits[1000]; 

In[3]:= LengthWhile[digits, 0 === #&]

Out[3]= 0

In[4]:= LengthWhile[Developer`FromPackedArray[digits], 0 === #&]

Out[4]= 3

which would explain why it worked when you used Evaluate in Place.


Your Answer

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

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