2008 October 29th Wednesday (十月 二十九日 水曜日)

 %data
love(zhangxueyou, wanfei).
love(zhangxueyou, zouhuimin).
love(wanfei, xietinfen).
love(zouhuimin, zhangxueyou).
love(xietinfen, wanfei).
love(xietinfen, zouhuimin).
love(liudehua, zouhuimin).

%rules
lovers(X,Y) :- love(X,Y),love(Y,X).

%rival_in_love(X,Y) :- love(X,Z),not(love(Z,X)),love(Z,Y).
rival_in_love(X,Y) :- love(X,Z),love(Z,Y),X/=Y.

  The above is a example in prolog programming language.  I found that the "not" is ineffective in GNU Prolog.  So, I have to
modify the rule "rival_in_love" by using "/=".  Although, during developing I am aware that if we have "not" predicator we have
to adopt a non-natural or inconveniently way to slove our problem.

  I re-debuged the prolog example command_loop.  The following coding is also effective.  I changed the "X == 'end'" to "X = 'end'".
Yes, unification will resulte in success.

cmd_loop :-
  repeat,
  write('Enter command (end to exit): '),
  read(X),
  write(X),
  nl,
  X = 'end', !.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值