V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
starvedcat
V2EX  ›  问与答

有没有人懂 Prolog?

  •  
  •   starvedcat · 2017-03-10 14:27:47 +08:00 · 923 次点击
    这是一个创建于 2670 天前的主题,其中的信息可能已经有所发展或是发生改变。
    我现在有如下程序:

    location_set(1, 2).
    location_set(1, 3).
    location_set(1, 4).

    init :-
    location_set([X, Y]),
    assert( location([X, Y]) ).

    然而这样执行了以后, KB 里只有 location(1, 2).。那么,如果我想把所有符合 location_set([X, Y]).的都 assert ,应该怎么做呢?
    1 条回复    2017-03-10 14:29:12 +08:00
    starvedcat
        1
    starvedcat  
    OP
       2017-03-10 14:29:12 +08:00
    http://www.swi-prolog.org/pldoc/doc_for?object=asserta/1

    Term is asserted as the first fact or clause of the corresponding predicate.

    这里写的很明确了,只对第一条 fact or clause 进行操作
    如果我想 assert 所有的 fact ,应该怎么做?
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   5035 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 30ms · UTC 08:27 · PVG 16:27 · LAX 01:27 · JFK 04:27
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.