Never miss a beat

Join my newsletter.

Tag: functional programming

Lambda-Map Performance in Kotlin

Published: 11/19/2018

Working on an enterprise application written in Kotlin, I’ve recently noticed something that felt “off” to me. Perhaps you’ve seen it, perhaps you’ve written it — maybe even recently! It looks something like this (I call this a Lambda-Map): Sure, this plusOne function isn’t really necessary. We can just inline it in the Lambda, but imagine for just a moment that this function does much, much more than just add one to a number. It then feels just to have that code pulled out into a private…

Sequence: A Kotlin Type

Published: 11/3/2018

Kotlin, despite being an object oriented language, offers a ton of support for Functional paradigms. One of the most common functional paradigms involves using a combination of map , filter , and reduce on Iterable types. However, Kotlin uses extension functions on Java Collections to create these functions in their standard library. That means that when you call map on a list, you’ll return a new list. This is usually intended, however, it can become problematic when chaining multiple…