2
$\begingroup$

In his video http://www.wolfram.com/broadcast/video.php?channel=362&video=1643, Wolfram gives the following example: the output from

dict = Nearest[WordData[]]

is a NearestFunction object -- a function that may then be evaluated at an input such as:

dict["eleephannt"]

{elephant}

How can one determine which other functions func similarly generate a funcFunction?

(Not sure if the Title correctly captures the meaning of my question!)

$\endgroup$
  • 2
    $\begingroup$ I think this is probably a bit too broad as it is, because there really isn't anything restricting one from writing these kinds of functions oneself, and they can freely appear in packages &c. Are you only interested in the built-in functions that have this kind of output? $\endgroup$ – Oleksandr R. Jun 26 '14 at 21:01
  • 1
    $\begingroup$ Some generated functions that come to mind: NearestFunction, BooleanFunction, InterpolatingFunction, FittedModel, CompiledFunction, DataDistribution (yes, it's technically a distritbuion, but try evaluating dist["Properties"]), and even more in v10: APIFunction, TemplateObject, MeshRegion, CloudFunction, etc. $\endgroup$ – Szabolcs Jun 26 '14 at 21:03
  • 1
    $\begingroup$ In addition, in v10 several list processing functions can be used to create a function object that can be passed around and used later. E.g. Select[OddQ] itself is a function. Try Select[OddQ][{1, 2, 3, 4, 5, 6, 7}]. $\endgroup$ – Szabolcs Jun 26 '14 at 21:06
  • 1
    $\begingroup$ I don't think you can scrape Mathematica's namespace to find functions that return functions, because the weak typing of Mathematica implies that return types are generally unknown and you can't systematically query functions to see what they might return. $\endgroup$ – Sjoerd C. de Vries Jun 26 '14 at 21:43
  • 1
    $\begingroup$ What is the motivation behind the question? Are you just looking for some examples that work like this or are you looking for a reliable programmatic way to decide whether something is a function? E.g. define functionQ which will return True when trying funcionQ@Nearest[{1,2,3}]? I think this really isn't possible in Mathematica (as Sjoerd pointed out). $\endgroup$ – Szabolcs Jun 26 '14 at 22:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.