Skip to content

Instantly share code, notes, and snippets.

@chris-taylor
Created May 1, 2012 10:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chris-taylor/41384441e01df1f88706 to your computer and use it in GitHub Desktop.
Save chris-taylor/41384441e01df1f88706 to your computer and use it in GitHub Desktop.
alternate definitions of abs and signum
myabs x | x > 0 = x
| x == 0 = 0
| x < 0 = -x
mysignum x | x > 0 = 1
| x == 0 = 0
| x < 0 = -1
test x = myabs x * mysignum x == x
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment