# Equality of LazyLists

**URL:** <https://discuss.ocaml.org/t/equality-of-lazylists/1192>\
**Category:** Learning\
**Tags:** lazy, batteries\
**Created:** [November 24, 2017, 6:30pm UTC](https://discuss.ocaml.org/t/equality-of-lazylists/1192 "2017-11-24T18:30:02Z")\
**Posts on this page:** 1\
**Showing post:** 12

<div class="post-metadata">

**Author:** ![mars0i](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/mars0i/32/1058_2.png) [@mars0i](https://discuss.ocaml.org/u/mars0i)\
**Post date:** [November 26, 2017, 6:33pm UTC](https://discuss.ocaml.org/t/equality-of-lazylists/1192/12 "2017-11-26T18:33:54Z")

</div>

Thanks @kantian for those suggestions and background investigation! I’ll try to PR those when I get a chance. I was about to write a PR for `LazyList.equal` the other day when I realized that embedded lazy lists would create a problem for the simple definition without the optional argument, and then noticed `equal` in the `Enum` docs, and wanted to see what response I got in this thread.

> In this case, it may me more useful to mimic the forall2 definition to not raise an exception

By default I usually incline toward making use of functions that are already there, i.e. `for_all2` in this case. After all, maybe someone will come up with a more efficient implementation of `for_all2`, and then `equal` will benefit. (The recent discussion of [alternative `List.map` implementations](https://discuss.ocaml.org/t/a-new-list-map-that-is-both-stack-safe-and-fast/865) was striking.) Is wrapping `for_all2` in `try`/`with` potentially less efficient? Or just aesthetically undesirable? I don’t know anything about the exception mechanism, and am not sure I want to try to figure it out right now.

---

_[View the full topic](https://discuss.ocaml.org/t/equality-of-lazylists/1192)._
