In this article, I will describe a simple implementation of a Markov chain using Scala. In particular, I will show how to build a purely functional data structure, without the use of any mutable state or variables. On the way, I will introduce the usage of the builder design pattern…