Created
September 2, 2024 12:41
-
-
Save nagat01/0776a6af2f07acd9d67ce99852461092 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
import scala.language.implicitConversions | |
extension [A](left: A)(using num: Numeric[A]) | |
def >=(right: A) = num.gteq(left, right) | |
def <=(right: A) = num.lteq(left, right) | |
def <== (right: A) = (left <= right, right) | |
def >== (right: A) = (left >= right, right) | |
extension [A](temp: (Boolean, A))(using num: Numeric[A]) | |
def <== (right: A) = (temp._1 && temp._2 <= right, right) | |
def >== (right: A) = (temp._1 && temp._2 >= right, right) | |
// implicit def boolNumberToBool[A](temp: (Boolean, A)): Boolean = temp._1 | |
given [A]: Conversion[(Boolean, A), Boolean] = temp => temp._1 | |
@main def main = | |
val x = 15 | |
if(10 <== x <== 20) println(1) | |
if(20 <== x <== 10) println(2) | |
if(30 >== x * 2 >== 20 >== x) println(3) | |
if(15 >== x <== 15) println(4) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment