From dfa7e2fad891081fbec7e645d7cfdb3c846f8fef Mon Sep 17 00:00:00 2001 From: yoshi~ Date: Thu, 13 Feb 2025 15:46:53 +0100 Subject: [PATCH] update README, fix map benchmark table --- README.md | 12 ++++-------- benchmarks.md | 10 ++++++---- test/demo.gleam | 12 ++++-------- 3 files changed, 14 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index 6274f19..76d3e5b 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,6 @@ gleam add iv@1 ```gleam import iv import gleam/int -import gleam/result // bubble sort, in my gleam? pub fn main() { @@ -50,14 +49,11 @@ fn bubble_sort_loop(array, index, max_index) { case iv.get(array, index - 1), iv.get(array, index) { // found 2 elements in the wrong order, swap them, then continue Ok(prev), Ok(curr) if prev > curr -> { - case + let array = array - |> iv.set(index, prev) - |> result.then(iv.set(_, index - 1, curr)) - { - Ok(array) -> bubble_sort_loop(array, index + 1, max_index) - Error(_) -> array - } + |> iv.try_set(index, prev) + |> iv.try_set(index - 1, curr) + bubble_sort_loop(array, index + 1, max_index) } // found 2 elements in the correct order, we can skip them! diff --git a/benchmarks.md b/benchmarks.md index 58620ee..bb18114 100644 --- a/benchmarks.md +++ b/benchmarks.md @@ -2,6 +2,8 @@ @import "https://unpkg.com/charts.css/dist/charts.min.css"; .benchmark { + margin-top: 1em; + .charts-css { --primary-axis-color: var(--bg-mono-1); --data-axes-color: var(--bg-mono-1); @@ -18,7 +20,7 @@ margin-bottom: 0.5em; } } - + table { min-width: 100%; } @@ -503,7 +505,7 @@ The goal of `iv` is to provide consistent, reliable performance across all kinds 10k iv: 16k gary: 3131 - gle: 11.4 + gle: 11.4 list: 6391 dict: 674 @@ -511,9 +513,9 @@ The goal of `iv` is to provide consistent, reliable performance across all kinds 100k iv: 1590 gary: 317 - gle: n/a + gle: n/a list: 621 - dict: 674 + dict: 56.7 diff --git a/test/demo.gleam b/test/demo.gleam index 348909c..e8da1d2 100644 --- a/test/demo.gleam +++ b/test/demo.gleam @@ -1,6 +1,5 @@ import gleam/int import gleam/io -import gleam/result import iv pub fn main() { @@ -21,14 +20,11 @@ fn bubble_sort_loop(array, index, max_index) { case iv.get(array, index - 1), iv.get(array, index) { // found 2 elements in the wrong order, swap them, then continue Ok(prev), Ok(curr) if prev > curr -> { - case + let array = array - |> iv.set(index, prev) - |> result.then(iv.set(_, index - 1, curr)) - { - Ok(array) -> bubble_sort_loop(array, index + 1, max_index) - Error(_) -> array - } + |> iv.try_set(index, prev) + |> iv.try_set(index - 1, curr) + bubble_sort_loop(array, index + 1, max_index) } // found 2 elements in the correct order, we can skip them! -- 2.51.2