2

Is there something like a function pattern test?

function[x_?FunctionQ]:=Module[{},]

In order that Mathematica can tell if the argument is a function or a parameter?

Mirko Aveta
  • 2,192
  • 11
  • 26
  • 1
    Just use Function or Symbol. – Αλέξανδρος Ζεγγ Aug 01 '19 at 11:49
  • 4
    The problem is that 'function' is not very well defined in MMA, you could start with e.g.: _Function | (s_Symbol /; Length[DownValues[s]] > 0) – Kuba Aug 01 '19 at 12:02
  • @Xminer fyi x : Except[ _Symbol] but Sin is a function isn't it? – Kuba Aug 01 '19 at 12:03
  • 3
    @Xminer it is all about what OP wants, I'd say Sin is function while Sin[x] is a function call. – Kuba Aug 01 '19 at 12:09
  • @Kuba Ah,I see. – Xminer Aug 01 '19 at 12:13
  • 2
    I agree with @Kuba that the concept of a function is ill-defined. What I have done in the past is to leave the checking for the body of the module: each time the function is actually used, make sure that the result is a number, and if it isn't, then issue an error message or even return the whole call unevaluated, as shown in the documentation of Module under "Details". In this way, all the myriad forms of specifying a function are covered. – Roman Aug 01 '19 at 12:18
  • 1
    https://mathematica.stackexchange.com/questions/147942/wl-terminology-evaluate-call-invoke-use-etc – Alan Aug 01 '19 at 13:52
  • 1
    Shadowry's answer on the question Alan quoted seams very much related to what I asked. – Mirko Aveta Aug 01 '19 at 13:57

0 Answers0