This is the 4th post in the From Imperative to Functional Programming focus series. This week, I'll first implement the Dijkstra algorithm, then migrate the code to a more functional-friendly design. Dijkstra's algorithm allows to find the shortest path in any graph, weighted or not, directed or not. The only requirement is that weights must be positive.
With Java 8 streams, it seems Functional Programming has won. Long live statelessness and recursion! Reality is a bit more nuanced: as always in software programming, it depends. I believe that the more tools in your toolbelt, the better it is. When all you have is a hammer, everything looks like a nail. In Functional Programming, every function needs to be pure: output only depends on input, and there are no side-effects. For this reason, Java methods to create infinite streams are not u
This is the 3rd post in the From Imperative to Functional Programming focus series. There's a whole category of problems related to grouping e.g.: Given a collection of person, return a list of pairs with the first value the age, and the second one the collection of persons of that age. Given a collection of orders, return a list of pairs with some price range _e.g._ $0-$100, $101-$200, etc. as the first value, and the number of such orders as the second one. Given a collection of words, return a
This is the 2nd post in the From Imperative to Functional Programming focus series. Last week, we ported the migration of a Scala application from imperative to functional in Kotlin with the help of the Arrow library. This was pretty easy: the example was laid out for us. This week, I'd like to go for more fundamental stuff.
This is the 1st post in the From Imperative to Functional Programming focus series. Some time ago, I watched the talk FP to the max. While the end of the talk is quite Scala-ish, the beginning can be of interest regardless of the language. In the talk, the speaker tries to migrate a standard imperative-like application using a functional approach. I wanted to check if it was possible to do the same in Kotlin.
Recently, I had some some fun writing functional Kotlin to solve the FizzBuzz test. I asked for some feedback, and one of the answer I received was in Clojure: In Clojure there's the classic way, with condp and mod. There's also another way using cycle that I saw some years ago. The range and the 2 cycles will generate the fizz & buzz, the rest just decides what to print.Will be easier for you with syntax highlighting -> screenshots pic.twitter.com/wOPJD0BpGM— Alexandre Gri