For most functions in Mathematica
, passing them a list will call the function on each element of the list. For example:
ExampleFunction1[x_] := x + 1
ExampleFunction1[{1, 2, 3}]
(* {2, 3, 4} *)
But things change when you use Max[]
. For example if I have this function:
ExampleFunction2[x_] := Max[x, 4]
If I pass this a single number x
, it will return either x
or 4
, whichever is larger, but, as documented, if i pass it a list like this:
ExampleFunction2[{1, 3, 7}]
It will return 7. Instead I'd like it to return { 4, 4, 7}
.
How can I make my function so that Max
uses an element of a list as its argument instead of the entire list?
Comments
Post a Comment