Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //dfs
- domains
- X=symbol
- Y=symbol*
- predicates
- child(X,X)
- childnode(X,X,Y)
- path(X,X,Y)
- clauses
- child(a,b). /*b is child of a*/
- child(a,c). /*c is child of a*/
- child(a,d). /*d is child of a*/
- child(b,e). /*b is child of b*/
- child(b,f). /*f is child of b*/
- child(c,g). /*g is child of c*/
- path(A,G,[A|Z]):- /*to find the path from root to leaf*/
- childnode(A,G,Z).
- childnode(A,G,[G]):- /*to determine whether a node is child of other*/
- child(A,G).
- childnode(A,G,[X|L]):-
- child(A,X),
- childnode(X,G,L).
- goal:path(a,e,L).
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement