How to use user input in prolog to search

2019-08-24 05:53发布

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条回答
相关推荐>>
2楼-- · 2019-08-24 06:34

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.
查看更多
登录 后发表回答