Intersection of Two Lists of Tuples in Prolog -


i trying find intersection of 2 lists in prolog using intersection() function. unfortunately, code giving undesirable results.

here have:

resulta = [ ('10:00 - 11:15 am', 'tr'), ('6:00 pm - 8:50 pm', 't'), ('6:00 pm - 8:50 pm', 'r'), ('6:00 pm - 8:50 pm', 'm')].  resultb = [ ('6:00 pm - 8:50 pm', 'r'), ('3:00 pm - 3:50 pm', 'tr')].  intersection(resulta, resultb, ab). 

the desired output ('6:00 pm - 8:50 pm', 'r') however, code returns resulta = ab, ab = [].

does have idea on how fix issue?

edit

resulta , resultb generated bagof() operations. actual code is:

1 ?- bagof((time, days), course^teaches_at('dr. j. leidig', course, time, days), resulta). resulta = [ ('10:00 - 11:15 am', 'tr'), ('6:00 pm - 8:50 pm', 't'), ('6:00 pm - 8:50 pm', 'r'), ('6:00 pm - 8:50 pm', 'm')].  2 ?- bagof((time, days), course^teaches_at('dr. el-said', course, time, days), resultb). resultb = [ ('6:00 pm - 8:50 pm', 'r'), ('3:00 pm - 3:50 pm', 'tr') 

sorry confusion.

the code in question queries prolog.

there 3 different queries: each query ends period. 3 queries independent, if share variables same names.

to want change periods commas:

resulta = [ ('10:00 - 11:15 am', 'tr'), ('6:00 pm - 8:50 pm', 't'), ('6:00 pm - 8:50 pm', 'r'), ('6:00 pm - 8:50 pm', 'm')], resultb = [ ('6:00 pm - 8:50 pm', 'r'), ('3:00 pm - 3:50 pm', 'tr')], intersection(resulta, resultb, ab). 

update after question updated:

bagof((time, days), course^teaches_at('dr. j. leidig', course, time, days), resulta), bagof((time, days), course^teaches_at('dr. el-said', course, time, days), resultb), intersection(resulta, resultb, ab). 

Comments

Popular posts from this blog

php - SPIP: From Tag directly to an article -

jquery - isAjaxRequest always return false -

ruby on rails - In a controller spec, how to find a specific tag in the generated view? -