Prolog - Remove sublists from a list
so I have a list which contains sublists in the format [[x,y,Sum,Product][....]] . I now need to remove the sublists from this list in which BOTH X and Y are prime.

So far I'm progressing quite well with this, I have a predicate to determine whether a number is prime, and I have some code which cycles through the whole list and passes a certain number to isprime(). 

Here's what I have:

    removePrimes([], _, []) :- !.
    removePrimes([[Hx|[Hy|_Tail1]]|Tail], X, L) :-
        isprime(Hx), !,

    removePrimes(Tail, X, L).
    removePrimes([Head|Tail], X, [Head|L]) :-
        removePrimes(Tail, X, L).

So far this works fine, it removes any sublist which has X as a prime number. However, if I change it to:

    removePrimes([[Hx|[Hy|_Tail1]]|Tail], X, L) :-
        isprime(Hx), isprime(Hy), !,

Then it doesn't work, and i'm not quite sure why. I think it may be something to do with the misuse of the cut, but I could be wrong.


Prolog - Remove sublists from a list
===

so I have a list which contains sublists in the format [[x,y,Sum,Product][....]] . I now need to remove the sublists from this list in which BOTH X and Y are prime.

So far I'm progressing quite well with this, I have a predicate to determine whether a number is prime, and I have some code which cycles through the whole list and passes a certain number to isprime(). 

Here's what I have:

    removePrimes([], _, []) :- !.
    removePrimes([[Hx|[Hy|_Tail1]]|Tail], X, L) :-
        isprime(Hx), !,

    removePrimes(Tail, X, L).
    removePrimes([Head|Tail], X, [Head|L]) :-
        removePrimes(Tail, X, L).

So far this works fine, it removes any sublist which has X as a prime number. However, if I change it to:

    removePrimes([[Hx|[Hy|_Tail1]]|Tail], X, L) :-
        isprime(Hx), isprime(Hy), !,

Then it doesn't work, and i'm not quite sure why. I think it may be something to do with the misuse of the cut, but I could be wrong.

