From 7d282716854d7995d3c3d50ef5b3c99c3d9f64b4 Mon Sep 17 00:00:00 2001 From: Tomasz Chojnacki Date: Wed, 27 Dec 2023 21:59:07 +0100 Subject: Fix problems found during blog post creation --- aoc-2020-gleam/src/ext/iteratorx.gleam | 7 +------ aoc-2020-gleam/src/util/cache.gleam | 2 +- 2 files changed, 2 insertions(+), 7 deletions(-) (limited to 'aoc-2020-gleam/src') diff --git a/aoc-2020-gleam/src/ext/iteratorx.gleam b/aoc-2020-gleam/src/ext/iteratorx.gleam index 6c7838d..93136be 100644 --- a/aoc-2020-gleam/src/ext/iteratorx.gleam +++ b/aoc-2020-gleam/src/ext/iteratorx.gleam @@ -3,15 +3,10 @@ import gleam/result as res import gleam/dict.{type Dict} import gleam/iterator.{type Iterator, Next} as iter -pub fn length(iterator: Iterator(a)) -> Int { - iterator - |> iter.fold(from: 0, with: fn(c, _) { c + 1 }) -} - pub fn count(iterator: Iterator(a), satisfying predicate: fn(a) -> Bool) -> Int { iterator |> iter.filter(keeping: predicate) - |> length + |> iter.length } pub fn counts(iterator: Iterator(a)) -> Dict(a, Int) { diff --git a/aoc-2020-gleam/src/util/cache.gleam b/aoc-2020-gleam/src/util/cache.gleam index c007d35..f84f1e6 100644 --- a/aoc-2020-gleam/src/util/cache.gleam +++ b/aoc-2020-gleam/src/util/cache.gleam @@ -44,7 +44,7 @@ pub fn set(in cache: Cache(k, v), for key: k, insert value: v) -> Nil { } pub fn get(from cache: Cache(k, v), fetch key: k) -> Result(v, Nil) { - process.call(cache.server, fn(c) { Get(key, c) }, timeout) + process.call(cache.server, Get(key, _), timeout) } pub fn memoize(with cache: Cache(k, v), this key: k, apply fun: fn() -> v) -> v { -- cgit v1.2.3