Function return false - Swi-Prolog -


i working on proyect programming classes. work resolve skyline problem. city's skyline outer contour of silhouette formed buildings in city when viewed distance. so, basically, take list of buildings 3 parameters each (initial position,final position, height) , have return coordinates of skyline.

i have 2 base cases. first 1 used when list empty. second 1 if there 1 building , last 1 used when have 2 or more buildings in list. function 'divide' receives list of buildings , returns 2 lists of buildings.

my problem is:

divide([],[],[]). divide([c|[]],[c|ed(x1,x2,h1)]):-    divide([],ed(x1,x2,h1),[]). divide([ed(x1,x2,h1),ed(y1,y2,h2)|l],l1,l2):-    l1 = [ed(x1,x2,h1)|l1],    l2 = [ed(y1,y2,h2)|l2],    divide(l,l1,l2). 

when run function 'divide' on console returns false answer instead of returning list. can't figure out wrong or problem might be. should return 2 lists, not 'false'.

an example:

?- divide([(1,2,3),(2,3,4),(1,4,5),(6,2,4)],x,y).  false. 

any ideas? sorry bad english , thanks.

always @ warnings prolog system produces. if ignore them, don't surprised fail. here another error:

divide([c|[]],[c|ed(x1,x2,h1)]):-                  ^^^^^^^^^^^^ 

this not formed list.


Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -