Skip to content

Think about mutability #2

@SchlenkR

Description

@SchlenkR

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions