Closed ilohmar closed 1 year ago
Quoting gpt4: April uses a “flat” representation of nested arrays, where each element is either a scalar or an array reference. This means that two nested arrays that look identical may have different internal structures and thus different identities.
For example, in Dyalog, (⊂1 2 3)≡⊂1 2 3 returns 1 because both sides are identical nested arrays. However, in April, (⊂1 2 3)≡⊂1 2 3 returns 0 because both sides are different array references that point to different copies of 1 2 3. To make them equal, you would need to use the same reference on both sides, such as v←1 2 3 ◊ (⊂v)≡⊂v.
...there is an alternative way to compare two arrays structurally in April. You can use the ≡ symbol with a dot on the left side, such as .≡. This will compare two arrays by their shape and contents, regardless of their internal references.
This answer came from GPT4? It's not accurate, this is in fact a bug. April's ≡
performs a deep comparison, of array values, it does not compare memory locations. Different arrays in memory with the same contents should return 1 when passed to ≡
. I'll look into this shortly.
There was a bug in the comparison function, it's been fixed. This has also been a case study in the dangers of relying on GPT for accurate information. I guess at some point there were internet discussions about a comparison function that did reference checking that looked similar to the question zurqlisp asked, causing GPT to construct this answer that its language model deemed the most likely response.
I am just getting sucked into APL, via this project, and it's amazing (APL and the Common-Lisp compilation!). Please excuse me if the following is due to my lack of understanding APL, or if it's a known difference b/w APL implementations.
I followed several APL tutorials, experimented myself etc, and stumbled at:
Finally I tried the same expression at the (Dyalog) REPL TryAPL, where it yields 1 (as I expected).
This is the simplest case of (presumably) the same phenomenon in several guises. What's more, I could not manage to observe any difference in shape, rank of the two sides in April, eg, using disclose to go back again --- once they are different, I am unable to manipulate them to become the same again (without dropping into individual elements of the nested vector).
Any hints or help?