Skip to content

Instantly share code, notes, and snippets.

@0racle
Created October 9, 2019 01:25
Show Gist options
  • Save 0racle/c32fc7f9c11d6a0dbe59c9f5cc389611 to your computer and use it in GitHub Desktop.
Save 0racle/c32fc7f9c11d6a0dbe59c9f5cc389611 to your computer and use it in GitHub Desktop.
Error Margin
role ErrorMargin[$e] {
method ACCEPTS($lval) { $lval ~~ self - $e .. self + $e }
}
say 2.2 ~~ 2 but ErrorMargin[0.5]; # True
say 2.7 ~~ 2 but ErrorMargin[0.5]; # False
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment