From a2243a035b52c6d85d6a2d9331d69a7d3ebc64de Mon Sep 17 00:00:00 2001 From: Matei Adriel Date: Sun, 15 Dec 2019 14:55:46 +0200 Subject: [PATCH] fsharp(ygosim): feat: added a basic helper to set an element by index in a list Signed-off-by: prescientmoon --- fsharp/ygosim/src/Utils.fs | 7 +++++++ fsharp/ygosim/ygosim.fsproj | 1 + 2 files changed, 8 insertions(+) create mode 100644 fsharp/ygosim/src/Utils.fs diff --git a/fsharp/ygosim/src/Utils.fs b/fsharp/ygosim/src/Utils.fs new file mode 100644 index 0000000..f241924 --- /dev/null +++ b/fsharp/ygosim/src/Utils.fs @@ -0,0 +1,7 @@ +module Utils + +module List = + let setIndex index value list = + List.mapi (fun previous i -> + if i = index then value + else previous) diff --git a/fsharp/ygosim/ygosim.fsproj b/fsharp/ygosim/ygosim.fsproj index 740adef..c11ddef 100644 --- a/fsharp/ygosim/ygosim.fsproj +++ b/fsharp/ygosim/ygosim.fsproj @@ -5,6 +5,7 @@ netcoreapp3.0 +