Skip to main content
added 399 characters in body
Source Link
kglr
  • 400.5k
  • 18
  • 488
  • 929
ClearAll[f]
f = Floor@# /. Floor -> Identity &;

f@{1.2, 3, {2.3, 5.4}, null, "fff"}

{1, 3, {2, 5}, null, "fff"}

f@{1.2, 3, {2.3, "ff"}, null, "fff", Pi}

{1, 3, {2, "ff"}, null, "fff", 3}

If the function returns unevaluated when a 'non-applicable' input is passed, this approach is more convenient as it does not require detailed knowledge of the function's argument requirements.

ClearAll[h]
h[x_] := 500 /; PrimeQ[x]
h[x_] := 500 /; Divisible[x, 3]
h /@ Range[15] /. h -> Identity

{1, 500, 500, 4, 500, 500, 500, 8, 500, 10, 500, 500, 500, 14, 500}

StringLength /@ {"abcabc", "bcdbc", 234} /. StringLength -> Identity

Mathematica graphics
{6, 5, 234}

ClearAll[f]
f = Floor@# /. Floor -> Identity &;

f@{1.2, 3, {2.3, 5.4}, null, "fff"}

{1, 3, {2, 5}, null, "fff"}

f@{1.2, 3, {2.3, "ff"}, null, "fff", Pi}

{1, 3, {2, "ff"}, null, "fff", 3}

If the function returns unevaluated when a 'non-applicable' input is passed, this approach is more convenient as it does not require detailed knowledge of the function's argument requirements.

ClearAll[h]
h[x_] := 500 /; PrimeQ[x]
h[x_] := 500 /; Divisible[x, 3]
h /@ Range[15] /. h -> Identity

{1, 500, 500, 4, 500, 500, 500, 8, 500, 10, 500, 500, 500, 14, 500}

StringLength /@ {"abcabc", "bcdbc", 234} /. StringLength -> Identity

Mathematica graphics
{6, 5, 234}

ClearAll[f]
f = Floor@# /. Floor -> Identity &;

f@{1.2, 3, {2.3, 5.4}, null, "fff"}

{1, 3, {2, 5}, null, "fff"}

f@{1.2, 3, {2.3, "ff"}, null, "fff", Pi}

{1, 3, {2, "ff"}, null, "fff", 3}

If the function returns unevaluated when a 'non-applicable' input is passed, this approach is more convenient as it does not require detailed knowledge of the function's argument requirements.

ClearAll[h]
h[x_] := 500 /; PrimeQ[x]
h[x_] := 500 /; Divisible[x, 3]
h /@ Range[15] /. h -> Identity

{1, 500, 500, 4, 500, 500, 500, 8, 500, 10, 500, 500, 500, 14, 500}

StringLength /@ {"abcabc", "bcdbc", 234} /. StringLength -> Identity

Mathematica graphics
{6, 5, 234}

added 69 characters in body
Source Link
kglr
  • 400.5k
  • 18
  • 488
  • 929
ClearAll[f]
f = Floor@# /. Floor -> Identity &;

f@{1.2, 3, {2.3, 5.4}, null, "fff"}

{1, 3, {2, 5}, null, "fff"}

f@{1.2, 3, {2.3, "ff"}, null, "fff", Pi}

{1, 3, {2, "ff"}, null, "fff", 3}

If the function returns unevaluated when a 'non-applicable' input is passed, this approach is more convenient as it does not require detailed knowledge of the function's argument requirements.

ClearAll[h]
h[x_] := 500 /; PrimeQ[x]
h[x_] := 500 /; Divisible[x, 3]
h /@ Range[15] /. h -> Identity

{1, 500, 500, 4, 500, 500, 500, 8, 500, 10, 500, 500, 500, 14, 500}

ClearAll[h]
h[1] = h[2] = h[5] = 100;
hStringLength /@ Range[5]{"abcabc", "bcdbc", 234} /. hStringLength -> Identity

Mathematica graphics
{6, 5, 234}

ClearAll[f]
f = Floor@# /. Floor -> Identity &;

