Deep Equality (optimized)

by Ricardo Fernández Serrata

Version 9 (June 5, 2021)

Download (19 downloads)

Checks if ANY 2 values are "deeply equal" (can check flat and nested containers). It uses an explicit stack to avoid subroutine calls, for better performance and memory usage.

I used a stack format where each frame contains a 3-tuple (array of fixed length of 3), instead of storing each value as an individual frame. S[-1] is the last (top) stack frame. S[-1][0] is the iteration index of the last frame. S[0][1] and S[0][2] are inputs A and B respectively. S[-1][1] and S[-1][2] are inner/deeper values of A and B.

If I didn't use 3-tuples, the format would've been like this: S[-1] is B, S[-2] is A and S[-3] is the iteration index. This format would require more blocks, so I fit all 3 values in 1 frame for a minified flow.

I already included example inputs, you can edit them to check correctness of this flow.


There are some special cases where "=" operator successfully detects that 2 containers are equal. This happens when 2 or more variables are referencing the same memory address (shared data structure), which allows programming languages (AM included) to easily detect the equality of these variables just by reading metadata.

This is why I included the "a = b" check, to avoid unnecessary processing, when possible

4.0 average rating from 1 reviews

5 stars
4 stars
3 stars
2 stars
1 star

Rate and review within the app in the Community section.