Comparing nlists containing nodes
Hi,
I've got two lists of nodes. The contained nodes are copies of each other. Thus, when "logging" the content of the lists it looks like:
... nlist1 contains: [node1, node2]
... nlist2 contains: [node1, node2]
I want to use the lists like:
if(nlist1 != nlist2) {...}
!= seems not to be the proper operator for doing this. Is there a special operator or am I required to iterate over the lists and compare single elements?
Thanks,
Henning
Please sign in to leave a comment.
Hi Henning,
you would have to define what it means that two nodes are "equal".
If you have a node A and a node A*, which is a copy of A, they cannot be referentially equal, since they are two different objects. If I understand you correctly, you want an operator or operation that takes two nlist objects and returns true if and only if the two lists contain
Now, comparing two MPS nodes is quite tricky and again you would have to define what "equality" means to you, since a node A can have children and references to other nodes.
There are some ways that might solve your specific issue.
I've implemented a custom node navigation API to handle node navigation in general, and use it to handle different "equality requirements" in my languages. Unfortunatelly, I cannot make it open source yet, but maybe I'll find some time to do this soon.
best,
Robert