# BinLists for list of depth greater than 1

Bug introduced in 9.0 or earlier and fixed in 10.3.1 or earlier

BinLists uses the bin specification assuming an interval that is closed on the left and open on the right (according to the documentation). So

BinLists[{1, 2, 3, 4, 5}, {{1, 3, 5, 7}}]


yields

{{1, 2}, {3, 4}, {5}}


because 1 and 2 both fall within the interval [1,3)

However, when I add a second dimension to the list and a second (trivial) binning specification, the leftmost interval is no longer closed for the first binning specification.

BinLists[{{1, 0}, {2, 0}, {3, 0}, {4, 0}, {5, 0}}, {{1, 3, 5, 7}}, {{-∞, ∞}}]


yields

{{{{2, 0}}}, {{{3, 0}, {4, 0}}}, {{{5, 0}}}}


which is incorrect. The workaround is to do something like this where I've replaced the first element of the bin specification with .999 rather than 1.

BinLists[{{1, 0}, {2, 0}, {3, 0}, {4, 0}, {5, 0}}, {{.999, 3, 5, 7}}, {{-∞, ∞}}].


which yields the desired result.

{{{{1, 0}, {2, 0}}}, {{{3, 0}, {4, 0}}}, {{{5, 0}}}}


Anyway, this really ought to be fixed.

• Please, tag questions with bugs after they have been reproduced and confirmed to be one. – Sektor May 8 '15 at 15:09
• Welcome to Mathematica.SE! I suggest the following: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Read the faq! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! – Michael E2 May 8 '15 at 15:11
• @Michael et al: do you feel this is a bug? This question never got any attention but Kelly seems to make a good point. – Mr.Wizard Dec 21 '16 at 23:58
• @Mr.Wizard By V10.4.1, it has been fixed, which indicates to me it was a bug. -- I added what I could about when it was a bug....I don't have access to all versions to check. – Michael E2 Dec 22 '16 at 0:46
• @MichaelE2 The code gives a correct result on 10.3.1. – JungHwan Min Dec 22 '16 at 0:52