exercism / prolog

Exercism exercises in Prolog.
https://exercism.org/tracks/prolog
MIT License
29 stars 39 forks source link

Hello World Difficulty #57

Closed deckar01 closed 6 years ago

deckar01 commented 6 years ago

It was not clear to me that the last argument in the hello_world fact was effectively used as output. My initial guess was to use write/1 and echo the first argument, and it actually caused the first test to pass, which was confusing.

After looking at the tests for the second lesson, I think it uses a style that makes the objective a little clearer.

test(hello_world, condition(true)) :-
    hello_world('Hello World!').

test(hello_world_with_a_name, condition(true)) :-
    hello_world('Alice', 'Hello Alice!').

...

might be clearer as:

test(hello_world, condition(true)) :-
    hello_world(Message),
    Message == 'Hello World!'.

test(hello_world_with_a_name, condition(pending)) :-
    hello_world('Alice', Message),
    Message == 'Hello Alice!'.

...
parkerl commented 6 years ago

This sounds like a good change to me. Care to open a PR?

qjd2413 commented 6 years ago

I'm not sure about your solution. While I think it's a fine idea, it doesn't seem like quite enough, since the test would still pass regardless. Perhaps in the language documentation one could write about how prolog differs from the typical PL? It may also be beneficial to change the first test to be something like

test(hello_world, condition(true)) :- 
    hello_world(null, Message),
    Message == "Hello World".

(assuming null exists in prolog, it's been too long since I've used it)

stale[bot] commented 6 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.