first two easy exercises

This commit is contained in:
Vladan Popovic 2024-01-13 12:19:21 +01:00
commit 8c221fed78
20 changed files with 562 additions and 0 deletions

36
hello-world/HELP.md Normal file
View file

@ -0,0 +1,36 @@
# Help
## Running the tests
A `Makefile` is provided with a default target to compile your solution and run the tests. At the command line in your exercise's directory, type:
```bash
make
```
## Submitting your solution
You can submit your solution using the `exercism submit hello_world.ml` 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 [OCaml track's documentation](https://exercism.org/docs/tracks/ocaml)
- The [OCaml track's programming category on the forum](https://forum.exercism.org/c/programming/ocaml)
- [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:
- [Documentation for the Standard Library](http://caml.inria.fr/pub/docs/manual-ocaml/libref/index.html)
- [/r/ocaml](https://www.reddit.com/r/ocaml) is the OCaml subreddit.
- [StackOverflow](http://stackoverflow.com/questions/tagged/ocaml) can be used to search for your problem and see if it has been answered already. You can also ask and answer questions.

9
hello-world/Makefile Normal file
View file

@ -0,0 +1,9 @@
default: clean test
test:
dune runtest
clean:
dune clean
.PHONY: clean

42
hello-world/README.md Normal file
View file

@ -0,0 +1,42 @@
# Hello World
Welcome to Hello World on Exercism's OCaml 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
- @dvberkel
### Contributed to by
- @daveyarwood
- @iHiD
- @kytrinyx
- @marionebl
- @Peaupote
- @sbl
- @sshine
- @stevejb71
### Based on
This is an exercise to introduce users to using Exercism - https://en.wikipedia.org/wiki/%22Hello,_world!%22_program

16
hello-world/dune Normal file
View file

@ -0,0 +1,16 @@
(executable
(name test)
(libraries base ounit2))
(alias
(name runtest)
(deps (:x test.exe))
(action (run %{x})))
(alias
(name buildtest)
(deps (:x test.exe)))
(env
(dev
(flags (:standard -warn-error -A))))

1
hello-world/dune-project Normal file
View file

@ -0,0 +1 @@
(lang dune 1.1)

View file

@ -0,0 +1 @@
let hello = "Hello, World!"

View file

@ -0,0 +1,4 @@
(*
Returns "Hello, World!"
*)
val hello: string

11
hello-world/test.ml Normal file
View file

@ -0,0 +1,11 @@
open OUnit2
open Hello_world
let ae exp got _test_ctxt = assert_equal ~printer:(fun x -> x) exp got
let tests = [
"Say Hi!" >:: ae "Hello, World!" hello;
]
let () =
run_test_tt_main ("Hello World tests" >::: tests)