tree - SWI prolog make set of variables name with rbtrees or others means -


i have got term want set of variables name.

eg. input: my_m(aa,b,b,c,max(d,c),d) output: [b,c,d] (no need ordered order of appearance in input) (that call set_variable_name(input,output).)

i can [b,c,d,c,d] input, don't know how implement set (only 1 appearance in output). i've tried storing in rbtrees failed, because of

only_one([],t,t) :- !. only_one([x|xs],b,c) :- rb_in(x,x,b), !, only_one(xs,b,c). only_one([x|xs],b,c) :- rb_insert(b,x,x,u), only_one(xs,u,c). 

it returns tree 1 node , unification b=c, c=d.... think why - because of unification of x while questioning rb_in(..).

so, how store once name of variable? or fundamentally wrong idea because using logic programming? if want know why need this, it's because asked implement a* algorithm in prolog , 1 part of making search space.

you can use sort/2, removes duplicates.


Popular posts from this blog

How to calculate SNR of signals in MATLAB? -

c# - Attempting to upload to FTP: System.Net.WebException: System error -

ios - UISlider customization: how to properly add shadow to custom knob image -