1

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.

4

2 回答 2

1

StdInt 提供了另一种选择:它称为 rem。就像老式的 mod 函数一样工作,但也适用于有符号整数。

10 rem 7 // 3

10 rem -7 // 3

-10 rem 7 // -3

-10 rem -7 //-3
于 2014-11-26T21:41:59.970 回答
0

在最新的稳定版本 (Clean 3.0) 中,只需导入 StdEnv 实例即可使用“rem”。

于 2020-09-29T17:24:09.727 回答