[ create a new paste ] login | about

Link: http://codepad.org/qr0ntRNJ    [ raw code | output | fork ]

Haskell, pasted on Mar 12:
1
2
3
4
5
6
7
8
data Node = Node [Node] deriving Show

children (Node ns) = ns

descendants :: Node -> [Node]
descendants n = n : (concatMap descendants $ children n)

main = print $ descendants (Node [Node [Node [], Node [Node []]]])


Output:
1
[Node [Node [Node [],Node [Node []]]],Node [Node [],Node [Node []]],Node [],Node [Node []],Node []]


Create a new paste based on this one


Comments: