feat: prolog hello world
Signed-off-by: Christina Sørensen <christina@cafkafk.com>
This commit is contained in:
parent
0cf380b65c
commit
2b2c2ba396
6 changed files with 168 additions and 0 deletions
26
prolog/hello-world/.exercism/config.json
Normal file
26
prolog/hello-world/.exercism/config.json
Normal file
|
@ -0,0 +1,26 @@
|
|||
{
|
||||
"authors": [
|
||||
"parkerl"
|
||||
],
|
||||
"contributors": [
|
||||
"Average-user",
|
||||
"heneryville",
|
||||
"jackhughesweb",
|
||||
"jesperp",
|
||||
"kytrinyx"
|
||||
],
|
||||
"files": {
|
||||
"solution": [
|
||||
"hello_world.pl"
|
||||
],
|
||||
"test": [
|
||||
"hello_world_tests.plt"
|
||||
],
|
||||
"example": [
|
||||
".meta/hello_world.example.pl"
|
||||
]
|
||||
},
|
||||
"blurb": "Exercism's classic introductory exercise. Just say \"Hello, World!\".",
|
||||
"source": "This is an exercise to introduce users to using Exercism",
|
||||
"source_url": "https://en.wikipedia.org/wiki/%22Hello,_world!%22_program"
|
||||
}
|
1
prolog/hello-world/.exercism/metadata.json
Normal file
1
prolog/hello-world/.exercism/metadata.json
Normal file
|
@ -0,0 +1 @@
|
|||
{"track":"prolog","exercise":"hello-world","id":"058eb3a37659491d8c9d4ff6a351d8b2","url":"https://exercism.org/tracks/prolog/exercises/hello-world","handle":"cafkafk","is_requester":true,"auto_approve":false}
|
84
prolog/hello-world/HELP.md
Normal file
84
prolog/hello-world/HELP.md
Normal file
|
@ -0,0 +1,84 @@
|
|||
# Help
|
||||
|
||||
## Running the tests
|
||||
|
||||
## Command line
|
||||
|
||||
The following command can be used to run the tests from the command line:
|
||||
|
||||
```bash
|
||||
swipl -f <exercise>.pl -s <exercise>_tests.plt -g run_tests,halt -t 'halt(1)'
|
||||
```
|
||||
|
||||
Replace `<exercise>` with the name of the exercise you are implementing.
|
||||
|
||||
## Interactive
|
||||
|
||||
To run prolog interactively first run:
|
||||
|
||||
```bash
|
||||
swipl
|
||||
```
|
||||
|
||||
After the prolog console starts, load your implementation and run the tests
|
||||
with:
|
||||
|
||||
```
|
||||
?- ["<exercise>.pl"].
|
||||
?- ["<exercise>_tests.plt"].
|
||||
?- run_tests.
|
||||
```
|
||||
|
||||
Replace `<exercise>` with the name of the exercise you are implementing.
|
||||
|
||||
### Reloading changes
|
||||
|
||||
Once the above files are loaded, you can apply any changes you've made
|
||||
by running:
|
||||
|
||||
```
|
||||
?- make.
|
||||
```
|
||||
|
||||
## Skipped tests
|
||||
|
||||
When you first begin an exercise, only the first test will run. The rest have
|
||||
been skipped by adding `condition(pending)` to the `test` goal. Once the first
|
||||
test passes, un-skip the next test by changing `pending` in `condition(pending)`
|
||||
to `true`. Repeat for each test until they are all running and passing.
|
||||
|
||||
### Command line
|
||||
|
||||
Add the `-- --all` argument to the end of the command to also run any pending tests:
|
||||
|
||||
```bash
|
||||
swipl -f <exercise>.pl -s <exercise>_tests.plt -g run_tests,halt -t 'halt(1)' -- --all
|
||||
```
|
||||
|
||||
## Submitting your solution
|
||||
|
||||
You can submit your solution using the `exercism submit hello_world.pl` command.
|
||||
This command will upload your solution to the Exercism website and print the solution page's URL.
|
||||
|
||||
It's possible to submit an incomplete solution which allows you to:
|
||||
|
||||
- See how others have completed the exercise
|
||||
- Request help from a mentor
|
||||
|
||||
## Need to get help?
|
||||
|
||||
If you'd like help solving the exercise, check the following pages:
|
||||
|
||||
- The [Prolog track's documentation](https://exercism.org/docs/tracks/prolog)
|
||||
- The [Prolog track's programming category on the forum](https://forum.exercism.org/c/programming/prolog)
|
||||
- [Exercism's programming category on the forum](https://forum.exercism.org/c/programming/5)
|
||||
- The [Frequently Asked Questions](https://exercism.org/docs/using/faqs)
|
||||
|
||||
Should those resources not suffice, you could submit your (incomplete) solution to request mentoring.
|
||||
|
||||
To get help if you're having trouble, you can use one of the following resources:
|
||||
|
||||
- [SWI Prolog Documentation](http://www.swi-prolog.org)
|
||||
- [Tutorials and Resources](http://www.swi-prolog.org/Links.html)
|
||||
- [/r/prolog](https://www.reddit.com/r/prolog) is the Prolog subreddit.
|
||||
- [StackOverflow](http://stackoverflow.com/questions/tagged/prolog) can be used to search for your problem and see if it has been answered already. You can also ask and answer questions.
|
39
prolog/hello-world/README.md
Normal file
39
prolog/hello-world/README.md
Normal file
|
@ -0,0 +1,39 @@
|
|||
# Hello World
|
||||
|
||||
Welcome to Hello World on Exercism's Prolog Track.
|
||||
If you need help running the tests or submitting your code, check out `HELP.md`.
|
||||
|
||||
## Instructions
|
||||
|
||||
The classical introductory exercise.
|
||||
Just say "Hello, World!".
|
||||
|
||||
["Hello, World!"][hello-world] is the traditional first program for beginning programming in a new language or environment.
|
||||
|
||||
The objectives are simple:
|
||||
|
||||
- Modify the provided code so that it produces the string "Hello, World!".
|
||||
- Run the test suite and make sure that it succeeds.
|
||||
- Submit your solution and check it at the website.
|
||||
|
||||
If everything goes well, you will be ready to fetch your first real exercise.
|
||||
|
||||
[hello-world]: https://en.wikipedia.org/wiki/%22Hello,_world!%22_program
|
||||
|
||||
## Source
|
||||
|
||||
### Created by
|
||||
|
||||
- @parkerl
|
||||
|
||||
### Contributed to by
|
||||
|
||||
- @Average-user
|
||||
- @heneryville
|
||||
- @jackhughesweb
|
||||
- @jesperp
|
||||
- @kytrinyx
|
||||
|
||||
### Based on
|
||||
|
||||
This is an exercise to introduce users to using Exercism - https://en.wikipedia.org/wiki/%22Hello,_world!%22_program
|
1
prolog/hello-world/hello_world.pl
Normal file
1
prolog/hello-world/hello_world.pl
Normal file
|
@ -0,0 +1 @@
|
|||
hello_world('Hello, World!').
|
17
prolog/hello-world/hello_world_tests.plt
Normal file
17
prolog/hello-world/hello_world_tests.plt
Normal file
|
@ -0,0 +1,17 @@
|
|||
% Please visit https://exercism.org/docs/tracks/prolog/installation
|
||||
% for instructions on setting up prolog.
|
||||
% Visit https://exercism.org/docs/tracks/prolog/tests
|
||||
% for help running the tests for prolog exercises.
|
||||
|
||||
pending :-
|
||||
current_prolog_flag(argv, ['--all'|_]).
|
||||
pending :-
|
||||
write('\nA TEST IS PENDING!\n'),
|
||||
fail.
|
||||
|
||||
:- begin_tests(hello_world).
|
||||
|
||||
test(hello_world, condition(true)) :-
|
||||
hello_world('Hello, World!').
|
||||
|
||||
:- end_tests(hello_world).
|
Loading…
Add table
Reference in a new issue