Created
September 13, 2024 00:13
-
-
Save xuwei-k/9350b26206298c1b04c2cc2e7815a50a 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.compiletime.ops.int | |
import scala.compiletime.ops.double | |
type F1[A <: Int] <: Double = | |
int.%[A, 2] match | |
case 0 => | |
1d | |
case 1 => | |
-1d | |
type F2[A <: Int] = | |
double./[ | |
F1[A], | |
int.ToDouble[ | |
int.+[ | |
int.*[A, 2], | |
1 | |
] | |
] | |
] | |
type F3[A <: Int, B <: Double] <: Double = | |
int.<[A, 0] match { | |
case true => | |
double.*[4.0, B] | |
case false => | |
F3[int.-[A, 1], double.+[B, F2[A]]] | |
} | |
type F[A <: Int] = F3[A, 0.0] | |
def x = summon[F[10000] =:= 3.1416926435905435] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment