This repository is a playground for different functional programming concepts on JVM: Java 8, Kotlin, Scala, Clojure, Eta (Haskell).
- Java - A series of examples of implementing fold function. From an example of sum and product to a full higher-order function. There are few examples implemented with fold like:
- count - normally we wouldn't use a fold function to count the number of elements on the list but for practice sake we will.
- last - finds the last item on the list
- reverse - returns a list with items with reversed order
- average - returns average value for the given list of Integers
- contains - return a boolean value indicating whether a search item is on the given list.
- join - returns a String created from a list of values joined with a given separator
- mkString - returns a String created from a list of values joined with a colon
- penultimate - returns the element next to the last element of the list. Hint: use Tuple
- unique - returns a list with unique elements from the given list
- Java - a series of examples how to change a method with several boolean arguments into composition of functions
- Java - an example how to implement a lazy "stream-like" data structure
- Java - a Scala Try implementation
- Java - a Haskell Validation implementation
- Kotlin - the same Validation applicative functor implementation (code shorter and much readable then in Java)