Hello all,<br><br>I have a very interesting alternative solution of the problem. First I generate a tree with all the permutations:<br><br>eg if I want to find al permutations of ao, I get the following tree<br><br>   [a   @]<br>
    |     |<br>  [o 0] [o 0]<br><br>Then I walk trough the tree so I can print it. There is only one ugly thing. Showtree&#39; returns a string (in our example aoa0@o@0). To make it a list i put a \n between a left and right node and then use lines to make it a list of strings. Can someone point me in the right direction how to beautify it a bit?<br>
<br>I also have an annoying problem with gmail and firefox. It seems it doesn add my posts to the current thread, but starts a new one. Oh well think I switch to evolution. I will review all yours solutions tomorrow. I saw some very beautifull things. <br>
<br>With kind regards,<br><br>Edgar Klerks<br><br>module Main where<br>import Data.Char<br><br>data WordTree = Chain (Char,WordTree)<br>        |   Choice (Char, WordTree) (Char, WordTree)<br>        |   Stop<br><br>instance Show WordTree where<br>
        show = unlines.showTree<br><br>type Rule = (Char, Char)<br>type Rules = [Rule]<br><br>infixl 4 ==&gt;<br><br>a ==&gt; b = (a,b)<br><br>rules :: Rules<br>rules = [ &#39;a&#39; ==&gt; &#39;@&#39;, &#39;l&#39; ==&gt; &#39;|&#39;]<br>
<br><br>buildTree :: String -&gt; Rules -&gt; WordTree<br>buildTree [] r = Stop<br>buildTree (c:cs) r = case lookup c r of<br>                        Just a -&gt; Choice (a, buildTree cs r) (c, buildTree cs r)<br>                        Nothing -&gt; Chain (c, buildTree cs r)<br>
<br><br>showTree a = lines $ showTree&#39; a []<br><br>showTree&#39; (Chain (a,b)) p  = a : showTree&#39; b p<br>showTree&#39; (Choice (a,b) (c,d)) p  = c : showTree&#39; d p ++ &quot;\n&quot; ++ (a : showTree&#39; b p)        <br>
showTree&#39; (Stop) p   = p<br><br>