Skip to content

Commit 5cf20d1

Browse files
authored
Format all instructions.append.md to start with an H1 (required but ignored) and H2 (#196)
1 parent 1c54b30 commit 5cf20d1

6 files changed

Lines changed: 33 additions & 32 deletions

File tree

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
# Instructions Append
22

3+
## Implementation
4+
35
You must return the anagrams in the same order as they are listed in the candidate words.

exercises/practice/error-handling/.docs/instructions.append.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Instructions append
22

3+
## Implementation
4+
35
You are building a tiny web server that queries an even tinier user database. Sounds easy, but in the real world many things can (and often do) go wrong:
46

57
- the connection may be insecure: the URL must start with `"https://"`
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Instructions append
22

3+
## Implementation
4+
35
The file to edit is named `HelloWorld.roc`.
46

57
If you are using the command line, run the test suite using `roc test hello-world-test.roc`

exercises/practice/list-ops/.docs/instructions.append.md

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
1-
# Wait, It's Impossible!
1+
# Instructions append
22

3-
Implementing these list operations without using _any_ built-in function is
4-
virtually impossible in Roc, because you need a way to append or prepend
5-
elements to a list. In other languages you might use operators such as `:`
6-
in Haskell or `+=` in Python, but in Roc you have to use the
7-
[`List` functions](https://www.roc-lang.org/builtins/List).
3+
## Wait, It's Impossible!
84

9-
So for this exercise you're allowed to use `List.append` (but avoid using any
10-
other built-in function).
5+
Implementing these list operations without using _any_ built-in function is virtually impossible in Roc, because you need a way to append or prepend elements to a list.
6+
In other languages you might use operators such as `:` in Haskell or `+=` in Python, but in Roc you have to use the [`List` functions](https://www.roc-lang.org/builtins/List).
7+
8+
So for this exercise you're allowed to use `List.append` (but avoid using any other built-in function).
119

1210
Many functional programming languages use linked lists as the primary collection type.
13-
It is efficient to prepend an element or pop the first element from a linked list, so in those languages, you would implement list operations
14-
using `List.prepend`. In Roc however, a `List` is an array (a contiguous chunk of bytes). Arrays have different
15-
properties than linked lists like the ability to efficiently access elements by index and append new elements.
11+
It is efficient to prepend an element or pop the first element from a linked list, so in those languages, you would implement list operations using `List.prepend`.
12+
In Roc however, a `List` is an array (a contiguous chunk of bytes).
13+
Arrays have different properties than linked lists like the ability to efficiently access elements by index and append new elements.
1614
Because of this, in Roc we use `List.append` often and rarely use `List.prepend`.
1715

1816
Hint: try using:
Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,22 @@
11
# Instructions append
22

3-
In Chess, rows are called "ranks", and columns are called "files". Ranks range
4-
from 1 to 8, while files range from A to H.
3+
## Implementation
54

6-
In this exercise, `Square` is an opaque type which represents a square on a
7-
chessboard. It uses 0-indexed `row` & `column` fields internally, and it
8-
guarantees that they are always valid (i.e., from 0 to 7).
5+
In Chess, rows are called "ranks", and columns are called "files".
6+
Ranks range from 1 to 8, while files range from A to H.
97

10-
The `create` function takes a `Str` as input, representing a valid square on
11-
the chessboard using the official notation, such as `"C5"`. The `create`
12-
function must parse this `Str`, verify that it represents a valid square, and if
13-
so it must return a `Square` value containing the appropriate `row` and `column`
14-
fields. Rank 1 corresponds to row 0, and rank 8 corresponds to row 7. For
15-
example, `create "C5"` must return `@Square { row : 2, column : 3 }`.
8+
In this exercise, `Square` is an opaque type which represents a square on a chessboard.
9+
It uses 0-indexed `row` & `column` fields internally, and it guarantees that they are always valid (i.e., from 0 to 7).
1610

17-
The `QueenAttack` module also exposes handy `rank` & `file` functions. In the
18-
example above, `rank` must return the integer `5`, and `file` must return the
19-
character `'C'`.
11+
The `create` function takes a `Str` as input, representing a valid square on the chessboard using the official notation, such as `"C5"`.
12+
The `create` function must parse this `Str`, verify that it represents a valid square, and if so it must return a `Square` value containing the appropriate `row` and `column` fields.
13+
Rank 1 corresponds to row 0, and rank 8 corresponds to row 7.
14+
For example, `create "C5"` must return `@Square { row : 2, column : 3 }`.
2015

21-
Lastly, the `queen_can_attack` function takes two different `Square` values and
22-
checks whether or not queens placed on these squares can attack each other.
16+
The `QueenAttack` module also exposes handy `rank` & `file` functions.
17+
In the example above, `rank` must return the integer `5`, and `file` must return the character `'C'`.
2318

24-
Take-away: opaque types such as `Square` are great when you want to offer some
25-
guarantees, such as the fact that `row` and `column` are always between 0 and 7.
26-
Opaque types also hide implementation details from the users, which makes the
27-
API cleaner.
19+
Lastly, the `queen_can_attack` function takes two different `Square` values and checks whether or not queens placed on these squares can attack each other.
20+
21+
Take-away: opaque types such as `Square` are great when you want to offer some guarantees, such as the fact that `row` and `column` are always between 0 and 7.
22+
Opaque types also hide implementation details from the users, which makes the API cleaner.
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
# Instructions append
22

3+
## Implementation
4+
35
This problem can be solved easily using Roc's built-in `Num` module, including the [`Num.sqrt`][sqrt] function.
46

57
However, we'd like you to consider the challenge of solving this exercise without using built-ins or modules.
68

79
While there is a mathematical formula that will find the square root of _any_ number, we have gone the route of having only [natural numbers][natural-number] (positive integers) as solutions.
810

911
[sqrt]: https://www.roc-lang.org/builtins/Num#sqrt
10-
[natural-number]: https://en.wikipedia.org/wiki/Natural_number
12+
[natural-number]: https://en.wikipedia.org/wiki/Natural_number

0 commit comments

Comments
 (0)