Hello everyone,
If I create a custom function and want to make it Listable, is the function restricted to one argument, namely, the input list? For example, here's a function that computes the square root of a number or list of numbers.
mySqrt[num_] := Sqrt[num]
SetAttributes[mySqrt, Listable]
mySqrt[{4,9}] returns {2,3} as expected. But say I want to add a second argument, an option to display the result as a table.
mySqrt[num_] := Sqrt[num]
mySqrt[num_, "Table"] := TableForm[mySqrt[num]]
SetAttributes[mySqrt, Listable]
mySqrt[{4,9},"Table"] still returns {2,3}, not a table. Any way to pull off what I am trying to do?
Greg