Is there a way to consolidate the facts?

Is there any way to do this:

genre(blues). gere(hiphop). genre(rock). 

In something like this:

 genre(blues;hiphop;rock). 

* I know that this does not work, but something like this exists.

+4
source share
3 answers

You cannot consolidate facts, but you can turn them into a simple rule, for example:

 genre(X) :- member(X, [blues, hiphop, rock]). 

member/2 is a built-in list predicate in the SWI for verifying list membership.

+2
source

This allows you to apply the predicate to all elements of the list and will be successful only if all applications succeed.

 test_list( _, [] ). test_list( F, [H|T] ) :- P =.. [F,H], P, test_list( F, T ). 
+1
source

You can use this syntax

 genre(X) :- X=blues ; X=hiphop ; X=rock. 

but personally I advise the member / 2 ways ...

0
source

Source: https://habr.com/ru/post/1441688/