user1118501
user1118501

Reputation: 71

check double list in prolog

I have a predicate called check(A,B). that checks if list A matches with another list B.

I need to make a predicate that checks if a list's elements are single lists.

Upvotes: 0

Views: 1426

Answers (2)

Scott Hunter
Scott Hunter

Reputation: 49803

Something like this?

checkList([],[]).
checkList([A|A2],[B|B2]) :- check(A,B), checkList(A2,B2).

This assumes that if A & B aren't "single lists", then check will fail (which sounds like what you want).

Upvotes: 1

Scott Hunter
Scott Hunter

Reputation: 49803

Why couldn't you just use

check(A,B) :- A=B.

Then it wouldn't matter what kinds of elements the lists were made up of; heck, they wouldn't haven to be lists at all!

Upvotes: 0

Related Questions