问题
hello i want to be able to get the user input then store it and use in in my code.
body(mercury, 36, small, none, none).
body(venus, 67, small, atmosphere, none).
body(earth, 93, small, atmosphere, none).
body(moon, 93, small, none, none).
body(mars, 141, small, atmosphere, none).
body(jupiter, 489, large, atmosphere, rings).
miles(Body,Miles):-write('Enter the Goal State:'),nl,
read(X),nl,
body(Body, Miles, _, _, _); Miles > X.
回答1:
i switched to GNU prolog firstly which helped.
miles(Body,Miles):-write('Enter the Goal State:'),nl,
read(X),nl,
body(Body, Miles, _, _, _), Miles > X.
来源:https://stackoverflow.com/questions/47317413/how-to-use-user-input-in-prolog-to-search