Conversation
| }; | ||
| return null | ||
| }; | ||
| public func exists<X>(array : [X], predicate : X -> Bool) : Bool { |
There was a problem hiding this comment.
This is called some in Trie.mo and List.mo. I'd hate to introduce inconsistency. Does the bot insist one this?
There was a problem hiding this comment.
Also would need doc and some tests, ideally.
| public func exists<X>(array : [X], predicate : X -> Bool) : Bool { | ||
| Option.isSome(find(array, predicate)) | ||
| }; | ||
| public func forall<X>(array : [X], predicate : X -> Bool) : Bool { |
There was a problem hiding this comment.
This is called all in Trie.mo and List.mo. Also would need doc and tests.
| sortInPlace(temp, compare); | ||
| freeze(temp) | ||
| }; | ||
| public func sortByLessThanOrEqual<X>(array : [X], isLessThanOrEqual : (X, X) -> Bool) : [X] { |
There was a problem hiding this comment.
Is this still an isse with the revised prompt? The bot was having trouble with defining functions returning Order.order because the prompt was actually misleadingly broken.
Maybe we could call lessThanOrEqual totalOrder?
| /// Slice buffer from [start, end). | ||
| public func slice<X>(buffer : Buffer<X>, start : Nat, end : Nat) : Buffer<X> { | ||
| let size = buffer.size(); | ||
| if (start < 0 or start > size or end < 0 or end > size or start > end) { |
There was a problem hiding this comment.
| if (start < 0 or start > size or end < 0 or end > size or start > end) { | |
| if (start > size or end > size or start > end) { |
Nat's are never < 0, right?
| public func abs(x : Int) : Nat { | ||
| Prim.abs(x) | ||
| }; | ||
| public func fromNat(n : Nat) : Int = n; |
There was a problem hiding this comment.
Needs doc .
Maybe we could add a deprecation warning to say its not really necessary (due to subtyping)
| /// Nat.toText 1234 // => "1234" | ||
| /// ``` | ||
| public func toText(n : Nat) : Text = Int.toText n; | ||
| public func hash(n : Nat) : Hash.Hash = Hash.hash(n); |
There was a problem hiding this comment.
Hash.hash is suboptimal. Do we really want to spread it's use?
| public func toText(n : Nat) : Text = Int.toText n; | ||
| public func hash(n : Nat) : Hash.Hash = Hash.hash(n); | ||
| public func abs(n : Int) : Nat = Int.abs n; | ||
| public func fromInt(n : Int) : Nat = Int.abs n; |
There was a problem hiding this comment.
fromInt should trap on negative?
| /// Nat32.toNat(123); // => 123 : Nat | ||
| /// ``` | ||
| public let toNat : Nat32 -> Nat = Prim.nat32ToNat; | ||
| public func hash(n : Nat32) : Hash.Hash = Hash.hash(toNat n); |
There was a problem hiding this comment.
Same argument about Hash.hash
| } | ||
| }; | ||
|
|
||
| public func lteToOrder<X>(isLessThanOrEqual : (X, X) -> Bool) : (X, X) -> Order { |
There was a problem hiding this comment.
I wonder if there is a better name for this...
totalOrderToComparer
or
lessThanOrEqualToCompare
or
compareBy
No description provided.