<html><body><div>btw here's my ugly solution</div><div><br></div><div><div>type Node = Char</div><div>type Arc  = (Node, Node)</div><div><br></div><div>solve [] arcs =<span class="Apple-tab-span" style="white-space:pre">     </span>[]</div><div>solve (x:xs) arcs = (filter (/= ' ') $ map (fmove x) arcs) ++ (solve (filter (/= ' ') $ map (fmove x) arcs) arcs)</div><div><br></div><div>fmove::Char->(Char,Char)->Char</div><div>fmove s (x,y)</div><div>    | s == x = y</div><div>    | otherwise = ' '</div><div><br></div><div><strong><em>isGraph s e arcs = (length $ filter (==e) (take 20  $ solve [s] arcs)) > 0</em></strong></div></div><div><br></div><div>This last check for isGraph should not use this evil number....."20"...coz of infinite list...Hopefully should be able to figure it out..</div><div><br></div><div>-Animesh<br><strong><em><br></em></strong></div><div><strong><em>On Mar 05, 2015, at 09:59 PM, Animesh Saxena <animeshsaxena@icloud.com> wrote:</em></strong><br><br></div><div><blockquote type="cite"><div class="msg-quote"><div>I have a simple function </div><div><br></div><div><div>fmove::Char->(Char,Char)->Char</div><div>     fmove s (x,y)</div><div>     | s == x = y</div><div>     | otherwise = s</div></div><div><br></div><div>If I say fmove 'a' ('a','b') it will move to 'b'</div><div>If I say fmove 'a' ('d','c') it will stay at 'a'</div><div><br></div><div>Now I am trying to use this for graph, coz one move can result in multiple result nodes. For example in graphs you can have move from a to b and a to c. So I was trying something like this,</div><div><br></div><div>:t (map fmove s) where s is the set of possible start nodes "abcd"</div><div><br></div><div>(map fmove s) :: [(Char, Char) -> Char]</div><div><br></div><div>Now I want to be able to pass the graph to this function and get all possible list of endings. For example my graph can be like [('a','b'),('b','c'),('c','a'),('c','d'),('e','a')]. You can see that both 'a' and 'd' are possible from node 'c'. </div><div><br></div><div>I can see that above type signature is wrong for passing the whole graph coz it accepts <span style="line-height: 1.5;" data-mce-style="line-height: 1.5;">[(Char, Char) -> Char]. I initially started with foldl but problem is recursion on top of foldl. The actual objective of the problem is to figure out if a node is reachable from a start node or not. Hope the problem is clear, can anyone suggest how to convert the map function to accept the graph? </span></div><div><span style="line-height: 1.5;" data-mce-style="line-height: 1.5;"> <br> </span></div><div><span style="line-height: 1.5;" data-mce-style="line-height: 1.5;">For each of the possible start nodes (accumulating at each step) it should apply it to the same graph. </span></div><div><span style="line-height: 1.5;" data-mce-style="line-height: 1.5;"> <br> </span></div><div><span style="line-height: 1.5;" data-mce-style="line-height: 1.5;">-Animesh</span></div><div><br></div><div><br></div><div class="_stretch"><span class="body-text-content">_______________________________________________<br>Beginners mailing list<br> <a href="mailto:Beginners@haskell.org" data-mce-href="mailto:Beginners@haskell.org">Beginners@haskell.org</a> <br> <a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners" data-mce-href="http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners">http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners</a> <br> </span></div></div></blockquote></div></body></html>