Functional Programming Patterns in Scala and Clojure (for Lorinda Hartzler) by Michael Bevilacqua-Linn

Functional Programming Patterns in Scala and Clojure (for Lorinda Hartzler) by Michael Bevilacqua-Linn

Author:Michael Bevilacqua-Linn
Language: eng
Format: epub, mobi
Tags: Pragmatic Bookshelf
ISBN: 978-1-937785-47-5
Publisher: The Pragmatic Bookshelf, LLC (448677)


​ ​def​ subtract(a: ​Int​, b: ​Int​) = a - b

​ ​def​ multiply(a: ​Int​, b: ​Int​) = a * b

​ ​def​ divide(a: ​Int​, b: ​Int​) = a / b

To wrap our calculator functions in logging code, we use ​makeLogger​ . This is a higher-order function that takes in a calculator function and returns a new function that runs the original calculator function and prints the result to the console before returning it.

ScalaExamples/src/main/scala/com/mblinn/mbfpp/oo/decorator/Examples.scala

​ ​def​ makeLogger(calcFn: (​Int​, ​Int​) => ​Int​) =



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.