Skip to content

Commit

Permalink
Update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Goju-Ryu committed Oct 16, 2024
1 parent 7a8eae9 commit 91bfd21
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 0 deletions.
39 changes: 39 additions & 0 deletions book/src/list-functions-lists.md
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,45 @@ fn sort<D: Dim>(xs: List<D>) -> List<D>

</details>

### `contains`
looks for an element in a list. Returns true if the element is in the list.

```nbt
fn contains<A>(x: A, xs: List<A>) -> Bool
```

<details>
<summary>Examples</summary>

<pre><div class="buttons"><button class="fa fa-play play-button" title="Run this code" aria-label="Run this code" onclick=" window.open('https://numbat.dev/?q=%5B3%2C%202%2C%207%2C%208%2C%20%2D4%2C%200%2C%20%2D5%5D%20%7C%3E%20contains%280%29')""></button></div><code class="language-nbt hljs numbat">>>> [3, 2, 7, 8, -4, 0, -5] |> contains(0)

= true [Bool]
</code></pre>

<pre><div class="buttons"><button class="fa fa-play play-button" title="Run this code" aria-label="Run this code" onclick=" window.open('https://numbat.dev/?q=%5B3%2C%202%2C%207%2C%208%2C%20%2D4%2C%200%2C%20%2D5%5D%20%7C%3E%20contains%281%29')""></button></div><code class="language-nbt hljs numbat">>>> [3, 2, 7, 8, -4, 0, -5] |> contains(1)

= false [Bool]
</code></pre>

</details>

### `unique`
Remove duplicates, ensuring every value is unique.

```nbt
fn unique<A>(xs: List<A>) -> List<A>
```

<details>
<summary>Examples</summary>

<pre><div class="buttons"><button class="fa fa-play play-button" title="Run this code" aria-label="Run this code" onclick=" window.open('https://numbat.dev/?q=unique%28%5B1%2C%202%2C%202%2C%203%2C%203%2C%203%5D%29')""></button></div><code class="language-nbt hljs numbat">>>> unique([1, 2, 2, 3, 3, 3])

= [1, 2, 3] [List<Scalar>]
</code></pre>

</details>

### `intersperse`
Add an element between each pair of elements in a list.

Expand Down
44 changes: 44 additions & 0 deletions book/src/list-functions-other.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,50 @@ fn is_finite<T: Dim>(n: T) -> Bool

</details>

### `is_zero`
Returns true if the input is 0 (zero).

```nbt
fn is_zero<D: Dim>(value: D) -> Bool
```

<details>
<summary>Examples</summary>

<pre><div class="buttons"><button class="fa fa-play play-button" title="Run this code" aria-label="Run this code" onclick=" window.open('https://numbat.dev/?q=is%5Fzero%2837%29')""></button></div><code class="language-nbt hljs numbat">>>> is_zero(37)

= false [Bool]
</code></pre>

<pre><div class="buttons"><button class="fa fa-play play-button" title="Run this code" aria-label="Run this code" onclick=" window.open('https://numbat.dev/?q=is%5Fzero%280%29')""></button></div><code class="language-nbt hljs numbat">>>> is_zero(0)

= true [Bool]
</code></pre>

</details>

### `is_not_zero`
Returns true if the input is anything other than 0 (zero).

```nbt
fn is_not_zero<D: Dim>(value: D) -> Bool
```

<details>
<summary>Examples</summary>

<pre><div class="buttons"><button class="fa fa-play play-button" title="Run this code" aria-label="Run this code" onclick=" window.open('https://numbat.dev/?q=is%5Fnot%5Fzero%2837%29')""></button></div><code class="language-nbt hljs numbat">>>> is_not_zero(37)

= true [Bool]
</code></pre>

<pre><div class="buttons"><button class="fa fa-play play-button" title="Run this code" aria-label="Run this code" onclick=" window.open('https://numbat.dev/?q=is%5Fnot%5Fzero%280%29')""></button></div><code class="language-nbt hljs numbat">>>> is_not_zero(0)

= false [Bool]
</code></pre>

</details>

## Quantities

Defined in: `core::quantities`
Expand Down

0 comments on commit 91bfd21

Please sign in to comment.