<html><head></head><body>Well, it makes a difference for me if I have twice the same subtree or sharing one subtree from several places. Later, I add some markers, thus, I know it is already processed or not.<br><br>Adding unique numbers and counting them makes sense if I know the result. If not then I don't know how to exploit it. But I may be tired too much already. :-(<br><br>Anyway, probably more imperative style would be a better option.<br><br>Thanks all,<br><br>Dušan<br><br><br><div class="gmail_quote">8. července 2020 18:13:34 SELČ, Viktor Dukhovni <ietf-dane@dukhovni.org> napsal:<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<pre class="k9mail">On Wed, Jul 08, 2020 at 08:17:41AM +0200, Dušan Kolář wrote:<br><br><blockquote class="gmail_quote" style="margin: 0pt 0pt 1ex 0.8ex; border-left: 1px solid #729fcf; padding-left: 1ex;">Nevertheless, I do even some transformations. Thus, I would like to know it is still a <br>DAG, not adding, accidentally, a node.<br><br>Is there any way, if I have data like<br><br>data Ex<br> = Val Int<br> | Add Ex Ex<br> <br>so that I can test that some value Val i === Val i ? I mean, the pointers go to the <br>same data box? I could do that via some IORefs, AFAIK, but I don't think it is <br>feasible. Maybe to tune the algorithm...<br></blockquote><br>If, for the same "n", two "distinct" leaf nodes "Val n" are possible, in<br>what sense is what you have still a DAG? If there's a difference<br>between:<br><br> Add<br> / \<br> / \<br> / \<br> v v<br> Val 1 Val 1<br><br>and:<br><br> Add<br> / \<br> / \<br> \ /<br> v v<br> Val 1<br><br>then perhaps the data model is flawed by failing to capture the<br>distinguishing attributes of distinct leaf objects. And of course<br>you might also have:<br><br> Add<br> / \<br> / \<br> \ /<br> v v<br> Add<br> / \<br> / \<br> / \<br> v v<br> Val 1 Val 2<br><br>So the most portable approach would be to assign a unique serial number<br>all the nodes, both "Add", and "Val", and check that there's only path<br>from the root to each distinct node (by serial number). Or, equivalently,<br>a recursive enumeration of all the serial numbers contains no duplicates.<br></pre></blockquote></div></body></html>