
上QQ阅读APP看书,第一时间看更新
FRP – the concat() and sorted() functions Marble diagram
So far, we did simple Marble diagrams, which apply only one function at a time. However, we can compose functions one by one in a sequential order to solve some complex problems easily and in an elegant way.
Now, we will draw Marble diagram for the concat() and sorted() functions. Let's consider some Scala code using these two functions:
scala> val hello = "Hello" hello: String = Hello scala> val world = "World" world: String = World scala> hello.concat(world) res17: String = HelloWorld scala> hello.concat(world).sorted res19: String = Hwdellloor
We can represent them as a Marble diagram, as follows:

In the same way, we can represent any Functional or Reactive or FRP function as a Marble diagram to understand it well.