Skip to content

Instantly share code, notes, and snippets.

View SLsthompson's full-sized avatar

Scott Thompson SLsthompson

  • SoftLayer Technologies, Inc.
View GitHub Profile
@SLsthompson
SLsthompson / State.ex
Last active June 9, 2016 19:00
State monad implemented in Elixir
defmodule State do
# At each stage of computation, State builds a function. That
# function accepts an "initial state" as an argument and returns
# a tuple containing a final computed value, and a final state
# The basis of State accepts a value and returns a function.
# The function returned accepts a state and returns a tuple with the
# value and the state.
def unit(value) do