Data:
%flight(FID, Start, Destination, Company, Seats).
%------------------------------------------------------
flight(1, 'Paris', 'Berlin', 'Lufthansa', 210).
flight(2, 'Frankfurt', 'Dubai', 'Lufthansa', 400).
flight(3, 'Rome', 'Barcelona', 'Eurowings', 350).
I want to know all companies that, that have flights with over 200 seats. But each company should be returned only once.
I tried:
q1(Company) :- flight(_, _, _, Company, S), S > 200.
But this returns lufthansa twice. I tried:
q1(Company) :- flight(_, _, _, Company, S), S > 200,!.
But this exited after first return of Lufthansa. I think I have to wrap the condition in a sub query:
q1(Company) :- flight(_, _, _, Company, S), q12(S).
q12(S) :- flight(_, _, _, _, S), S > 200,!.
But this exited after the first return, too. Any idea how I can return a company that matches only once using cut?
FID is the primary key and I am only allowed to use . , + < > <= >=