a fast, general-purpose, persistent array structure for Gleam.
28

Configure Feed

Select the types of activity you want to include in your feed.

update README, fix map benchmark table

yoshi~ (Feb 13, 2025, 3:46 PM +0100) dfa7e2fa 5b5a5033

+14 -20
+4 -8
README.md
··· 29 29 ```gleam 30 30 import iv 31 31 import gleam/int 32 - import gleam/result 33 32 34 33 // bubble sort, in my gleam? 35 34 pub fn main() { ··· 50 49 case iv.get(array, index - 1), iv.get(array, index) { 51 50 // found 2 elements in the wrong order, swap them, then continue 52 51 Ok(prev), Ok(curr) if prev > curr -> { 53 - case 52 + let array = 54 53 array 55 - |> iv.set(index, prev) 56 - |> result.then(iv.set(_, index - 1, curr)) 57 - { 58 - Ok(array) -> bubble_sort_loop(array, index + 1, max_index) 59 - Error(_) -> array 60 - } 54 + |> iv.try_set(index, prev) 55 + |> iv.try_set(index - 1, curr) 56 + bubble_sort_loop(array, index + 1, max_index) 61 57 } 62 58 63 59 // found 2 elements in the correct order, we can skip them!
+6 -4
benchmarks.md
··· 2 2 @import "https://unpkg.com/charts.css/dist/charts.min.css"; 3 3 4 4 .benchmark { 5 + margin-top: 1em; 6 + 5 7 .charts-css { 6 8 --primary-axis-color: var(--bg-mono-1); 7 9 --data-axes-color: var(--bg-mono-1); ··· 18 20 margin-bottom: 0.5em; 19 21 } 20 22 } 21 - 23 + 22 24 table { 23 25 min-width: 100%; 24 26 } ··· 503 505 <th scope="row">10k</th> 504 506 <td style="--start: calc(log(15991, 10) / var(--max)); --end: calc(log(1590, 10) / var(--max))"><span class="data">iv: 16k</span></td> 505 507 <td style="--start: calc(log(3131, 10) / var(--max)); --end: calc(log(317, 10) / var(--max))"><span class="data">gary: 3131</span></td> 506 - <td style="--start: calc(log(11.4, 10) / var(--max)); --end: calc(log(0, 10) / var(--max))"><span class="data">gle: 11.4</span></td> 508 + <td style="--start: calc(log(11.4, 10) / var(--max)); --end: 0"><span class="data">gle: 11.4</span></td> 507 509 <td style="--start: calc(log(6391, 10) / var(--max)); --end: calc(log(621, 10) / var(--max))"><span class="data">list: 6391</span></td> 508 510 <td style="--start: calc(log(674, 10) / var(--max)); --end: calc(log(56.7, 10) / var(--max))"><span class="data">dict: 674</span></td> 509 511 </tr> ··· 511 513 <th scope="row">100k</th> 512 514 <td style="--start: calc(log(1590, 10) / var(--max)); --end: calc(log(159, 10) / var(--max))"><span class="data">iv: 1590</span></td> 513 515 <td style="--start: calc(log(317, 10) / var(--max)); --end: calc(log(31, 10) / var(--max))"><span class="data">gary: 317</span></td> 514 - <td style="--start: calc(log(0, 10) / var(--max)); --end: calc(log(0, 10) / var(--max))"><span class="data">gle: n/a</span></td> 516 + <td style="--start: 0; --end: 0"><span class="data">gle: n/a</span></td> 515 517 <td style="--start: calc(log(621, 10) / var(--max)); --end: calc(log(62, 10) / var(--max))"><span class="data">list: 621</span></td> 516 - <td style="--start: calc(log(674, 10) / var(--max)); --end: calc(log(70, 10) / var(--max))"><span class="data">dict: 674</span></td> 518 + <td style="--start: calc(log(56.7, 10) / var(--max)); --end: calc(log(7, 10) / var(--max))"><span class="data">dict: 56.7</span></td> 517 519 </tr> 518 520 </tbody> 519 521 </table>
+4 -8
test/demo.gleam
··· 1 1 import gleam/int 2 2 import gleam/io 3 - import gleam/result 4 3 import iv 5 4 6 5 pub fn main() { ··· 21 20 case iv.get(array, index - 1), iv.get(array, index) { 22 21 // found 2 elements in the wrong order, swap them, then continue 23 22 Ok(prev), Ok(curr) if prev > curr -> { 24 - case 23 + let array = 25 24 array 26 - |> iv.set(index, prev) 27 - |> result.then(iv.set(_, index - 1, curr)) 28 - { 29 - Ok(array) -> bubble_sort_loop(array, index + 1, max_index) 30 - Error(_) -> array 31 - } 25 + |> iv.try_set(index, prev) 26 + |> iv.try_set(index - 1, curr) 27 + bubble_sort_loop(array, index + 1, max_index) 32 28 } 33 29 34 30 // found 2 elements in the correct order, we can skip them!