# How does Array.Extra.all short circuit?

**URL:** <https://discourse.elm-lang.org/t/how-does-array-extra-all-short-circuit/8947>\
**Category:** Learn\
**Created:** [February 16, 2023, 7:43pm UTC](https://discourse.elm-lang.org/t/how-does-array-extra-all-short-circuit/8947 "2023-02-16T19:43:26Z")\
**Posts on this page:** 1\
**Showing post:** 8

<div class="post-metadata">

**Author:** ![rupert](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/rupert/32/1775_2.png) [@rupert](https://discourse.elm-lang.org/u/rupert)\
**Post date:** [February 23, 2023, 4:24pm UTC](https://discourse.elm-lang.org/t/how-does-array-extra-all-short-circuit/8947/8 "2023-02-23T16:24:56Z")

</div>

With Arrays I iterated over a slice using Array.get:

> <https://github.com/rupertlssmith/elm-buffer-spike/blob/main/src/elm/GapBuffer.elm#L445>

This was used to implement a GapBuffer for a text editor. I certainly found that doing it this way was efficient enough to get a UI that scrolled smoothly. But yes, the Array.get access is O(Log n), so not as fast as it could be:

> [@Efficient Text Editing Buffer](https://discourse.elm-lang.org/t/efficient-text-editing-buffer/6414):
>
> If a simple Array is used to hold lines of text, whenever a line is edited, the array will need to be sliced, lines modified, then put back together again. It works fine up to a limit at which point the editor becomes noticeably unresponsive. I scratched my head over this one for a while, thinking about various tree structures, or skip lists, and so on. Then the answer came to me - make a data structure like a zip list, but use arrays instead of lists. There are lots of packages implementing zi…

Demo: [https://kind-colden-ebafc2.netlify.app/](https://kind-colden-ebafc2.netlify.app/)

---

_[View the full topic](https://discourse.elm-lang.org/t/how-does-array-extra-all-short-circuit/8947)._
