Mathematica Asked on June 10, 2021
When I execute f[g[a, b]] /. f[g[l__]] :> f[l]
I get f[a, b]
as expected.
When I execute f[a + b] /. f[Plus[l__]] :> f[l]
I get f[a + b]
. (I expect f[a, b]
again)
Why?
(Wolfram Mathematica 12.2.0)
This happens because Plus[l__]
evaluates to l__
before the pattern is even replaced. Try instead:
f[a + b] /. f[HoldPattern@Plus[l__]] :> f[l]
Answered by Fidel I. Schaposnik on June 10, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP