Stream: beginners

Topic: ✔ modulo function?


view this post on Zulip Becker A. (Jan 04 2024 at 00:38):

I see Roc's standard library has Num.rem, which seems equivalent to Rust's rem function.
https://www.roc-lang.org/builtins/Num#rem
https://doc.rust-lang.org/std/primitive.u8.html#method.rem-2

is there a "modulo" function, like Rust's rem_euclid?
https://doc.rust-lang.org/core/primitive.i8.html#method.rem_euclid

view this post on Zulip Luke Boswell (Jan 04 2024 at 00:53):

This is being discussed in another thread https://roc.zulipchat.com/#narrow/stream/304641-ideas/topic/Add.20mod.20to.20the.20builtins/near/394738507

view this post on Zulip Notification Bot (Jan 04 2024 at 00:53):

Becker A. has marked this topic as resolved.

view this post on Zulip Luke Boswell (Jan 04 2024 at 00:54):

Richard Feldman said:

so the idea would be to remove the current mod/rem operations from builtins, as well as the % operator, and replace them all with:

Num.mod : Num a, [Signed, Unsigned, Euclidean] -> Num a

Looks like the summary


Last updated: Jul 06 2025 at 12:14 UTC