
Hi haskellers, I have made one recursive function, where input is: nodesIds: [1,2,4,3,5] edgesIds: [(3,5),(4,3),(2,4),(1,2)] and on output I need/have: [([1,2,4,3,5],(3,5)),([1,2,4,3],(4,3)),([1,2,4],(2,4)),([1,2],(1,2))] 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? joinEdgeNodes' :: [Int] -> [Int] -> [(Int, Int)] -> [([Int], (Int, Int))] joinEdgeNodes' [] _ [] = [] joinEdgeNodes' [] _ _ = [] joinEdgeNodes' _ _ [] = [] joinEdgeNodes' (n) (wn) [e] = [(n, e)] joinEdgeNodes' (n) [] (e:es) = joinEdgeNodes' n edgeNodes es ++ [(edgeNodes, e)] where edgeNodes = take 2 n joinEdgeNodes' (n) (wn) (e:es) = joinEdgeNodes' n edgeNodes es ++ [(edgeNodes, e)] where edgeNodes = take edgeNodesLength n edgeNodesLength = (length wn) + 1 I call the function with: let l = joinEdgeNodes' nodeIds [] edgeIds Cheers, Miro