2 Replies - 626 Views - Last Post: 30 September 2012 - 12:59 PM Rate Topic: -----

#1 UNIcoder  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 7
  • Joined: 30-September 12

Prolog: Express the predicate member2 using the predicate append only

Posted 30 September 2012 - 11:31 AM

Im not quite sure how to do this. (Recursion is not allowed)
It should only succed if there is two consecutive values in the list.

I would make member2 and then try work it in append.

member2a(X,L).
append([],X,X).
append(_,[X,X|_],X) :- member2a(X,[]).


Is This A Good Question/Topic? 0
  • +

Replies To: Prolog: Express the predicate member2 using the predicate append only

#2 UNIcoder  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 7
  • Joined: 30-September 12

Re: Prolog: Express the predicate member2 using the predicate append only

Posted 30 September 2012 - 12:35 PM

Like this ofcourse

member2a(X,[X,X|_]).
member2a(X,[_|T]) :- append(_,[X,X|_],X), append(_,[T|_],X).


Was This Post Helpful? 0
  • +
  • -

#3 UNIcoder  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 7
  • Joined: 30-September 12

Re: Prolog: Express the predicate member2 using the predicate append only

Posted 30 September 2012 - 12:59 PM

Close the thread I figured it out by myself.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1