<div dir="ltr">Hi haskellers, I have made one recursive function, where<div><br></div><div><br></div><div>input is:</div><div><div><font face="times new roman, serif">   nodesIds: [1,2,4,3,5]</font></div><div><font face="times new roman, serif">   edgesIds: [(3,5),(4,3),(2,4),(1,2)]</font></div><div><br></div><div>and on output I need/have:</div><div><font face="garamond, serif">   [([1,2,4,3,5],(3,5)),([1,2,4,3],(4,3)),([1,2,4],(2,4)),([1,2],(1,2))]</font></div></div><div><br></div><div>I have made one function for this, but it seems to me a bit too big and 'ugly'? Please, do you have any hints for a more elegant solution?</div><div><br></div><div><div><font face="garamond, serif">joinEdgeNodes' :: [Int] -> [Int] -> [(Int, Int)] -> [([Int], (Int, Int))]</font></div><div><font face="garamond, serif">joinEdgeNodes' [] _ [] = []</font></div><div><font face="garamond, serif">joinEdgeNodes' [] _  _ = []</font></div><div><font face="garamond, serif">joinEdgeNodes'  _ _ [] = []</font></div><div><font face="garamond, serif">joinEdgeNodes' (n) (wn) [e] = [(n, e)]</font></div><div><font face="garamond, serif">joinEdgeNodes' (n) [] (e:es) = joinEdgeNodes' n edgeNodes es ++ [(edgeNodes, e)]</font></div><div><font face="garamond, serif">   where edgeNodes = take 2 n</font></div><div><font face="garamond, serif">joinEdgeNodes' (n) (wn) (e:es) = joinEdgeNodes' n edgeNodes es ++ [(edgeNodes, e)]</font></div><div><font face="garamond, serif">   where edgeNodes = take edgeNodesLength n</font></div><div><font face="garamond, serif">         edgeNodesLength = (length wn) + 1</font></div></div><div><font face="garamond, serif"><br></font></div><div>I call the function with: <span style="font-family:garamond,serif">let l = joinEdgeNodes' nodeIds [] edgeIds</span><font face="garamond, serif"><br></font></div><div><span style="font-family:garamond,serif"><br></span></div><div><span style="font-family:garamond,serif"><br></span></div><div><span style="font-family:garamond,serif"><br></span></div><div>Cheers, </div><div>Miro<br></div></div>