Skip to content

Commit

Permalink
chore: regenerate base docs (#4336)
Browse files Browse the repository at this point in the history
  • Loading branch information
ggreif authored Dec 20, 2023
1 parent fe03888 commit b397789
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 1 deletion.
19 changes: 19 additions & 0 deletions doc/md/base/Array.md
Original file line number Diff line number Diff line change
Expand Up @@ -614,3 +614,22 @@ assert s.next() == null;

Runtime: O(1)
Space: O(1)

## Function `take`
``` motoko no-repl
func take<T>(array : [T], length : Int) : [T]
```

Returns a new subarray of given length from the beginning or end of the given array

Returns the entire array if the length is greater than the size of the array

```motoko include=import
let array = [1, 2, 3, 4, 5];
assert Array.take(array, 2) == [1, 2];
assert Array.take(array, -2) == [4, 5];
assert Array.take(array, 10) == [1, 2, 3, 4, 5];
assert Array.take(array, -99) == [1, 2, 3, 4, 5];
```
Runtime: O(length);
Space: O(length);
2 changes: 1 addition & 1 deletion doc/md/base/Blob.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Some built in features not listed in this module:
* `b.size() : Nat` returns the number of bytes in the blob `b`;
* `b.vals() : Iter.Iter<Nat8>` returns an iterator to enumerate the bytes of the blob `b`.

For example:
For example:
```motoko include=import
import Debug "mo:base/Debug";
import Nat8 "mo:base/Nat8";
Expand Down
29 changes: 29 additions & 0 deletions doc/md/base/ExperimentalInternetComputer.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,32 @@ let count = IC.countInstructions(func() {
// ...
});
```

## Value `performanceCounter`
``` motoko no-repl
let performanceCounter : (counter : Nat32) -> (value : Nat64)
```

Returns the current value of IC _performance counter_ `counter`.

* Counter `0` is the _current execution instruction counter_, counting instructions only since the beginning of the current IC message.
This counter is reset to value `0` on shared function entry and every `await`.
It is therefore only suitable for measuring the cost of synchronous code.

* Counter `1` is the _call context instruction counter_ for the current shared function call.
For replicated message executing, this excludes the cost of nested IC calls (even to the current canister).
For non-replicated messages, such as composite queries, it includes the cost of nested calls.
The current value of this counter is preserved across `awaits` (unlike counter `0`).

* The function (currently) traps if `counter` >= 2.

Consult [Performance Counter](https://internetcomputer.org/docs/current/references/ic-interface-spec#system-api-performance-counter) for details.

Example:
```motoko no-repl
import IC "mo:base/ExperimentalInternetComputer";
let c1 = IC.performanceCounter(1);
work();
let diff : Nat64 = IC.performanceCounter(1) - c1;
```
9 changes: 9 additions & 0 deletions doc/md/base/TrieSet.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,15 @@ Test if `s1` is a subset of `s2`.
func mem<T>(s : Set<T>, x : T, xh : Hash, eq : (T, T) -> Bool) : Bool
```

@deprecated: use `TrieSet.contains()`

Test if a set contains a given element.

## Function `contains`
``` motoko no-repl
func contains<T>(s : Set<T>, x : T, xh : Hash, eq : (T, T) -> Bool) : Bool
```

Test if a set contains a given element.

## Function `union`
Expand Down

0 comments on commit b397789

Please sign in to comment.