Prolog - 'unknown clause' error message when asking for user input when using PIE (Prolog Interface Engine)





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







1















I'm writing code for a simple program that outputs any phrase that the user inputs. Here's my code so far:



input():-
read(X),
nl,
write(X).


Here's the output:



input().
input().
Unknown clause found read(X$0)
Execution terminated
No solutions


Here's my desired output:



input().
input().
hello
hello









share|improve this question































    1















    I'm writing code for a simple program that outputs any phrase that the user inputs. Here's my code so far:



    input():-
    read(X),
    nl,
    write(X).


    Here's the output:



    input().
    input().
    Unknown clause found read(X$0)
    Execution terminated
    No solutions


    Here's my desired output:



    input().
    input().
    hello
    hello









    share|improve this question



























      1












      1








      1








      I'm writing code for a simple program that outputs any phrase that the user inputs. Here's my code so far:



      input():-
      read(X),
      nl,
      write(X).


      Here's the output:



      input().
      input().
      Unknown clause found read(X$0)
      Execution terminated
      No solutions


      Here's my desired output:



      input().
      input().
      hello
      hello









      share|improve this question
















      I'm writing code for a simple program that outputs any phrase that the user inputs. Here's my code so far:



      input():-
      read(X),
      nl,
      write(X).


      Here's the output:



      input().
      input().
      Unknown clause found read(X$0)
      Execution terminated
      No solutions


      Here's my desired output:



      input().
      input().
      hello
      hello






      prolog






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 23 '18 at 13:59









      Guy Coder

      16.3k44287




      16.3k44287










      asked Nov 23 '18 at 12:49









      plants thoplants tho

      132




      132
























          1 Answer
          1






          active

          oldest

          votes


















          0














          Note: In a comment the OP noted this was originally done using PIE (Prolog Interface Engine)



          Your problem is that you are using read/1 which expects a Prolog term. Prolog terms are not strings that can be of any form, Prolog terms end with a period (.). So in your example input(). works because it ends with a period, hello does not work because it does not end with a period.



          Using your query



          ?- input().
          |: input().


          and entering input(). works



          input()
          true.





          ?- input().
          |: hello
          |: .


          entering hello does not work right away as indicated by the second prompt |: but then entering the . completes the Prolog term and works.



          hello
          true.


          --



          Here is demo of your code, slightly modified running on SWISH.



          enter image description here





          When I ran your code with SWI-Prolog installed on my laptop it worked with input() as the predicate. When I tried the same with SWISH it complained, but changing the predicate from input() to input solved that problem.





          Now knowing that you are not using a common Prolog such as SWI-Prolog and seeing the error message



          Unknown clause found read(X$0)


          tells me that PIE does not have read/1, I did a quick check of some tutorials for PIE and could not find any use of read/1. The obvious conclusion is that PIE does not support read/1 and if you want to use read/1 while learning Prolog you will have to use something that does, e.g. SWI-Prolog, SWISH, GNU Prolog






          share|improve this answer


























          • The thing is: it doesn't allow me to enter an input. When I call the input() method, it is supposed to allow me to enter something but when I type input(). and hit enter, it shows up the unknown clause error message above. I'm running this on PIE (Prolog Interface Engine) if that helps

            – plants tho
            Nov 23 '18 at 13:08











          • If you don't want to download and install Prolog then try SWISH - SWISH: SWI-Prolog for SHaring It runs in a browser.

            – Guy Coder
            Nov 23 '18 at 13:13











          • works like a charm on swish but gives me trouble on PIE. I guess the issue here is PIE not my code. Thank you so much!!!!

            – plants tho
            Nov 23 '18 at 13:29











          • won't let me upvote because I don't have enough reputation points :(

            – plants tho
            Nov 23 '18 at 13:39











          • @plantstho I lose more points because of that silly requirement. Thanks. I should send the bill to SO for those.

            – Guy Coder
            Nov 23 '18 at 13:41












          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53447044%2fprolog-unknown-clause-error-message-when-asking-for-user-input-when-using-pi%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          Note: In a comment the OP noted this was originally done using PIE (Prolog Interface Engine)



          Your problem is that you are using read/1 which expects a Prolog term. Prolog terms are not strings that can be of any form, Prolog terms end with a period (.). So in your example input(). works because it ends with a period, hello does not work because it does not end with a period.



          Using your query



          ?- input().
          |: input().


          and entering input(). works



          input()
          true.





          ?- input().
          |: hello
          |: .


          entering hello does not work right away as indicated by the second prompt |: but then entering the . completes the Prolog term and works.



          hello
          true.


          --



          Here is demo of your code, slightly modified running on SWISH.



          enter image description here





          When I ran your code with SWI-Prolog installed on my laptop it worked with input() as the predicate. When I tried the same with SWISH it complained, but changing the predicate from input() to input solved that problem.





          Now knowing that you are not using a common Prolog such as SWI-Prolog and seeing the error message



          Unknown clause found read(X$0)


          tells me that PIE does not have read/1, I did a quick check of some tutorials for PIE and could not find any use of read/1. The obvious conclusion is that PIE does not support read/1 and if you want to use read/1 while learning Prolog you will have to use something that does, e.g. SWI-Prolog, SWISH, GNU Prolog






          share|improve this answer


























          • The thing is: it doesn't allow me to enter an input. When I call the input() method, it is supposed to allow me to enter something but when I type input(). and hit enter, it shows up the unknown clause error message above. I'm running this on PIE (Prolog Interface Engine) if that helps

            – plants tho
            Nov 23 '18 at 13:08











          • If you don't want to download and install Prolog then try SWISH - SWISH: SWI-Prolog for SHaring It runs in a browser.

            – Guy Coder
            Nov 23 '18 at 13:13











          • works like a charm on swish but gives me trouble on PIE. I guess the issue here is PIE not my code. Thank you so much!!!!

            – plants tho
            Nov 23 '18 at 13:29











          • won't let me upvote because I don't have enough reputation points :(

            – plants tho
            Nov 23 '18 at 13:39











          • @plantstho I lose more points because of that silly requirement. Thanks. I should send the bill to SO for those.

            – Guy Coder
            Nov 23 '18 at 13:41
















          0














          Note: In a comment the OP noted this was originally done using PIE (Prolog Interface Engine)



          Your problem is that you are using read/1 which expects a Prolog term. Prolog terms are not strings that can be of any form, Prolog terms end with a period (.). So in your example input(). works because it ends with a period, hello does not work because it does not end with a period.



          Using your query



          ?- input().
          |: input().


          and entering input(). works



          input()
          true.





          ?- input().
          |: hello
          |: .


          entering hello does not work right away as indicated by the second prompt |: but then entering the . completes the Prolog term and works.



          hello
          true.


          --



          Here is demo of your code, slightly modified running on SWISH.



          enter image description here





          When I ran your code with SWI-Prolog installed on my laptop it worked with input() as the predicate. When I tried the same with SWISH it complained, but changing the predicate from input() to input solved that problem.





          Now knowing that you are not using a common Prolog such as SWI-Prolog and seeing the error message



          Unknown clause found read(X$0)


          tells me that PIE does not have read/1, I did a quick check of some tutorials for PIE and could not find any use of read/1. The obvious conclusion is that PIE does not support read/1 and if you want to use read/1 while learning Prolog you will have to use something that does, e.g. SWI-Prolog, SWISH, GNU Prolog






          share|improve this answer


























          • The thing is: it doesn't allow me to enter an input. When I call the input() method, it is supposed to allow me to enter something but when I type input(). and hit enter, it shows up the unknown clause error message above. I'm running this on PIE (Prolog Interface Engine) if that helps

            – plants tho
            Nov 23 '18 at 13:08











          • If you don't want to download and install Prolog then try SWISH - SWISH: SWI-Prolog for SHaring It runs in a browser.

            – Guy Coder
            Nov 23 '18 at 13:13











          • works like a charm on swish but gives me trouble on PIE. I guess the issue here is PIE not my code. Thank you so much!!!!

            – plants tho
            Nov 23 '18 at 13:29











          • won't let me upvote because I don't have enough reputation points :(

            – plants tho
            Nov 23 '18 at 13:39











          • @plantstho I lose more points because of that silly requirement. Thanks. I should send the bill to SO for those.

            – Guy Coder
            Nov 23 '18 at 13:41














          0












          0








          0







          Note: In a comment the OP noted this was originally done using PIE (Prolog Interface Engine)



          Your problem is that you are using read/1 which expects a Prolog term. Prolog terms are not strings that can be of any form, Prolog terms end with a period (.). So in your example input(). works because it ends with a period, hello does not work because it does not end with a period.



          Using your query



          ?- input().
          |: input().


          and entering input(). works



          input()
          true.





          ?- input().
          |: hello
          |: .


          entering hello does not work right away as indicated by the second prompt |: but then entering the . completes the Prolog term and works.



          hello
          true.


          --



          Here is demo of your code, slightly modified running on SWISH.



          enter image description here





          When I ran your code with SWI-Prolog installed on my laptop it worked with input() as the predicate. When I tried the same with SWISH it complained, but changing the predicate from input() to input solved that problem.





          Now knowing that you are not using a common Prolog such as SWI-Prolog and seeing the error message



          Unknown clause found read(X$0)


          tells me that PIE does not have read/1, I did a quick check of some tutorials for PIE and could not find any use of read/1. The obvious conclusion is that PIE does not support read/1 and if you want to use read/1 while learning Prolog you will have to use something that does, e.g. SWI-Prolog, SWISH, GNU Prolog






          share|improve this answer















          Note: In a comment the OP noted this was originally done using PIE (Prolog Interface Engine)



          Your problem is that you are using read/1 which expects a Prolog term. Prolog terms are not strings that can be of any form, Prolog terms end with a period (.). So in your example input(). works because it ends with a period, hello does not work because it does not end with a period.



          Using your query



          ?- input().
          |: input().


          and entering input(). works



          input()
          true.





          ?- input().
          |: hello
          |: .


          entering hello does not work right away as indicated by the second prompt |: but then entering the . completes the Prolog term and works.



          hello
          true.


          --



          Here is demo of your code, slightly modified running on SWISH.



          enter image description here





          When I ran your code with SWI-Prolog installed on my laptop it worked with input() as the predicate. When I tried the same with SWISH it complained, but changing the predicate from input() to input solved that problem.





          Now knowing that you are not using a common Prolog such as SWI-Prolog and seeing the error message



          Unknown clause found read(X$0)


          tells me that PIE does not have read/1, I did a quick check of some tutorials for PIE and could not find any use of read/1. The obvious conclusion is that PIE does not support read/1 and if you want to use read/1 while learning Prolog you will have to use something that does, e.g. SWI-Prolog, SWISH, GNU Prolog







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 23 '18 at 13:44

























          answered Nov 23 '18 at 13:04









          Guy CoderGuy Coder

          16.3k44287




          16.3k44287













          • The thing is: it doesn't allow me to enter an input. When I call the input() method, it is supposed to allow me to enter something but when I type input(). and hit enter, it shows up the unknown clause error message above. I'm running this on PIE (Prolog Interface Engine) if that helps

            – plants tho
            Nov 23 '18 at 13:08











          • If you don't want to download and install Prolog then try SWISH - SWISH: SWI-Prolog for SHaring It runs in a browser.

            – Guy Coder
            Nov 23 '18 at 13:13











          • works like a charm on swish but gives me trouble on PIE. I guess the issue here is PIE not my code. Thank you so much!!!!

            – plants tho
            Nov 23 '18 at 13:29











          • won't let me upvote because I don't have enough reputation points :(

            – plants tho
            Nov 23 '18 at 13:39











          • @plantstho I lose more points because of that silly requirement. Thanks. I should send the bill to SO for those.

            – Guy Coder
            Nov 23 '18 at 13:41



















          • The thing is: it doesn't allow me to enter an input. When I call the input() method, it is supposed to allow me to enter something but when I type input(). and hit enter, it shows up the unknown clause error message above. I'm running this on PIE (Prolog Interface Engine) if that helps

            – plants tho
            Nov 23 '18 at 13:08











          • If you don't want to download and install Prolog then try SWISH - SWISH: SWI-Prolog for SHaring It runs in a browser.

            – Guy Coder
            Nov 23 '18 at 13:13











          • works like a charm on swish but gives me trouble on PIE. I guess the issue here is PIE not my code. Thank you so much!!!!

            – plants tho
            Nov 23 '18 at 13:29











          • won't let me upvote because I don't have enough reputation points :(

            – plants tho
            Nov 23 '18 at 13:39











          • @plantstho I lose more points because of that silly requirement. Thanks. I should send the bill to SO for those.

            – Guy Coder
            Nov 23 '18 at 13:41

















          The thing is: it doesn't allow me to enter an input. When I call the input() method, it is supposed to allow me to enter something but when I type input(). and hit enter, it shows up the unknown clause error message above. I'm running this on PIE (Prolog Interface Engine) if that helps

          – plants tho
          Nov 23 '18 at 13:08





          The thing is: it doesn't allow me to enter an input. When I call the input() method, it is supposed to allow me to enter something but when I type input(). and hit enter, it shows up the unknown clause error message above. I'm running this on PIE (Prolog Interface Engine) if that helps

          – plants tho
          Nov 23 '18 at 13:08













          If you don't want to download and install Prolog then try SWISH - SWISH: SWI-Prolog for SHaring It runs in a browser.

          – Guy Coder
          Nov 23 '18 at 13:13





          If you don't want to download and install Prolog then try SWISH - SWISH: SWI-Prolog for SHaring It runs in a browser.

          – Guy Coder
          Nov 23 '18 at 13:13













          works like a charm on swish but gives me trouble on PIE. I guess the issue here is PIE not my code. Thank you so much!!!!

          – plants tho
          Nov 23 '18 at 13:29





          works like a charm on swish but gives me trouble on PIE. I guess the issue here is PIE not my code. Thank you so much!!!!

          – plants tho
          Nov 23 '18 at 13:29













          won't let me upvote because I don't have enough reputation points :(

          – plants tho
          Nov 23 '18 at 13:39





          won't let me upvote because I don't have enough reputation points :(

          – plants tho
          Nov 23 '18 at 13:39













          @plantstho I lose more points because of that silly requirement. Thanks. I should send the bill to SO for those.

          – Guy Coder
          Nov 23 '18 at 13:41





          @plantstho I lose more points because of that silly requirement. Thanks. I should send the bill to SO for those.

          – Guy Coder
          Nov 23 '18 at 13:41




















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53447044%2fprolog-unknown-clause-error-message-when-asking-for-user-input-when-using-pi%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          "Incorrect syntax near the keyword 'ON'. (on update cascade, on delete cascade,)

          Alcedinidae

          RAC Tourist Trophy