Created
January 31, 2017 02:07
-
-
Save sohnryang/467a74e77bc0b9403f1bed3fd5077116 to your computer and use it in GitHub Desktop.
scala for the impatient - calculating signum
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def signum(x: Int) = { | |
if (x > 0) 1 | |
else if (x < 0) -1 | |
else 0 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment