You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CONTRIBUTING.md
+14-14Lines changed: 14 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
3
3
Welcome to [TheAlgorithms/Nim](https://github.com/TheAlgorithms/Nim)!
4
4
5
-
We are very happy that you are considering working on algorithm and data structure implementations in Nim! This repository is meant to be referenced and used by learners from all over the globe, and we aspire to maintain the highest possible quality of the code presented here. This is why we ask you to **read all of the following guidelines beforehand** to know what we expect of your contributions. If you have any doubts about this guide, please feel free to [state them clearly in an issue](https://github.com/TheAlgorithms/Nim/issues/new) or ask the community in [Discord](https://the-algorithms.com/discord).
5
+
We are very happy that you are considering working on the algorithm and data structure implementations in Nim! This repository is meant to be referenced and used by learners from all over the globe, and we aspire to maintain the highest possible quality of the code presented here. This is why we ask you to **read all of the following guidelines beforehand** to know what we expect of your contributions. If you have any doubts about this guide, please feel free to [state them clearly in an issue](https://github.com/TheAlgorithms/Nim/issues/new) or ask the community in [Discord](https://the-algorithms.com/discord).
6
6
7
7
## Table Of Contents
8
8
@@ -29,7 +29,7 @@ An Algorithm is one or more functions that:
29
29
- return one or more outputs,
30
30
- have minimal side effects (Examples of side effects: `echo()`, `rand()`, `read()`, `write()`).
31
31
32
-
## Contributor agreement
32
+
## Contributor Agreement
33
33
34
34
Being one of our contributors, you agree and confirm that:
35
35
@@ -40,28 +40,28 @@ Being one of our contributors, you agree and confirm that:
40
40
41
41
We appreciate any contribution, from fixing a grammar mistake in a comment to implementing complex algorithms. Please check the [directory](directory.md) and [issues](https://github.com/TheAlgorithms/Nim/issues/) for an existing (or declined) implementation of your algorithm and relevant discussions.
42
42
43
-
**New implementations** are welcome! This includes: new solutions for a problem, different representations for a data structure, algorithm design with a different complexity or features.
43
+
**New implementations** are welcome! This includes: new solutions for a problem, different representations for a data structure, and algorithm design with different complexity or features.
44
44
45
45
**Improving documentation and comments** and **adding tests** is also highly welcome.
46
46
47
47
**Identical implementations** are not allowed.
48
48
49
49
### Implementation requirements
50
50
51
-
- The unit of an implementation we expect is a [**Nim module**](https://nim-lang.org/docs/manual.html#modules). Although the main goals of this repository are educational, the module form mirrors a realworld scenario and makes it easy to use the code from this repository in other projects.
52
-
-First line must contain the canonical title of the module prefixed by double hashes (`## Title Of The Module`). This title is used in this repository's automation for populating the [Directory](directory.md).
51
+
- The unit of implementation we expect is a [**Nim module**](https://nim-lang.org/docs/manual.html#modules). Although the main goals of this repository are educational, the module form mirrors a real-world scenario and makes it easy to use the code from this repository in other projects.
52
+
-The first line must contain the canonical title of the module prefixed by double hashes (`## Title Of The Module`). This title is used in this repository's automation for populating the [Directory](directory.md).
53
53
- The module should be thoroughly documented with doc comments. Follow the [Nim documentation style](https://nim-lang.org/docs/docstyle.html).
54
54
- The file begins with the module-level documentation with the general description and explanation of the algorithm/data-structure. If possible, please include:
55
55
* Any restrictions of the implementation and any constraints for the input data.
56
-
* An overview of the use-cases.
56
+
* An overview of the usecases.
57
57
* Recommendations for when to use or avoid using it.
58
58
* Comparison with the alternatives.
59
59
* Links to source materials and further reading.
60
60
- Use intuitive and descriptive names for objects, functions, and variables.
61
61
- Return all calculation results instead of printing or plotting them.
62
-
- This repository is not simply a compilation of *how-to* examples for existing Nim packages and routines. Each algorithm implementation should add unique value. It is fine to leverage the standard library or third-party packages as long as it doesn't substitute writing the algorithm itself. In other words, you don't need to reimplement a basic hash table ([`std/tables`](https://nim-lang.org/docs/tables.html)) each time you need to use it, unless it is the goal of the module.
62
+
- This repository is not simply a compilation of *how-to* examples for existing Nim packages and routines. Each algorithm implementation should add unique value. It is fine to leverage the standard library or third-party packages as long as it doesn't substitute writing the algorithm itself. In other words, you don't need to reimplement a basic hash table ([`std/tables`](https://nim-lang.org/docs/tables.html)) each time you need to use it unless it is the goal of the module.
63
63
- Avoid importing third-party libraries. Only use those for complicated algorithms and only if the alternatives of relying on the standard library or including a short amount of the appropriately-licensed external code are not feasible.
64
-
- The module has to include tests that check valid and erroneous input values and the appropriate edge-cases. See [Documentation, examples and tests](#documentation-examples-and-tests) below.
64
+
- The module has to include tests that check valid and erroneous input values and the appropriate edgecases. See [Documentation, examples and tests](#documentation-examples-and-tests) below.
65
65
66
66
### Nim Coding Style
67
67
@@ -71,7 +71,7 @@ We want your work to be readable by others; therefore, we encourage you to follo
71
71
72
72
- Help your readers by using **descriptive names** that eliminate the need for redundant comments.
73
73
- Follow Nim conventions for naming: camelCase for variables and functions, PascalCase for types and objects, PascalCase or UPPERCASE for constants.
74
-
- Avoid single-letter variable names, unless it has a minimal lifespan. If your variable comes from a mathematical context or no confusion is possible with another variable, you may use single-letter variables. Generally, single-letter variables stop being OK if there's more than just a couple of them in a scope. Some examples:
74
+
- Avoid single-letter variable names, unless it has a minimal lifespan. If your variable comes from a mathematical context or no confusion is possible with another variable, you may use single-letter variables. Generally, single-letter variables stop being OK if there are more than just a couple of them in scope. Some examples:
75
75
* Prefer `index` or `idx` to `i` for loops.
76
76
* Prefer `src` and `dst` to `a` and `b`.
77
77
* Prefer `remainder` to `r` and `prefix` to `p`.
@@ -83,17 +83,17 @@ We want your work to be readable by others; therefore, we encourage you to follo
83
83
84
84
#### Types
85
85
86
-
- Use the strictest types possible for the input, output and object fields. Prefer `Natural`, `Positive` or custom [subrange types](https://nim-lang.org/docs/manual.html#types-subrange-types) to unconstrained `int` where applicable, use `Natural` for indexing.
86
+
- Use the strictest types possible for the input, output, and object fields. Prefer `Natural`, `Positive` or custom [subrange types](https://nim-lang.org/docs/manual.html#types-subrange-types) to unconstrained `int` where applicable, use `Natural` for indexing.
87
87
- On the other hand, write generic code where appropriate. Do not impose arbitrary limitations if the code can work on a wider range of data types.
88
-
- Don't use unsigned numerical types (`uint` and its sized variants), unless wrapping behaviour or binary manipulation is required for the algorithm.
88
+
- Don't use unsigned numerical types (`uint` and its sized variants), unless wrapping behavior or binary manipulation is required for the algorithm.
89
89
- Prefer the [`Option[T]`](https://nim-lang.org/docs/options.html) to encode an [optional value](https://en.wikipedia.org/wiki/Option_type) instead of using an invalid value (like the `-1` or an empty string `""`), unless it is critical for the algorithm. It may be also fitting if you are looking for the equivalent of "NULL" (default value for pointers)[^null].
90
90
91
91
#### Exceptions and side-effects
92
92
93
93
- Raise Nim exceptions (`ValueError`, etc.) on erroneous input values.
94
94
- Use [exception tracking](https://nim-lang.org/docs/manual.html#effect-system-exception-tracking). Right after the module-level documentation, add a `{.push raises: [].}` module pragma. This enforces that all `func`s don't raise any exceptions. If they do raise at least one, list them all with the `raises` pragma after the return type and before the `=` sign like this: `func foo(bar: int) {.raises: [IOError].} =`.
95
95
96
-
#### Documentation, examples and tests
96
+
#### Documentation, examples, and tests
97
97
98
98
- It is incited to give a usage example after the module documentation and the `push raises` pragma in the top-level `runnableExamples` block.
99
99
- Use the [`std/unittest` module](https://nim-lang.org/docs/unittest.html) to test your program.
@@ -135,11 +135,11 @@ when isMainModule:
135
135
### Submissions Requirements
136
136
137
137
- Make sure the code compiles before submitting.
138
-
- Look up the name of your algorithm in other active repositories of [TheAlgorithms](https://github.com/TheAlgorithms/), like [TheAlgorithms/Python](https://github.com/TheAlgorithms/Python). By reusing the same name, your implementation will be appropriately grouped alongside other implementations on the [project's web site](https://the-algorithms.com/).
138
+
- Look up the name of your algorithm in other active repositories of [TheAlgorithms](https://github.com/TheAlgorithms/), like [TheAlgorithms/Python](https://github.com/TheAlgorithms/Python). By reusing the same name, your implementation will be appropriately grouped alongside other implementations on the [project's website](https://the-algorithms.com/).
139
139
- Please help us keep our issue list small by adding fixes: Add the number of the issue you solved — even if only partially — to the commit message of your pull request.
140
140
- Use *snake_case* (words separated with an underscore `_`) for the filename.
141
141
- Try to fit your work into the existing directory structure as much as possible. Please open an issue first if you want to create a new subdirectory.
142
-
- Writing documentation, be concise and check your spelling and grammar.
142
+
- Writing documentation, be concise, and check your spelling and grammar.
143
143
- Add a corresponding explanation to [Algorithms-Explanation](https://github.com/TheAlgorithms/Algorithms-Explanation) (optional but recommended).
144
144
- Most importantly, **be consistent in the use of these guidelines**.
0 commit comments