TransWikia.com

How conflicting patterns are resolved?

Mathematica Asked on April 11, 2021

I often find myself doing something like this (probably poor example, sorry)

f[x_] := 0
f[x_Plus] := 1

In the back of my mind generally f[x] is zero but in an exceptional case when the argument is a sum f[x] gives 1. This is exactly what Mathematica thinks as well

{f[a], f[a + b]}

returns {0,1}. If it were not for the "exceptional" rule for f[x_Plus] both results would be zero.

What is the general rule how similar conflicts are resolved?

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP