Re: The editor does not always offer other solutions.

Daniel Diaz <[email protected]> Mon, 9 Jan 2023 09:33:03 +0100
Newsgroups gmane.comp.gnu.prolog.bugs
Message-ID <[email protected]>
This is a multi-part message in MIME format.
--------------Uv0fw2gxvETg6WaeMNbh60lS
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit

Hi,

this is due to 'return' (\n) which ends the read(X) and remains in the 
keyboard buffer - when the first solution of name (bob) is displayed, 
the return is send to the top-level which ends the alternatives.

To consume the return, you can use:

| ?- read(Y), get_char(_), name(X).

Daniel


Le 08/01/2023 à 16:46, one_of_us a écrit :
>
> o@Kiki:~/prolog/gen_rythm$ uname -a
> Linux Kiki 5.10.0-19-amd64 #1 SMP Debian 5.10.149-2 (2022-10-21) 
> x86_64 GNU/Linux
>
> o@Kiki:~/prolog/gen_rythm$ gprolog
> GNU Prolog 1.4.5 (64 bits)
> Compiled Feb 23 2020, 20:14:50 with gcc
> By Daniel Diaz
> Copyright (C) 1999-2020 Daniel Diaz
> | ?- [user].
> compiling user for byte code...
> name(bob).
> name(ann).
> name(joe).
> end_of_file.
> user compiled, 3 lines read - 292 bytes written, 45418 ms
>
> yes
> | ?- name(X). %
>               %
> X = bob ? ;   % Here is possibility
>               % to request another
> X = ann ? ;   % solutions.
>               % It is good.
> X = joe       %
>
> yes
> | ?- read(Y), name(X). %
> tratata.               % Here is not such possibility.
>                        % Why?
> X = bob                % Is it a bug?
> Y = tratata ?          %
>
> yes
> | ?-
>
>
--------------Uv0fw2gxvETg6WaeMNbh60lS
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 8bit

<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <p>Hi,</p>
    <p>this is due to 'return' (\n) which ends the read(X) and remains
      in the keyboard buffer - when the first solution of name (bob) is
      displayed, the return is send to the top-level which ends the
      alternatives.</p>
    <p>To consume the return, you can use:</p>
    <p><font face="Free Courier">| ?- read(Y), get_char(_), name(X).</font></p>
    <p><font face="Free Courier">Daniel</font></p>
    <p><font face="Free Courier"><br>
      </font></p>
    <div class="moz-cite-prefix">Le 08/01/2023 à 16:46, one_of_us a
      écrit :<br>
    </div>
    <blockquote type="cite"
      cite="mid:[email protected]">
      <meta http-equiv="content-type" content="text/html; charset=UTF-8">
      <p><font face="Free Courier">o@Kiki:~/prolog/gen_rythm$ uname -a<br>
          Linux Kiki 5.10.0-19-amd64 #1 SMP Debian 5.10.149-2
          (2022-10-21) x86_64 GNU/Linux<br>
          <br>
          o@Kiki:~/prolog/gen_rythm$ gprolog<br>
          GNU Prolog 1.4.5 (64 bits)<br>
          Compiled Feb 23 2020, 20:14:50 with gcc<br>
          By Daniel Diaz<br>
          Copyright (C) 1999-2020 Daniel Diaz<br>
          | ?- [user].<br>
          compiling user for byte code...<br>
          name(bob).<br>
          name(ann).<br>
          name(joe).<br>
          end_of_file.<br>
          user compiled, 3 lines read - 292 bytes written, 45418 ms<br>
          <br>
          yes<br>
          | ?- name(X). %<br>
                        %<br>
          X = bob ? ;   % Here is possibility<br>
                        % to request another<br>
          X = ann ? ;   % solutions.<br>
                        % It is good.<br>
          X = joe       %<br>
          <br>
          yes<br>
          | ?- read(Y), name(X). %<br>
          tratata.               % Here is not such possibility.<br>
                                 % Why?<br>
          X = bob                % Is it a bug?<br>
          Y = tratata ?          %<br>
          <br>
          yes<br>
          | ?- <br>
          <br>
          <br>
        </font></p>
    </blockquote>
  </body>
</html>

--------------Uv0fw2gxvETg6WaeMNbh60lS--