Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

In Mathematica 9, I used to be able to do

rules = Dispatch[{'a' -> 1, 'b' -> 2}]
rules[[1]]

to extract the rules from Dispatchwrapped list of rules. In Mathematica 10 the following error is raised:

Part::partd: Part specification Dispatch[...][[1]] is longer than depth of object. >>

Is this a bug? I am using only the trial version currently. I got aware of it because it breaks the AutomaticUnits package.

share|improve this question

1 Answer 1

up vote 11 down vote accepted

No, this is not a bug. Dispatch tables are now atomic:

Dispatch[{"a" -> 1, "b" -> 2, "c" -> 3}] // AtomQ
True

As noted by user 18w here we can use Normal to recover the rules.

Dispatch[{"a" -> 1, "b" -> 2, "c" -> 3}] // Normal
{"a" -> 1, "b" -> 2, "c" -> 3}
share|improve this answer
1  
And (they became atoms) for good reason, Dispatch tables with symbols in them were hard to use properly. See Performance of Dispatch and lists of Rules. Maybe I should see if I can simplify my answer to your "Why is there no PositionFunction in Mathematica?" Q&A. There was another issue with performance I think. –  Jacob Akkerboom Jul 14 at 13:37
2  
Sweet, Dispatch now works with Verbatim! The example in my answer (below "This may be because Dispatch just does not work well with Verbatim. Example:") now works! –  Jacob Akkerboom Jul 14 at 13:40

Your Answer

 
discard

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.