How to use user input in prolog to search

有些话、适合烂在心里 提交于 2020-01-06 05:50:29

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!