Created
August 11, 2025 02:05
-
-
Save hamidb80/960d78b120e88174cd4691350182d914 to your computer and use it in GitHub Desktop.
static modulation for nim
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 std/random | |
func mods[T: static Natural](a: int, b: type T): range[0 .. T-1] = | |
cast[type result](a mod b.int) | |
let n = rand 0 .. 100 | |
case n.mods 4 | |
of 3,2,1: echo "huh" | |
of 0 : echo "got you" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
the compiler does not nag and say: