如何在序言中使用用户输入进行搜索 [英] How to use user input in prolog to search

查看:67
本文介绍了如何在序言中使用用户输入进行搜索的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我希望能够获得用户输入,然后将其存储并在我的代码中使用.

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.

推荐答案

我首先改用了GNU prolog,这很有帮助.

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.

这篇关于如何在序言中使用用户输入进行搜索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