From 9d3e7259ec37a48b131bdeb12b1d182c225430b4 Mon Sep 17 00:00:00 2001 From: Smaug123 Date: Mon, 6 Dec 2021 19:40:35 +0000 Subject: [PATCH] Fantomas format --- Day1.fs | 2 +- Program.fs | 4 ++-- Test/TestDay1.fs | 12 ++++-------- Utils.fs | 21 +++++++++++++-------- 4 files changed, 20 insertions(+), 19 deletions(-) diff --git a/Day1.fs b/Day1.fs index 9c34b23..7e018cc 100644 --- a/Day1.fs +++ b/Day1.fs @@ -11,7 +11,7 @@ module Day1 = |> Seq.pairwise |> Seq.filter (fun (a, b) -> a < b) |> Seq.length - + let part2 () = Utils.readResource "Day1.txt" |> Seq.map int diff --git a/Program.fs b/Program.fs index 49fbcd2..f499b5e 100644 --- a/Program.fs +++ b/Program.fs @@ -7,6 +7,6 @@ module Program = | "1" -> printfn $"{Day1.part1 ()}" printfn $"{Day1.part2 ()}" - | s -> - failwithf $"Unexpected argument: %s{s}" + | s -> failwithf $"Unexpected argument: %s{s}" + 0 diff --git a/Test/TestDay1.fs b/Test/TestDay1.fs index 99edda2..c801043 100644 --- a/Test/TestDay1.fs +++ b/Test/TestDay1.fs @@ -5,13 +5,9 @@ open Xunit open FsUnitTyped module TestDay1 = - - [] - let ``Part 1`` () = - Day1.part1 () - |> shouldEqual 1766 [] - let ``Part 2`` () = - Day1.part2 () - |> shouldEqual 1797 + let ``Part 1`` () = Day1.part1 () |> shouldEqual 1766 + + [] + let ``Part 2`` () = Day1.part2 () |> shouldEqual 1797 diff --git a/Utils.fs b/Utils.fs index e63367c..d99c0ff 100644 --- a/Utils.fs +++ b/Utils.fs @@ -5,15 +5,20 @@ open System.Reflection [] module Utils = - type private Dummy = class end + type private Dummy = + class + end let readResource' (name : string) : string array = let asm = Assembly.GetAssembly typeof - use stream = asm.GetManifestResourceStream (sprintf "AdventOfCode2021.Inputs.%s" name) - let s = - use reader = new StreamReader(stream) - reader.ReadToEnd() - s.Split('\r', '\n') - let inline readResource (name : string) : string list = - readResource' name |> List.ofArray + use stream = + asm.GetManifestResourceStream (sprintf "AdventOfCode2021.Inputs.%s" name) + + let s = + use reader = new StreamReader (stream) + reader.ReadToEnd () + + s.Split ('\r', '\n') + + let inline readResource (name : string) : string list = readResource' name |> List.ofArray