https://medium.com/@alonso.delarte/applying-a-function-to-just-one-previous-term-in-a-scala-lazy-collection-59db607a05c2