1
Fork 0
solar-conflux/fsharp/ygosim/src/Utils.fs
2019-12-16 15:01:50 +02:00

17 lines
443 B
Forth

module Utils
module List =
let setIndex index value =
List.mapi (fun i previous ->
if i = index then value
else previous)
let toIndices list = List.mapi (fun i _ -> i) list
let containsIndex index list = index >= 0 && index < List.length list
module Lens =
open FSharpPlus.Lens
let inline indexToLens index f (array: list<'a>) = f array.[index] <&> fun v -> List.setIndex index v array