I would like to be able to use Mathematica's string completion feature for subvalues of my own functions. I tend to go for functions that follow the pattern f["description"][parameters][variables] So say I have functions describing models:

modelOfSomething["Linear"][a_, b_][x_]:= a + b x;
modelOfSomething["Logarithmic"][a_, b_][x_]:= a + b Log[x];

Then as time goes on, I define more functions:

modelOfSomething["NonLinear"][a_, b_, c_, n_][x_] := 
  modelOfSomething["Linear"][a, b][x] + c x^n;

so as I go along, I may end up with a few different models that I find useful to index with a string especially if they have the same number of parameters. So my question is

if/how can I get Mathematica to give me a drop-down of all the string subvalues of my function much like it does with CountryData:

enter image description here


The method described in File-name completion for custom functions can be used to complete the "description" argument in your examples, but it won't work for the curried parameters and variables.

Note that the method does not appear to support dynamic computation of completion choices, so it cannot be used to generate the list directly from a symbol's definitions. The list would have to be maintained independently of the definitions themselves.

  • $\begingroup$ See, the linked is exactly the question I was looking for before I posted but I thought "string completion" was the right search term - I will see what I can do with it and if it is as easy as your answer there makes it look, I will delete this as duplicate. Thanks! $\endgroup$ – gpap Aug 28 '14 at 14:51
  • $\begingroup$ Let's close it instead of deleting it -- you won't be the last person to use that search term. $\endgroup$ – WReach Aug 28 '14 at 14:53

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