Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
must be your version. with 8.0.4 on mac 10.6.8 both inputs return 3 – Mike Honeychurch Feb 1 '12 at 3:55
Bug in V8.0.0 that was fixed in V8.0.1. – Brett Champion Feb 1 '12 at 3:57
@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 – Rojo Feb 1 '12 at 4:00
@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 – Rojo Feb 1 '12 at 4:14
You may also find the comments to this answer:… interesting. – Leonid Shifrin Feb 1 '12 at 7:43
up vote 11 down vote accepted

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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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