Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add Nat.hash #644

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/Nat.mo
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import Int "Int";
import Order "Order";
import Prim "mo:⛔";
import Char "Char";
import Hash "Hash";

module {

Expand All @@ -25,7 +26,10 @@ module {
/// ```motoko include=import
/// Nat.toText 1234 // => "1234"
/// ```
public func toText(n : Nat) : Text = Int.toText n;
public let toText : Nat -> Text = Int.toText;

/// Computes a hash from the least significant 32-bits of `n`, ignoring other bits.
public let hash : Nat -> Hash.Hash = Int.hash;

/// Creates a natural number from its textual representation. Returns `null`
/// if the input is not a valid natural number.
Expand Down
Loading