- #1
Physics_rocks
- 12
- 0
I'm good in writing functions in Matlab , however since moving to Mathematica , I find it pretty hard to write them . For instance I need to write a function that returns a [1,0,-1] to integers, meaning x>0 , x==0 , x<0
with a single If , but I didn't find a way with one (only two)
sigNum[x_] := If[x < 0, -1, If[x > 0, 1, 0]]
and then using with PATTERNS . what are patterns and how do I use them ? tnx
with a single If , but I didn't find a way with one (only two)
sigNum[x_] := If[x < 0, -1, If[x > 0, 1, 0]]
and then using with PATTERNS . what are patterns and how do I use them ? tnx