Test if an expression is a Function?

后端 未结 3 1177
不思量自难忘°
不思量自难忘° 2021-01-03 01:16

How would a function FunctionQ look like, maybe in a way I can even specify the number of arguments allowed?

3条回答
  •  遥遥无期
    2021-01-03 01:22

    Here's something quick and dirty which may do what you need:

    FunctionQ[x_] := Head[x] == Function || DownValues[x] =!= {}
    

提交回复
热议问题