Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/minibill/elm-rope

List-like data structure with fast concatenation
https://github.com/minibill/elm-rope

Last synced: about 8 hours ago
JSON representation

List-like data structure with fast concatenation

Awesome Lists containing this project

README

        

# elm-rope

A `Rope` is a data structure similar to a list, but supporting fast concatenation at both ends.

It's useful when you're concatenating many lists, especially if recursively. You can build a `Rope` and then call `toList` at the end and only do the concatenation once.

# Example

```elm
import Rope

ten : Rope Int
ten =
Rope.fromList (List.range 1 10)

result : List Int
result =
ten
|> Rope.concatMap
(\one ->
ten
|> Rope.concatMap
(\two ->
ten
|> Rope.concatMap
(\three ->
Rope.fromList [ one, two, three ]
)
)
)
|> Rope.toList
```