Modulo function in Clean

249 views Asked by At

Is there a predefined way to compute the modulo of two integers in Clean?

StdOverloaded defines the (mod) typeclass, but StdInt does not contain an instance of it, and StdEnv does not either anywhere else. I have seen a language overview about Clean version 2.0, which mentions StdInt's mod instance, but in 2.4, it is definitely missing.

2

There are 2 answers

0
user3474399 On BEST ANSWER

StdInt delivers another alternative: it's called rem. Works just like the old fashioned mod function, but also works fine with signed integers.

10 rem 7 // 3

10 rem -7 // 3

-10 rem 7 // -3

-10 rem -7 //-3
0
Rustam Temirov On

In the latest stable release (Clean 3.0) , it is possible to use "rem" by just importing StdEnv instance.