Which - Maple Help

MmaTranslator[Mma]

 Which
 evaluate a specified test and return the value

 Calling Sequence Which(arguments)

Parameters

 arguments - Maple translation of the Mathematica command arguments

Description

 • The Which command evaluates a specified test and returns its value corresponding to the first on the yields TRUE.

Examples

 > $\mathrm{with}\left(\mathrm{MmaTranslator}\left[\mathrm{Mma}\right]\right):$
 > h:= proc (x) options operator, arrow; Which(x < -2, x/3, x > 3, x^2, true, 0) end proc;
 ${h}{≔}{x}{↦}{\mathrm{MmaTranslator}}{:-}{\mathrm{Mma}}{:-}{\mathrm{Which}}{}\left({x}{<}{-2}{,}\frac{{x}}{{3}}{,}{3}{<}{x}{,}{{x}}^{{2}}{,}{\mathrm{true}}{,}{0}\right)$ (1)
 > $h\left(6\right)$
 ${36}$ (2)
 > $h\left(2\right)$
 ${0}$ (3)

Alternatively, you can use the FromMma command with the evaluate option specified.

 > $\mathrm{with}\left(\mathrm{MmaTranslator}\right):$
 > $\mathrm{FromMma}\left(\mathrm{h\left[x_\right]:=Which\left[x < -2, x/3, x > 3, x^2, True, 0\right]},\mathrm{evaluate}\right)$
 ${x}{↦}{\mathrm{Which}}{}\left({x}{<}{-2}{,}\frac{{x}}{{3}}{,}{3}{<}{x}{,}{{x}}^{{2}}{,}{\mathrm{true}}{,}{0}\right)$ (4)
 > $h\left(-5\right)$
 ${-}\frac{{5}}{{3}}$ (5)