Syntax 如何编写if(KSO<;20)然后在prolog中执行过程?
我想写:Syntax 如何编写if(KSO<;20)然后在prolog中执行过程?,syntax,prolog,Syntax,Prolog,我想写: if (KSO<20) then { printf( "Is there NO3 in the water (yes/no)"); scanf("%s",NUMKSOVALUE_value); } if(KSO开始学习序言的好地方是: 对于您的问题,以下代码将帮助您开始: no3_present_in_water :- write('Enter KSO v
if (KSO<20) then {
printf( "Is there NO3 in the water (yes/no)");
scanf("%s",NUMKSOVALUE_value);
}
if(KSO开始学习序言的好地方是:
对于您的问题,以下代码将帮助您开始:
no3_present_in_water :-
write('Enter KSO value:'), nl,
read(V),
process_response(V,Outcome),
write('NO3 present: '), write(Outcome), nl.
process_response(A,B) :-
A =< 20,
B = 'no'.
process_response(A,B) :-
A > 20,
B = 'yes'.
:-
用于定义谓词子句。它将谓词的头和体分开。您以某种不寻常的方式使用过它。您是否阅读过任何Prolog教程或有一本Prolog书来学习一些基本的Prolog?
no3_present_in_water :-
write('Enter KSO value:'), nl,
read(V),
process_response(V,Outcome),
write('NO3 present: '), write(Outcome), nl.
process_response(A,B) :-
A =< 20,
B = 'no'.
process_response(A,B) :-
A > 20,
B = 'yes'.
?- no3_present_in_water.
Enter KSO value:
|: 10.
NO3 present: no
yes
?- no3_present_in_water.
Enter KSO value:
|: 30.
NO3 present: yes
yes