LocSta icon indicating copy to clipboard operation
LocSta copied to clipboard

Think about mutability

Open SchlenkR opened this issue 4 years ago • 0 comments

Example:


let mutFunc ctor =
    (ctor ()) <|> fun cont (_: unit) -> gen {
        let res = cont ()
        return { value = res; state = cont }
    }

let increment seed =
    fun () ->
        let mutable x = seed
        let f () =
            x <- x + 1
            x
        f
    |> mutFunc

Gen.toSeq id (increment 3) |> Seq.toListN 10

SchlenkR avatar Sep 14 '21 12:09 SchlenkR