f@{1.2, 3, {2.3, 5.4}, null, "fff"}

{1, 3, {2, 5}, null, "fff"}

f@{1.2, 3, {2.3, "ff"}, null, "fff", Pi}

{1, 3, {2, "ff"}, null, "fff", 3}

If the function returns unevaluated when a 'non-applicable' input is passed, this approach is more convenient as it does not require detailed knowledge of the function's argument requirements.

ClearAll[h]
h[x_] := 500 /; PrimeQ[x]
h[x_] := 500 /; Divisible[x, 3]
h /@ Range[15] /. h -> Identity

{1, 500, 500, 4, 500, 500, 500, 8, 500, 10, 500, 500, 500, 14, 500}

ClearAll[h]
h[1] = h[2] = h[5] = 100;
h /@ Range[5] /. h -> Identity
ClearAll[f]
f = Floor@# /. Floor -> Identity &;

f@{1.2, 3, {2.3, 5.4}, null, "fff"}

{1, 3, {2, 5}, null, "fff"}

f@{1.2, 3, {2.3, "ff"}, null, "fff", Pi}

{1, 3, {2, "ff"}, null, "fff", 3}

If the function returns unevaluated when a 'non-applicable' input is passed, this approach is more convenient as it does not require detailed knowledge of the function's argument requirements.

ClearAll[h]
h[x_] := 500 /; PrimeQ[x]
h[x_] := 500 /; Divisible[x, 3]
h /@ Range[15] /. h -> Identity

{1, 500, 500, 4, 500, 500, 500, 8, 500, 10, 500, 500, 500, 14, 500}

StringLength /@ {"abcabc", "bcdbc", 234} /. StringLength -> Identity

Mathematica graphics
{6, 5, 234}

added 481 characters in body
Source Link
kglr
  • 400.5k
  • 18
  • 488
  • 929
ClearAll[f]
f = Floor@# /. Floor -> Identity &;

f@{1.2, 3, {2.3, 5.4}, null, "fff"}

{1, 3, {2, 5}, null, "fff"}

f@{1.2, 3, {2.3, "ff"}, null, "fff", Pi}

{1, 3, {2, "ff"}, null, "fff", 3}

If the function returns unevaluated when a 'non-applicable' input is passed, this approach is more convenient as it does not require detailed knowledge of the function's argument requirements.

ClearAll[h]
h[x_] := 500 /; PrimeQ[x]
h[x_] := 500 /; Divisible[x, 3]
h /@ Range[15] /. h -> Identity

{1, 500, 500, 4, 500, 500, 500, 8, 500, 10, 500, 500, 500, 14, 500}

ClearAll[h]
h[1] = h[2] = h[5] = 100;
h /@ Range[5] /. h -> Identity
ClearAll[f]
f = Floor@# /. Floor -> Identity &;

f@{1.2, 3, {2.3, 5.4}, null, "fff"}

{1, 3, {2, 5}, null, "fff"}

f@{1.2, 3, {2.3, "ff"}, null, "fff", Pi}

{1, 3, {2, "ff"}, null, "fff", 3}

ClearAll[f]
f = Floor@# /. Floor -> Identity &;

f@{1.2, 3, {2.3, 5.4}, null, "fff"}

{1, 3, {2, 5}, null, "fff"}

f@{1.2, 3, {2.3, "ff"}, null, "fff", Pi}

{1, 3, {2, "ff"}, null, "fff", 3}

If the function returns unevaluated when a 'non-applicable' input is passed, this approach is more convenient as it does not require detailed knowledge of the function's argument requirements.

ClearAll[h]
h[x_] := 500 /; PrimeQ[x]
h[x_] := 500 /; Divisible[x, 3]
h /@ Range[15] /. h -> Identity

{1, 500, 500, 4, 500, 500, 500, 8, 500, 10, 500, 500, 500, 14, 500}

ClearAll[h]
h[1] = h[2] = h[5] = 100;
h /@ Range[5] /. h -> Identity
Source Link
kglr
  • 400.5k
  • 18
  • 488
  • 929
Loading