diff --git a/exercises/practice/anagram/.docs/instructions.append.md b/exercises/practice/anagram/.docs/instructions.append.md index 2b17bb7a..0f5c35b6 100644 --- a/exercises/practice/anagram/.docs/instructions.append.md +++ b/exercises/practice/anagram/.docs/instructions.append.md @@ -1,3 +1,5 @@ # Instructions Append +## Implementation + You must return the anagrams in the same order as they are listed in the candidate words. diff --git a/exercises/practice/error-handling/.docs/instructions.append.md b/exercises/practice/error-handling/.docs/instructions.append.md index bcd5f71f..b5625706 100644 --- a/exercises/practice/error-handling/.docs/instructions.append.md +++ b/exercises/practice/error-handling/.docs/instructions.append.md @@ -1,5 +1,7 @@ # Instructions append +## Implementation + 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: - the connection may be insecure: the URL must start with `"https://"` diff --git a/exercises/practice/hello-world/.docs/instructions.append.md b/exercises/practice/hello-world/.docs/instructions.append.md index 6c0d9182..2886ae84 100644 --- a/exercises/practice/hello-world/.docs/instructions.append.md +++ b/exercises/practice/hello-world/.docs/instructions.append.md @@ -1,5 +1,7 @@ # Instructions append +## Implementation + The file to edit is named `HelloWorld.roc`. If you are using the command line, run the test suite using `roc test hello-world-test.roc` diff --git a/exercises/practice/list-ops/.docs/instructions.append.md b/exercises/practice/list-ops/.docs/instructions.append.md index 1ef8e766..56d270a1 100644 --- a/exercises/practice/list-ops/.docs/instructions.append.md +++ b/exercises/practice/list-ops/.docs/instructions.append.md @@ -1,18 +1,16 @@ -# Wait, It's Impossible! +# Instructions append -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. 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). +## Wait, It's Impossible! -So for this exercise you're allowed to use `List.append` (but avoid using any -other built-in function). +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. +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). + +So for this exercise you're allowed to use `List.append` (but avoid using any other built-in function). Many functional programming languages use linked lists as the primary collection type. -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`. In Roc however, a `List` is an array (a contiguous chunk of bytes). Arrays have different -properties than linked lists like the ability to efficiently access elements by index and append new elements. +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`. +In Roc however, a `List` is an array (a contiguous chunk of bytes). +Arrays have different properties than linked lists like the ability to efficiently access elements by index and append new elements. Because of this, in Roc we use `List.append` often and rarely use `List.prepend`. Hint: try using: diff --git a/exercises/practice/queen-attack/.docs/instructions.append.md b/exercises/practice/queen-attack/.docs/instructions.append.md index 9f5f42ac..39447833 100644 --- a/exercises/practice/queen-attack/.docs/instructions.append.md +++ b/exercises/practice/queen-attack/.docs/instructions.append.md @@ -1,27 +1,22 @@ # Instructions append -In Chess, rows are called "ranks", and columns are called "files". Ranks range -from 1 to 8, while files range from A to H. +## Implementation -In this exercise, `Square` is an opaque type which represents a square on a -chessboard. It uses 0-indexed `row` & `column` fields internally, and it -guarantees that they are always valid (i.e., from 0 to 7). +In Chess, rows are called "ranks", and columns are called "files". +Ranks range from 1 to 8, while files range from A to H. -The `create` function takes a `Str` as input, representing a valid square on -the chessboard using the official notation, such as `"C5"`. 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. Rank 1 corresponds to row 0, and rank 8 corresponds to row 7. For -example, `create "C5"` must return `@Square { row : 2, column : 3 }`. +In this exercise, `Square` is an opaque type which represents a square on a chessboard. +It uses 0-indexed `row` & `column` fields internally, and it guarantees that they are always valid (i.e., from 0 to 7). -The `QueenAttack` module also exposes handy `rank` & `file` functions. In the -example above, `rank` must return the integer `5`, and `file` must return the -character `'C'`. +The `create` function takes a `Str` as input, representing a valid square on the chessboard using the official notation, such as `"C5"`. +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. +Rank 1 corresponds to row 0, and rank 8 corresponds to row 7. +For example, `create "C5"` must return `@Square { row : 2, column : 3 }`. -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. +The `QueenAttack` module also exposes handy `rank` & `file` functions. +In the example above, `rank` must return the integer `5`, and `file` must return the character `'C'`. -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. -Opaque types also hide implementation details from the users, which makes the -API cleaner. +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. + +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. +Opaque types also hide implementation details from the users, which makes the API cleaner. diff --git a/exercises/practice/square-root/.docs/instructions.append.md b/exercises/practice/square-root/.docs/instructions.append.md index 92f7c50e..b91263a2 100644 --- a/exercises/practice/square-root/.docs/instructions.append.md +++ b/exercises/practice/square-root/.docs/instructions.append.md @@ -1,5 +1,7 @@ # Instructions append +## Implementation + This problem can be solved easily using Roc's built-in `Num` module, including the [`Num.sqrt`][sqrt] function. However, we'd like you to consider the challenge of solving this exercise without using built-ins or modules. @@ -7,4 +9,4 @@ However, we'd like you to consider the challenge of solving this exercise withou 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. [sqrt]: https://www.roc-lang.org/builtins/Num#sqrt -[natural-number]: https://en.wikipedia.org/wiki/Natural_number \ No newline at end of file +[natural-number]: https://en.wikipedia.org/wiki/Natural_number