Prolog - How to assert/make a database only once

后端 未结 2 1191
隐瞒了意图╮
隐瞒了意图╮ 2021-01-21 00:33
resultList(UsersQuery):-
    question(X,H),
    write(H),
    myintersection(H,UsersQuery,Match,TotalQuestionKeywords),
    Percent is Match/TotalQuestionKeywords*100,
          


        
相关标签:
2条回答
  • 2021-01-21 01:10

    Maybe do retractall/1 before you rerun your program.

    0 讨论(0)
  • 2021-01-21 01:20

    Make a separate predicate for assertion that checks if fact is not yet asserted:

    assertThisFact(Fact):-
        \+( Fact ),!,         % \+ is a NOT operator.
        assert(Fact).
    assertThisFact(_).
    
    0 讨论(0)
提交回复
热议问题