0

If you query e.g.

?- X = 10, Y = 10, Z = 10.

The output is

X = Y, Y = Z, Z = 10.

But my X is totally different from Y, they just happen to accidentally both be 10, so it doesn't seem clear/logical to display it that way. Can i make it look like this instead?:

X = 10, Y = 10, Z = 10.
TessellatingHeckler
  • 27,511
  • 4
  • 48
  • 87
Frodo
  • 21
  • 2
  • 1
    It's completely logical. Far more often than not, it's worth noting that variables are equal. This is only the interactive environment (AFAIK it can't be customized as you wish). You can use e.g. https://www.swi-prolog.org/pldoc/man?predicate=writeln/1 in your program to output your own format. – brebs Nov 20 '22 at 13:41
  • Alright, thats what i guessed too, thanks for the confirmation – Frodo Nov 21 '22 at 12:21

2 Answers2

0

I share your preference. Note that different Prolog systems have different top levels...

SWI-Prolog gives me this:

$ swipl
?- X = 10, Y = 10, Z = 10.
X = Y, Y = Z, Z = 10.

Traella Prolog says something quite similar:

$ tpl 
?- X = 10, Y = 10, Z = 10.
   X = 10, Y = X, Z = X.

GNU-Prolog and Scryer Prolog, however, give me answers that I like better:

$ gprolog
| ?- X = 10, Y = 10, Z = 10.

X = 10
Y = 10
Z = 10

yes

$ scryer-prolog 
?- X = 10, Y = 10, Z = 10.
   X = 10, Y = 10, Z = 10.
repeat
  • 18,496
  • 4
  • 54
  • 166
  • 1
    Mnm. What about larger terms? Are you still happy if they are repeated over and over again? – false Nov 23 '22 at 10:46
  • @false. Yes, as long as the right abbreviation is used. Something like `?- blam(X). X = [] ; X = [[]] ; X = [[[]],[]] ; X = [[[[]],[]],[[]],[]] ; X = BIG(size=31,ground) ; X = BIG(size=63,ground) ; X = BIG(size=127,ground) ; ... .` – repeat Nov 23 '22 at 19:27
  • 1
    Your syntax is, lo and behold, **invalid**. Is this really an advantage? – false Nov 24 '22 at 09:11
  • @false. It all depends on how you see it:) Personally, I (as a Prolog user) prefer *knowing* something is missing over guessing there *might* be something missing. – repeat Nov 24 '22 at 18:13
  • @false. Also, screen estate is very precious to me. So I'd rather get *some* useful info like `functors=['.'/2,[]/0]` (not shown above) in invalid form than lines and lines of (actually valid, but fake) `[...,...|...]` terms. – repeat Nov 24 '22 at 18:31
  • 1
    These `...` in subterms but also within strings are certainly a pain. But there is no better consistent proposal. – false Nov 25 '22 at 07:52
  • @false. I share your `...` pain. Maybe I should not fiddle around too much with corner cases that make invalid syntax appear more appealing than actually is in general. – repeat Nov 27 '22 at 19:56
  • 1
    Considerations of corner cases are important. And in this specific case I prefer Trealla's answer over Scryer's and over SWI's. Ideally, we could find a good definition of this. – false Dec 06 '22 at 12:02
-2

change([H,Q,D,N,P]) :-member(H,[0,1,2]), /* Half-dollars /member(Q,[0,1,2,3,4]), / quarters /member(D,[0,1,2,3,4,5,6,7,8,9,10]) , / dimes /member(N,[0,1,2,3,4,5,6,7,8,9,10, / nickels /11,12,13,14,15,16,17,18,19,20]),S is 50H + 25Q +10D + 5*N,S =< 100,P is 100-S.

  • 1
    How does your contribution answer the question posed by the OP? – repeat Nov 22 '22 at 15:34
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Nov 27 '22 at 23:30