Bug introduced in 10.0 and fixed in 10.1.0

In Version 10, the GeneralUtilities package contain some useful functions. AssociatePairs is one of those functions included in the package and advertised to work as follows:



Mathematica graphics

Well, here is an input that matches a List of pairs:

lis = Table[{k, k^3}, {k, 2, 10}];



Gives the following error:

Mathematica graphics

Well, the included PairQ function disagrees with this assertion:

AllTrue[lis, PairQ]


So, is this a bug? Since I can't get any list of pairs to work with this function. I'm on Windows 8.1

  • $\begingroup$ Looks like a bug for me, why not to report to Wolfram Support? $\endgroup$
    – m0nhawk
    Commented Jul 16, 2014 at 6:14
  • $\begingroup$ @m0nhawk, I need more people to confirm this behavior and on different operating systems. $\endgroup$
    – RunnyKine
    Commented Jul 16, 2014 at 6:18
  • $\begingroup$ confirm on Windows 8.1 (x64), will check on Linux in few hours. $\endgroup$
    – m0nhawk
    Commented Jul 16, 2014 at 6:20
  • 4
    $\begingroup$ is GeneralUtilities supposed to be an official thing? or some kind of still-in-work package? If it is official, where to find official documentation about it? When I type reference.wolfram.com/search/?q=GeneralUtilities I do not see it? $\endgroup$
    – Nasser
    Commented Jul 16, 2014 at 6:39
  • 1
    $\begingroup$ Error persists in 10.0.1. $\endgroup$ Commented Sep 17, 2014 at 14:29

2 Answers 2


Using Simon Woods's Spelunk we see that the body of the function is:

Self : AssociatePairs[l_] := 
  r$ = Which[! Quiet[TrueQ[MatrixQ[l, PairQ]]], Message[AssociatePairs::npairs, l];
    $FailRHS, True, HoldSequence[Associate @@ Transpose[l]]];
  ReleaseHoldSequence[r$] /; ! MatchQ[r$, $FailRHS | HoldSequence[$FailRHS]]

I draw your attention to:

TrueQ[MatrixQ[l, PairQ]]

Recalling the definition of MatrixQ:

enter image description here

This means that the function is checking that:

  1. l (input) is a matrix

  2. each element passes PairQ

This is apparently illogical.

One could correct this with one of many other possible checks, simplest perhaps:

MatchQ[l, {{_, _} ..}]

Or to allow for SparseArray input, as may have been the motivation for MatrixQ:

MatchQ[Dimensions[l], {_, 2}] && MatrixQ[l]
  • 1
    $\begingroup$ That is an interesting condition! As an aside, every time I use spelunk I want to hug @SimonWoods $\endgroup$
    – acl
    Commented Jul 16, 2014 at 11:02
  • 1
    $\begingroup$ Yeah, the condition is clearly off. Hopefully it will be corrected when they finally add it as an internal function. $\endgroup$
    – RunnyKine
    Commented Jul 16, 2014 at 11:36
  • 3
    $\begingroup$ This is fixed, which is too late for 10.0.2, but will be present in 10.0.3 $\endgroup$ Commented Dec 11, 2014 at 16:01
  • 1
    $\begingroup$ @Taliesin Thanks for the notice. $\endgroup$
    – Mr.Wizard
    Commented Dec 11, 2014 at 19:24
  • $\begingroup$ Didn't we go from 10.0.2 to 10.1? $\endgroup$ Commented Jul 25, 2015 at 22:28

This is an adjunct to @Mr.Wizard's answer: while I've fixed this for 10.0.3, anyone who wants to use this rather trivial function in the meantime can run SystemOpen["GeneralUtilitiesLoader`"] and then paste the following code at the end of that file:

AssociatePairs[l_] := Macros`ConditionalRHS[
    (MatrixQ[l] && Dimensions[l][[2]] == 2) || VectorQ[l, PairQ], {"npairs", l}, 
    AssociationThread @@ Transpose[l]];

P.S. What goodies does Macros contain? Only the intrepid spelunker will find out!


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.