Skip to main content
added 101 characters in body
Source Link
Kuba
  • 137.7k
  • 13
  • 289
  • 751

Alternatively:

expr /. 
  foo_f :> RuleCondition[Hold[foo] /. Print -> Echo] /. 
  Hold[foo_f] :> foo 

We can safely perform the second replacement because we just wrapped every f[..] with Hold.

Alternatively:

expr /. 
  foo_f :> RuleCondition[Hold[foo] /. Print -> Echo] /. 
  Hold[foo_f] :> foo 

Alternatively:

expr /. 
  foo_f :> RuleCondition[Hold[foo] /. Print -> Echo] /. 
  Hold[foo_f] :> foo 

We can safely perform the second replacement because we just wrapped every f[..] with Hold.

Source Link
Kuba
  • 137.7k
  • 13
  • 289
  • 751

Alternatively:

expr /. 
  foo_f :> RuleCondition[Hold[foo] /. Print -> Echo] /. 
  Hold[foo_f] :> foo