99ff363652
Signed-off-by: prescientmoon <git@moonythm.dev>
17 lines
443 B
Forth
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
|