0
votes

I'm new to prolog language recently started teaching my self this language I came across an interesting question which says to Write a database for a predicate cycle/1 such that query

cycle(X)

returns the instantiations
   X = food 
   X = me 
   X = pizza  
   X = food 
   X = me 
   X = pizza 

in an endless cycle 

How do we do that can someone help me out am trying to touch my self this language!

hence: it's JUST FOR LEARNING PURPOSES!

1
also, what(food). what(me). what(pizza). cycle(X):- repeat, what(X). - Will Ness
@WillNess can u have a look in the other question i asked ? - Cold_SOUL
it's gone. :| do you have a link? (even if it's deleted I could see it, but I need a link). - Will Ness
@WillNess hey there I just undeleted the question would really appreciate your help! here is the link : stackoverflow.com/questions/59114028/… - Cold_SOUL

1 Answers

2
votes
cycle(food).
cycle(me).
cycle(pizza).
cycle(X):-cycle(X).