Put is a Keyword to replace the value of the current context.
Purely functional programming languages usually do not support native first-class mutable variables.
In those languages, mutable states can be implemented in state monads.
Put and Get are the Dsl-based replacements of state monads.
We use unary function as the domain of mutable state.
The parameter of the unary function can be read from the Get keyword, and changed by the Put keyword.
Put is a Keyword to replace the value of the current context.
Purely functional programming languages usually do not support native first-class mutable variables. In those languages, mutable states can be implemented in state monads.
Put and Get are the Dsl-based replacements of state monads.
We use unary function as the domain of mutable state. The parameter of the unary function can be read from the Get keyword, and changed by the Put keyword.
Author:
杨博 (Yang Bo)
Put and Get support multiple states. The following code creates a formatter that Put parts of content into a
Vector[Any]
of string buffers.The following example creates a function that accepts a string parameter and returns the upper-cased last character of the parameter.
For example, given a string of
foo
, the upper-cased last character should beO
.Get