prolog-assert

    0熱度

    1回答

    我正在嘗試製作一個程序,用戶可以回答問題以查找遊戲,但我無法理解如何使用列表和聲明。我嘗試了另一種程序點系統的方式。該方案是這樣的: yeah:- write('Please answer the questions to find the game which suite you!'), nl, find(Game), nl, write('I

    0熱度

    1回答

    %Examples %course_meetings(maths4,tutorial,t07,khaled_mohamed,'tutorial for t07') %days([sat,sun...]) %tutorialrooms([c6301,b4108,c2201,c2301,c2202,c2203]) %slots([1,2,3,4,5]) day_tut(Day,Slot

    0熱度

    1回答

    我嘗試創建序言一個簡單的程序,但我有一個問題(?): :- dynamic at/2, i_am_holding/1, i_am_at/1. /* some lines of code */ i_am_at(room1). at(revolver, room1). take(revolver) :- write('You picked up the revolver.'),nl.

    2熱度

    1回答

    事實在序言中,如果我斷言某些事實,例如: assert(boy(john4)). assert(boy(john3)). assert(boy(john2)). assert(boy(john1)). 我如何保存在文件中這一事實?

    0熱度

    2回答

    我,在這樣的文件「students.pl」由學生數據庫的知識基礎: % student(Name,Percent,List_of_Marks_in_3_subjects). student('abc',83,[80,80,90]). student('pqr',70,[70,60,80]). student('xyz',76,[80,70,80]). 我想從知識庫獲取每個學生謂詞和計算每

    0熱度

    3回答

    我有這個序言問題,我不能解決。我試圖達到的目的是斷言FACT A,當我輸入時收回事實B:取得並斷言事實B,並在輸入時撤銷事實A. 即: :- dynamic s/2. :- dynamic s/3. s(P0, s(V, NP)) --> v(P1, V), np(P2, NP), {P0 is P1*P2*0.35}. s(P0, s(V, NP, PP)) --> v(P1, V),

    1熱度

    1回答

    :-dynamic listofQuestions/2. myrule:- write('P = '), write(Percent), write('-'),write(X), (listofQuestions(Percent,X) -> true ; assert(listofQuestions(Percent,X))), 代碼片段可能不需要回答我的問題。 我想斷言一

    0熱度

    1回答

    我有一個問題,需要我將元素添加到遍佈各種謂詞的列表中。我選擇使用動態列表謂詞,而不是通過基於參數的列表來做。我簡單的例子可以看到下面。當我最初使用它時,它工作正常,但現在如果我使用任何參數作爲X,即使在關閉程序並重新編譯之後,它仍會從列表中檢索先前的參數數據。有人知道它有什麼問題嗎? //list declarations :- dynamic listD/1. listD([]). //

    7熱度

    1回答

    我現在檢查X(Y)在我的小型數據庫中不是一個可接受的事實。由於X(Y)返回false,它將試圖斷言它。 (我知道這提出了問題,當X是規則而不是事實) ifNotAdd(X,Y):- not(call(X,Y)), !, assert(X(Y)). 例如,讓我們說,這實際上是在DB mammal(dolphin). 我問 ifNotAdd(哺乳動物,大象)。 我

    6熱度

    1回答

    我寫了下面的簡單代碼,我期待當我寫'男性'時,這段代碼問我一次「是男性嗎?」如果我輸入'不',它會在屏幕上寫上「她是女性」。 male :- (print('is it male ? '),read(yes)) -> true; asserta(not(male)),female. female:- not(male),print('she is female'). not(P) :- (ca