starvedcat
V2EX  ›  问与答

有没有人懂 Prolog?

  •  
  •   starvedcat · Mar 10, 2017 · 1353 views
    This topic created in 3376 days ago, the information mentioned may be changed or developed.
    我现在有如下程序:

    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 replies    2017-03-10 14:29:12 +08:00
    starvedcat
        1
    starvedcat  
    OP
       Mar 10, 2017
    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 ,应该怎么做?
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3815 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 36ms · UTC 04:23 · PVG 12:23 · LAX 21:23 · JFK 00:23
    ♥ Do have faith in what you're doing.