Created
March 2, 2025 23:34
-
-
Save pomadchin/c52e21249ad112ad16d4124c3454a9e0 to your computer and use it in GitHub Desktop.
Spire inspired simple cfor https://github.com/typelevel/spire/blob/v0.18.0/core/src/main/scala-3/spire/syntax/macros/cforMacros.scala#L24-L37
This file contains 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
object CforInline: | |
inline def cfor[A](init: => A)(test: => A => Boolean, next: => A => A)(body: => A => Unit): Unit = | |
cforInline(init, test, next, body) | |
inline def cforInline[R](inline init: R, inline test: R => Boolean, inline next: R => R, inline body: R => Unit): Unit = | |
var index = init | |
while test(index) do | |
body(index) | |
index = next(index) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment