Definindo uma função em partes

Oct 24 2020

Como posso definir uma função por partes no Mathematica?

Estou tentando definir $$f_{A}(x)=\left\{\begin{aligned} 1, \quad x \in A\\ 0, \quad x\notin A \end{aligned}\right.$$ Onde $A\subseteq \mathbb{R}$.

Respostas

5 cvgmt Oct 23 2020 at 22:47
Clear["`*"];
f[A_][x_] := Boole@MemberQ[A, x];
A = {x, y, z};
f[A][x]