From: Ummon Date: Mon, 18 Dec 2017 07:53:33 +0000 (+0100) Subject: Simplify a bit X-Git-Url: https://git.euphorik.ch/?a=commitdiff_plain;h=d83c27d507917993689f4e8f1783f2e881c08bc2;p=advent_of_code_2017.git Simplify a bit --- diff --git a/AdventOfCode2017/Day16.fs b/AdventOfCode2017/Day16.fs index bc52286..d032c45 100644 --- a/AdventOfCode2017/Day16.fs +++ b/AdventOfCode2017/Day16.fs @@ -43,13 +43,14 @@ let dance (size : int) (nb : int) (moves : DanceMove list) : string = swap (find a) (find b) let cycle = - ((0, initialState), Seq.initInfinite id) + (initialState, Seq.initInfinite id) ||> Seq.scan ( - fun (_, previous) i -> + fun previous _ -> let current = previous.[*] applyMoves current - i + 1, current + current ) + |> Seq.indexed |> Seq.takeWhile (fun (i, state) -> i = 0 || i <= nb && not (state |=| initialState)) |> Seq.map snd |> Array.ofSeq