diff options
Diffstat (limited to 'aoc-2022-dotnet/Common/Util.fs')
-rw-r--r-- | aoc-2022-dotnet/Common/Util.fs | 10 |
1 files changed, 5 insertions, 5 deletions
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 |