Skip to content

Instantly share code, notes, and snippets.

@agustingianni
Created April 14, 2020 20:17
Show Gist options
  • Save agustingianni/0123b65ed8b6ec1bf4d6f8ac5a622e60 to your computer and use it in GitHub Desktop.
Save agustingianni/0123b65ed8b6ec1bf4d6f8ac5a622e60 to your computer and use it in GitHub Desktop.
type HistoryBuffer () =
let elements = ResizeArray<string>()
let mutable current = 0
member this.AddElement element =
elements.Add element
current <- elements.Count - 1
member this.NextElement() =
if elements.Count <> 0 then
current <- (current + 1) % elements.Count
elements.[current]
else
""
member this.PreviousElement() =
if elements.Count <> 0 then
let element = elements.[current]
current <- if current = 0 then elements.Count - 1 else current - 1
element
else
""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment