# Clever Way to Check Unordered List Equality

**URL:** <https://racket.discourse.group/t/clever-way-to-check-unordered-list-equality/2919>\
**Category:** Questions & Answers\
**Created:** [May 16, 2024, 3:22pm UTC](https://racket.discourse.group/t/clever-way-to-check-unordered-list-equality/2919 "2024-05-16T15:22:18Z")\
**Posts on this page:** 1\
**Showing post:** 21

<div class="post-metadata">

**Author:** ![bakgatviooldoos](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/bakgatviooldoos/32/1381_2.png) [@bakgatviooldoos](https://racket.discourse.group/u/bakgatviooldoos)\
**Post date:** [November 23, 2024, 5:20pm UTC](https://racket.discourse.group/t/clever-way-to-check-unordered-list-equality/2919/21 "2024-11-23T17:20:33Z")

</div>

Holy smokes! I would never have thought the speed-up to be so drastic.

I reimplemented some logic [using streams](https://racket.discourse.group/t/conjunction-and-disjunction-of-streams/3352), and by golly, did that pay off.

```scheme
#hash((#<age> . 28) (#<name> . Faye) (#<meal> . Fish) (#<drink> . Aqua))
#hash((#<age> . 27) (#<name> . John) (#<meal> . Beef) (#<drink> . Aqua))
#hash((#<age> . 27) (#<name> . Nina) (#<meal> . Stew) (#<drink> . Aqua))
cpu time: 15 real time: 41 gc time: 0

```

* * *

Edit: LOL, it's because it _is_ too good to be true. My sucky code causes the evaluation of parts of the relations before it is even run... Sigh. It is cleaner with the streams, though, which isn't bad.

* * *

Just as I suspected, when amending the culprit:

```scheme
#hash((#<drink> . Aqua) (#<age> . 28) (#<name> . Faye) (#<meal> . Fish))
#hash((#<drink> . Aqua) (#<age> . 27) (#<name> . John) (#<meal> . Beef))
#hash((#<drink> . Aqua) (#<age> . 27) (#<name> . Nina) (#<meal> . Stew))
cpu time: 1203 real time: 1905 gc time: 250

```

---

_[View the full topic](https://racket.discourse.group/t/clever-way-to-check-unordered-list-equality/2919)._
