Member and List in prolog? -


i trying write code assign color state. there 5 states(tn, ms, al, ga, fl) want assign color each. have use 3 colors, , no 2 states share border can have same color. wrote code:

states(t, m, a, g, f) :-   member(t, [green, white, red]),   member(m, [green, white, red]),   member(a, [green, white, red]),   member(g, [green, white, red]),   member(f, [green, white, red]),   t = f,   g = m. 

when test code weird output! example if use code:

states(t,m,a,g,f), write(['tn', t, ' ms', m, ' al', a, ' ga', g, ' fl', f]). 

i bunch of unifier numbers! how can assign colors states? trying here saying in code tn , fl should have same color, , ga , mi should have same color! seems doing wrong. doing wrong? not color output! how assign colors states?

thanks in advance!


Comments