|
| 1 | +# Instructions append |
| 2 | + |
| 3 | +## Defining syntax |
| 4 | + |
| 5 | +~~~~exercism/caution |
| 6 | +This exercise is intended as a continuation of [`Resistor Color`][resistor-color] and builds upon it. |
| 7 | +Although you may solve practice exercises in any order, we encourage you to follow the suggested sequence. |
| 8 | +
|
| 9 | +[resistor-color]: https://exercism.org/tracks/lean/exercises/resistor-color |
| 10 | +~~~~ |
| 11 | + |
| 12 | +In this exercise, you are given syntax for colors already predefined using the `c*` prefix, e.g., `c*black`. |
| 13 | +You must then define syntax that associates a sequence of colors to a number, according to the instructions. |
| 14 | +The colors are within `*[[` and `]]` and separated by `, `, e.g., `*[[c*black, c*yellow, c*violet]]`. |
| 15 | + |
| 16 | +This task will likely require you to use either notations or macros. |
| 17 | +You might want to check a [reference][macro-reference]. |
| 18 | + |
| 19 | +Because new syntax is expanded at compile time, any test would fail to compile unless all the required syntax is defined. |
| 20 | +For this reason, instead of relying on traditional runtime tests, we use [`#guard_msgs`][guard-msgs]. |
| 21 | +This command compares a given docstring with a message generated by another command, in this case [`#eval`][eval], and reports an error if they are different. |
| 22 | +You may consider the absence of an error as a passing test. |
| 23 | + |
| 24 | +If you work locally or in Lean's [online playground][playground], you will get instant feedback on any error reported by `#guard_msgs` through Lean InfoView. |
| 25 | + |
| 26 | +~~~~exercism/caution |
| 27 | +For practical reasons, the online test runner does not currently have support to the built-in `Lean` library. |
| 28 | +This means that, although you are free to import this library, or any module within it, when working locally or in Lean's online playground, this will cause a solution to fail when submitted to exercism. |
| 29 | +
|
| 30 | +Note that this library is not necessary to solve the exercise. |
| 31 | +~~~~ |
| 32 | + |
| 33 | +[macro-reference]: https://lean-lang.org/doc/reference/latest/Notations-and-Macros/#language-extension |
| 34 | +[guard-msgs]: https://lean-lang.org/doc/reference/latest/Interacting-with-Lean/#hash-guard_msgs |
| 35 | +[eval]: https://lean-lang.org/doc/reference/latest/Interacting-with-Lean/#hash-eval |
| 36 | +[playground]: https://live.lean-lang.org/ |
0 commit comments