picking specific symbol definitions in mathematica (not transformation rules)

后端 未结 3 1870
说谎
说谎 2021-01-12 19:28

I have a following problem.

f[1]=1;
f[2]=2;
f[_]:=0;

dvs = DownValues[f];

this gives

dvs = 
   {
      HoldPattern[f[1]] :         


        
3条回答
  •  轮回少年
    2021-01-12 19:43

    Based on Simon's excellent solution here, I suggest:

    Cases[DownValues[f], _?(FreeQ[#[[1]], Pattern | Blank] &)]
    

提交回复
热议问题