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

I want to produce an array from expressions given by

test[one][1] = 3;
test[one][5] = 7;


Normally would use Table[test[one][i], {i,N}], but for this you need the value of N that may not be known (without keeping track of it via some other means). I would like to be able to read the maximum value of the integer inside test[one][ ] and use this to construct the array. For expression such as test[1] = 5, this is straight forward since DownValues[test] can be used, but when adding another level the head becomes "test" and DownValues[] will not work.

share|improve this question
Related: (9440); Documentation on different *Values types. – Mr.Wizard Aug 6 '13 at 6:14

The issue at hand is that curried values are stored in SubValues, not DownValues:

Do[test["one"][i] = Fibonacci[i], {i, 5}];
Last /@ SubValues[test]
(* {1, 1, 2, 3, 5} *)

If you have several definitions for test such as test["two"] or whatever, then you can pattern match on the SubValues:

Do[test["one"][i] = Fibonacci[i], {i, 5}];
Do[test["two"][i] = Fibonacci[i], {i, 6, 10}];
Cases[SubValues[test], x : test["two"][_] :> x, Infinity]
share|improve this answer
Yes, thanks that's the function I was looking for – user8281 Aug 6 '13 at 3:50

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.