From d83c27d507917993689f4e8f1783f2e881c08bc2 Mon Sep 17 00:00:00 2001 From: Ummon Date: Mon, 18 Dec 2017 08:53:33 +0100 Subject: [PATCH] Simplify a bit --- AdventOfCode2017/Day16.fs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) 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 -- 2.45.2