From 689368eb3bbd9695ef2183ce03596a34be9292f5 Mon Sep 17 00:00:00 2001 From: Tomasz Chojnacki Date: Fri, 16 Dec 2022 21:22:24 +0100 Subject: Finish day 16 --- aoc-2022-dotnet/Common/Util.fs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'aoc-2022-dotnet/Common/Util.fs') diff --git a/aoc-2022-dotnet/Common/Util.fs b/aoc-2022-dotnet/Common/Util.fs index 8505f58..0086ac8 100644 --- a/aoc-2022-dotnet/Common/Util.fs +++ b/aoc-2022-dotnet/Common/Util.fs @@ -40,12 +40,12 @@ module Util = let composition n f = List.replicate n f |> List.reduce (>>) - let topN n xs = - let rec insertSorted x = - function - | h :: t -> min h x :: (insertSorted (max h x) t) - | _ -> [ x ] + let rec insertSorted x = + function + | h :: t -> min h x :: (insertSorted (max h x) t) + | [] -> [ x ] + let topN n xs = Seq.fold (fun acc x -> if List.length acc < n then -- cgit v1.2.3