Created
February 28, 2015 16:30
-
-
Save no-longer-on-githu-b/0b52c4d7737ba2850f11 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 abs(x: Number)(ensure out >= 0): Real = | |
x | |
|> non-zero-parts() | |
|> map(fn(x) => x ^ 2) | |
|> sum() | |
|> sqrt() | |
specialize def abs(x: Real): Real = | |
if x < 0 { -x } else { x } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment