Functional collections

It's quite a different picture in functional languages. Let's have a look at the same abstraction, the List, in Scala's library. Its API documentation is available at https://www.scala-lang.org/api/current/scala/collection/immutable/List.html. It contains many more methods than can be found in Java's List. In contrast to the Java List interface, Scala's List abstraction is immutable. This means that once you have created a list, you are not able to modify it. All the modifications to the list can be implemented by just creating a modified copy of the list. This concept is referred to as structural sharing. This means that the objects that are members of the list are not copied, just that the structure of the list is ...

Get Mastering Functional Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.