I have
a["tree"] := "oak"
a["flower"] := "rose"
a["dog" | "cat"] := "animals"
I want that the last definition of a
behaves differently like in
b[x_ /; x == "dog" || x == "cat"] := If[x == "dog", "wow", "miau"]
but want to do this with a
Is there a way to write something like
a["dog" | "cat"] := If[ (* passed parameter *) == "dog", "wow", "miau"]
a[x : "dog" | "cat"] := Switch[x, "dog", 1, "cat", 2]
? P.s. there is not need for:=
in first two cases. $\endgroup$Switch
if possible; please read this: (2618) $\endgroup$