2008/10/31 Imre Palik <span dir="ltr"><<a href="mailto:imre@u-tx.com">imre@u-tx.com</a>></span><br><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
During playing with project Euler I solved a few constraint satisfaction problems with erlang.  But whenever I code a solution, I have a really awkward feeling, that it should be possible to do better, but I don't know how.<br>

<br>
I tend to code a backtracking search with constraint propagation before every step.  I model the constraint graph with digraph, but then the non-functional nature of the digraph package makes backtracking really awkward.<br>

<br>
Is there any better way to solve constraint satisfaction problems?<br>
What is the rationale behind those pesky side effects in digraph?</blockquote><br>I don't think is there is a deeper rationale behind the side effects in digraph other than that they are a result of it using ets internally.<br>
<br>One solution would be to rewrite it, or at least a part of it, using dict or gb_trees but that might be overkill for what you want to do. Depends, I suppose, on how much functionality you need.<br><br>What type of constraints are they? If your backtracking search algorithm is more suitable for prolog you could try erlog which is a prolog interpreter written in erlang.<br>
<br>Robert<br><br></div>