# fold

As a quick note today, if you ever need some examples of how the Kotlin collections methods work, I hope these examples are helpful.

## Sample data

First, here’s some sample data:

```
val a = listOf(10, 20, 30, 40, 10)
val names = listOf("joel", "ed", "chris", "maurice")
```

This page contains a large collection of examples of how to use the Scala Map class, including most of the methods that are available on a Vector. (Currently well over 100 examples.)

## Scala: How to use fold on an Option (syntax)

## Scala List class: methods, examples, and syntax

This page contains a large collection of examples of how to use the methods on the Scala List class.

The Scala List class as an immutable, linear, linked-list class. It’s very efficient when it makes sense for your algorithms to (a) prepend all new elements, (b) work with it in terms of its head and tail elements, and (c) use functional methods that traverse the list from beginning to end, such as `filter`

, `map`

, `foldLeft`

, `reduceLeft`

.

- Read more about Scala Seq class: methods, examples, and syntax
- Log in to post comments

This page contains a large collection of examples of how to use the methods on the Scala Seq class.

## Important note about Seq, IndexedSeq, and LinearSeq

As an important note, I use `Seq`

in the following examples to keep things simple, but in your code you should be more precise and use `IndexedSeq`

or `LinearSeq`

where appropriate. As the `Seq`

class Scaladoc states:

This page contains a collection of examples of how to use Scala Vector class informational and mathematical methods. Note that these same methods will also work with a Scala `Seq`

, including `IndexedSeq`

.

## Informational and mathematical methods

As the name implies, these methods let you get information about the contents of a `Vector`

, or perform mathematical expressions on a `Vector`

.

## Scala Vector class: method examples and syntax

## A Scala ‘foldLeft’ function written using recursion

As a short note, here’s some Scala source code that shows how to write a `foldLeft`

function using recursion: