concept sublist in category kotlin

appears as: sublists, sublist, sublists
The Joy of Kotlin

This is an excerpt from Manning's book The Joy of Kotlin.

You’ll first have to implement a startsWith function to determine whether a list starts with a sublist. Once this is done, you’ll test this function recursively, starting from each element of the list.

First, you must define the number of sublists you want to use and divide the list accordingly:

divide(1024)

Then you’ll map the list of sublists with a function that’ll submit a task to the ExecutorService. This task consists of folding each sublist and returning a Future instance. The list of Future instances is mapped to a function calling get on each Future to produce a list of results (one for each sublist). You must catch the potential exceptions. Eventually, the list of results is folded with the second function, and the result is returned in a Success. In the case of an exception, a Failure is returned: