1 Replies - 454 Views - Last Post: 26 December 2014 - 04:22 AM Rate Topic: -----

#1 deore   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 01-May 12

How do i use if else statement in prolog

Posted 26 December 2014 - 03:11 AM

Hi,

I have a simple prolog code like,

read(A),
(member(A,X) ->
append([],[A],List));
read(B),
(member(B,X)->
append(List,[B],L)),
read©,
member(C,X)->
append(L,[C],L2),
printList(L2).

in this code i want to check input, if the input in list X then add it to another list. However, if my first input is in my list program returns true and does not check the other inputs.As a result, i want to modify it like check input if it is in list X then add it to another list but if it is not in the list X then continue to get other inputs.

Is This A Good Question/Topic? 0
  • +

Replies To: How do i use if else statement in prolog

#2 no2pencil   User is offline

  • Professor Snuggly Pants
  • member icon

Reputation: 6825
  • View blog
  • Posts: 31,474
  • Joined: 10-May 07

Re: How do i use if else statement in prolog

Posted 26 December 2014 - 04:22 AM

** duplicate topic closed, please reply to the origianl. **
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1