Lists are a fundamental data of functional programming languages. In statically typed languages like Elm all elements of the list are of the same type. Lists are immutable. You never change the list's value. Instead you create new lists, sometimes as modified versions of an input list.

Problem 1 - Get last element of a list.

Problem 2 - Get penultimate element of a list.

Problem 3 - Get the element of a list at a specified index.

Problem 4 - Get the count of elements in a list.

Problem 5 - Reverse a list.

Problem 6 - Determine if a list is a palindrome.

Problem 7 - Flatten nested lists.

List Extras

Many of the solutions to problems in this book can take advantage of some commonly used list manipulation functions. The Elm community created the List.Extra module which is well worth your time to peruse. These functions will be familiar to experienced functional programmers, especially Haskell programmers.

Since List.Extra is not part of the Elm core we won't use the module in this book. However some of the functions are inescapably useful. So let's add a few extra problems to the original 99, so we can use them in later solutions.

Extra 1 - dropWhile

Extra 2 - takeWhile

More problems

Problem 8 - Eliminate consecutive duplicate elements from a list.

Problem 9 - Place consecutive duplicate elements of a list into a list of lists.

results matching ""

    No results matching ""