From a61dc3d878113ecbfcc33428302394ae9fce7a97 Mon Sep 17 00:00:00 2001 From: Hamcha Date: Sat, 30 Nov 2024 21:24:07 +0100 Subject: [PATCH] minor private fn cleanup --- src/kmer.gleam | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/kmer.gleam b/src/kmer.gleam index 2bcfb24..0d2f8ff 100644 --- a/src/kmer.gleam +++ b/src/kmer.gleam @@ -102,7 +102,7 @@ fn decode_map( ) -> DecoderResult(List(#(DecodedValue, DecodedValue))) { use #(length, rest) <- try(decode_int(bits)) use #(entries, remainder) <- try(decode_next_n([], rest, length * 2)) - use pairs <- try(into_pairs(entries)) + use pairs <- try(into_pairs([], entries)) Ok(#(pairs, remainder)) } @@ -128,18 +128,14 @@ fn decode_simple(bits: BitArray) -> DecodeResult { } } -fn into_pairs(list: List(a)) -> Result(List(#(a, a)), DecodeError) { - into_pairs_aggr([], list) -} - -fn into_pairs_aggr( +fn into_pairs( accum: List(#(a, a)), remaining: List(a), ) -> Result(List(#(a, a)), DecodeError) { case remaining { [] -> Ok(reverse(accum)) [_] -> Error(Malformed) - [key, value, ..rest] -> into_pairs_aggr([#(key, value), ..accum], rest) + [key, value, ..rest] -> into_pairs([#(key, value), ..accum], rest) } }