From 9774308bb6b898df6ecbde64c5c6e48c651870ae Mon Sep 17 00:00:00 2001 From: Erik Schierboom Date: Fri, 12 Feb 2021 17:42:15 +0100 Subject: [PATCH] [v3] Update Markdown files to latest spec (#599) --- concepts/access-behaviour/about.md | 2 ++ concepts/access-behaviour/introduction.md | 2 ++ concepts/agent/about.md | 2 ++ concepts/agent/introduction.md | 2 ++ concepts/anonymous-functions/about.md | 2 ++ concepts/anonymous-functions/introduction.md | 2 ++ concepts/atoms/about.md | 2 ++ concepts/atoms/introduction.md | 2 ++ concepts/basics/about.md | 2 ++ concepts/basics/introduction.md | 12 +++++++----- concepts/binaries/about.md | 2 ++ concepts/binaries/introduction.md | 4 +++- concepts/bit-manipulation/about.md | 2 ++ concepts/bit-manipulation/introduction.md | 2 ++ concepts/bitstrings/about.md | 2 ++ concepts/bitstrings/introduction.md | 6 ++++-- concepts/booleans/about.md | 2 ++ concepts/booleans/introduction.md | 2 ++ concepts/case/about.md | 2 ++ concepts/case/introduction.md | 2 ++ concepts/charlists/about.md | 2 ++ concepts/charlists/introduction.md | 2 ++ concepts/closures/about.md | 2 ++ concepts/closures/introduction.md | 2 ++ concepts/cond/about.md | 2 ++ concepts/cond/introduction.md | 2 ++ concepts/default-arguments/about.md | 2 ++ concepts/default-arguments/introduction.md | 2 ++ concepts/dynamic-dispatch/about.md | 2 ++ concepts/dynamic-dispatch/introduction.md | 2 ++ concepts/enum/about.md | 2 ++ concepts/enum/introduction.md | 2 ++ concepts/erlang-libraries/about.md | 2 ++ concepts/erlang-libraries/introduction.md | 2 ++ concepts/errors/about.md | 2 ++ concepts/errors/introduction.md | 2 ++ concepts/exceptions/about.md | 2 ++ concepts/exceptions/introduction.md | 6 ++++-- concepts/file/about.md | 2 ++ concepts/file/introduction.md | 2 ++ concepts/floating-point-numbers/about.md | 2 ++ concepts/floating-point-numbers/introduction.md | 6 ++++-- concepts/guards/about.md | 2 ++ concepts/guards/introduction.md | 2 ++ concepts/if/about.md | 2 ++ concepts/if/introduction.md | 4 +++- concepts/integers/about.md | 2 ++ concepts/integers/introduction.md | 2 ++ concepts/io/about.md | 2 ++ concepts/io/introduction.md | 6 ++++-- concepts/keyword-lists/about.md | 2 ++ concepts/keyword-lists/introduction.md | 2 ++ concepts/list-comprehensions/about.md | 2 ++ concepts/list-comprehensions/introduction.md | 2 ++ concepts/lists/about.md | 2 ++ concepts/lists/introduction.md | 2 ++ concepts/maps/about.md | 2 ++ concepts/maps/introduction.md | 6 ++++-- concepts/module-attributes-as-constants/about.md | 2 ++ .../module-attributes-as-constants/introduction.md | 2 ++ concepts/multiple-clause-functions/about.md | 2 ++ concepts/multiple-clause-functions/introduction.md | 2 ++ concepts/nil/about.md | 2 ++ concepts/nil/introduction.md | 2 ++ concepts/pattern-matching/about.md | 2 ++ concepts/pattern-matching/introduction.md | 4 +++- concepts/pids/about.md | 2 ++ concepts/pids/introduction.md | 2 ++ concepts/pipe-operator/about.md | 2 ++ concepts/pipe-operator/introduction.md | 2 ++ concepts/processes/about.md | 2 ++ concepts/processes/introduction.md | 6 ++++-- concepts/protocols/about.md | 2 ++ concepts/protocols/introduction.md | 2 ++ concepts/randomness/about.md | 2 ++ concepts/randomness/introduction.md | 2 ++ concepts/ranges/about.md | 2 ++ concepts/ranges/introduction.md | 2 ++ concepts/recursion/about.md | 2 ++ concepts/recursion/introduction.md | 2 ++ concepts/regular-expressions/about.md | 2 ++ concepts/regular-expressions/introduction.md | 2 ++ concepts/streams/about.md | 2 ++ concepts/streams/introduction.md | 2 ++ concepts/strings/about.md | 2 ++ concepts/strings/introduction.md | 2 ++ concepts/structs/about.md | 2 ++ concepts/structs/introduction.md | 6 ++++-- concepts/tail-call-recursion/about.md | 2 ++ concepts/tail-call-recursion/introduction.md | 2 ++ concepts/try-rescue-else-after/about.md | 2 ++ concepts/try-rescue-else-after/introduction.md | 2 ++ concepts/try-rescue/about.md | 2 ++ concepts/try-rescue/introduction.md | 2 ++ concepts/tuples/about.md | 2 ++ concepts/tuples/introduction.md | 4 +++- docs/ABOUT.md | 2 ++ docs/INSTALLATION.md | 4 +++- docs/LEARNING.md | 2 ++ docs/RESOURCES.md | 2 ++ docs/TESTS.md | 6 +++--- exercises/concept/basketball-website/.docs/hints.md | 2 ++ .../concept/basketball-website/.docs/instructions.md | 2 ++ .../concept/basketball-website/.docs/introduction.md | 2 +- exercises/concept/basketball-website/.meta/design.md | 2 ++ exercises/concept/bird-count/.docs/hints.md | 2 ++ exercises/concept/bird-count/.docs/instructions.md | 2 ++ exercises/concept/bird-count/.docs/introduction.md | 2 +- exercises/concept/bird-count/.meta/design.md | 2 ++ exercises/concept/boutique-inventory/.docs/hints.md | 2 ++ .../concept/boutique-inventory/.docs/instructions.md | 2 ++ .../concept/boutique-inventory/.docs/introduction.md | 2 +- exercises/concept/boutique-inventory/.meta/design.md | 2 ++ .../concept/boutique-suggestions/.docs/hints.md | 2 ++ .../boutique-suggestions/.docs/instructions.md | 2 ++ .../boutique-suggestions/.docs/introduction.md | 2 +- .../concept/boutique-suggestions/.meta/design.md | 2 ++ exercises/concept/bread-and-potions/.docs/hints.md | 2 ++ .../concept/bread-and-potions/.docs/instructions.md | 2 ++ .../concept/bread-and-potions/.docs/introduction.md | 2 +- exercises/concept/bread-and-potions/.meta/design.md | 2 ++ exercises/concept/captains-log/.docs/hints.md | 2 ++ exercises/concept/captains-log/.docs/instructions.md | 2 ++ exercises/concept/captains-log/.docs/introduction.md | 2 ++ exercises/concept/captains-log/.meta/design.md | 2 ++ exercises/concept/chessboard/.docs/hints.md | 2 ++ exercises/concept/chessboard/.docs/instructions.md | 2 ++ exercises/concept/chessboard/.docs/introduction.md | 2 +- exercises/concept/chessboard/.meta/design.md | 2 ++ exercises/concept/community-garden/.docs/hints.md | 2 ++ .../concept/community-garden/.docs/instructions.md | 2 ++ .../concept/community-garden/.docs/introduction.md | 2 +- exercises/concept/community-garden/.meta/design.md | 2 ++ exercises/concept/date-parser/.docs/hints.md | 2 ++ exercises/concept/date-parser/.docs/instructions.md | 2 ++ exercises/concept/date-parser/.docs/introduction.md | 2 +- exercises/concept/date-parser/.meta/design.md | 2 ++ exercises/concept/dna-encoding/.docs/hints.md | 2 ++ exercises/concept/dna-encoding/.docs/instructions.md | 2 ++ exercises/concept/dna-encoding/.docs/introduction.md | 2 ++ exercises/concept/dna-encoding/.meta/design.md | 2 ++ exercises/concept/file-sniffer/.docs/hints.md | 2 ++ exercises/concept/file-sniffer/.docs/instructions.md | 2 ++ exercises/concept/file-sniffer/.docs/introduction.md | 4 ++-- exercises/concept/file-sniffer/.meta/design.md | 2 ++ exercises/concept/freelancer-rates/.docs/hints.md | 2 ++ .../concept/freelancer-rates/.docs/instructions.md | 2 ++ .../concept/freelancer-rates/.docs/introduction.md | 2 ++ exercises/concept/freelancer-rates/.meta/design.md | 2 ++ exercises/concept/german-sysadmin/.docs/hints.md | 2 ++ .../concept/german-sysadmin/.docs/instructions.md | 2 ++ .../concept/german-sysadmin/.docs/introduction.md | 2 ++ exercises/concept/german-sysadmin/.meta/design.md | 2 ++ exercises/concept/guessing-game/.docs/hints.md | 2 ++ .../concept/guessing-game/.docs/instructions.md | 2 ++ .../concept/guessing-game/.docs/introduction.md | 2 ++ exercises/concept/guessing-game/.meta/design.md | 2 ++ .../concept/high-school-sweetheart/.docs/hints.md | 2 ++ .../high-school-sweetheart/.docs/instructions.md | 2 ++ .../high-school-sweetheart/.docs/introduction.md | 2 +- .../concept/high-school-sweetheart/.meta/design.md | 2 ++ exercises/concept/high-score/.docs/hints.md | 2 ++ exercises/concept/high-score/.docs/instructions.md | 2 ++ exercises/concept/high-score/.docs/introduction.md | 2 ++ exercises/concept/high-score/.meta/design.md | 2 ++ exercises/concept/kitchen-calculator/.docs/hints.md | 2 ++ .../concept/kitchen-calculator/.docs/instructions.md | 2 ++ .../concept/kitchen-calculator/.docs/introduction.md | 2 ++ exercises/concept/kitchen-calculator/.meta/design.md | 2 ++ exercises/concept/language-list/.docs/hints.md | 2 ++ .../concept/language-list/.docs/instructions.md | 2 ++ .../concept/language-list/.docs/introduction.md | 2 +- exercises/concept/language-list/.meta/design.md | 2 ++ exercises/concept/lasagna/.docs/hints.md | 2 ++ exercises/concept/lasagna/.docs/instructions.md | 2 ++ exercises/concept/lasagna/.docs/introduction.md | 12 ++++++------ exercises/concept/lasagna/.meta/design.md | 2 ++ exercises/concept/log-level/.docs/hints.md | 2 ++ exercises/concept/log-level/.docs/instructions.md | 2 ++ exercises/concept/log-level/.docs/introduction.md | 2 ++ exercises/concept/log-level/.meta/design.md | 2 ++ .../concept/mensch-aergere-dich-nicht/.docs/hints.md | 2 ++ .../mensch-aergere-dich-nicht/.docs/instructions.md | 2 ++ .../mensch-aergere-dich-nicht/.docs/introduction.md | 2 ++ .../mensch-aergere-dich-nicht/.meta/design.md | 2 ++ exercises/concept/name-badge/.docs/hints.md | 2 ++ exercises/concept/name-badge/.docs/instructions.md | 2 ++ exercises/concept/name-badge/.docs/introduction.md | 2 ++ exercises/concept/name-badge/.meta/design.md | 2 ++ exercises/concept/newsletter/.docs/hints.md | 2 ++ exercises/concept/newsletter/.docs/instructions.md | 2 ++ exercises/concept/newsletter/.docs/introduction.md | 2 +- exercises/concept/newsletter/.meta/design.md | 2 ++ exercises/concept/pacman-rules/.docs/hints.md | 2 ++ exercises/concept/pacman-rules/.docs/instructions.md | 2 ++ exercises/concept/pacman-rules/.docs/introduction.md | 2 +- exercises/concept/pacman-rules/.meta/design.md | 2 ++ exercises/concept/remote-control-car/.docs/hints.md | 2 ++ .../concept/remote-control-car/.docs/instructions.md | 2 ++ .../concept/remote-control-car/.docs/introduction.md | 6 +++--- exercises/concept/remote-control-car/.meta/design.md | 2 ++ exercises/concept/rpg-character-sheet/.docs/hints.md | 2 ++ .../rpg-character-sheet/.docs/instructions.md | 2 ++ .../rpg-character-sheet/.docs/introduction.md | 6 +++--- .../concept/rpg-character-sheet/.meta/design.md | 2 ++ .../concept/rpn-calculator-output/.docs/hints.md | 2 ++ .../rpn-calculator-output/.docs/instructions.md | 2 ++ .../rpn-calculator-output/.docs/introduction.md | 2 ++ .../concept/rpn-calculator-output/.meta/design.md | 2 ++ exercises/concept/rpn-calculator/.docs/hints.md | 2 ++ .../concept/rpn-calculator/.docs/instructions.md | 2 ++ .../concept/rpn-calculator/.docs/introduction.md | 2 ++ exercises/concept/rpn-calculator/.meta/design.md | 2 ++ exercises/concept/secrets/.docs/hints.md | 2 ++ exercises/concept/secrets/.docs/instructions.md | 2 ++ exercises/concept/secrets/.docs/introduction.md | 2 ++ exercises/concept/secrets/.meta/design.md | 2 ++ exercises/concept/stack-underflow/.docs/hints.md | 2 ++ .../concept/stack-underflow/.docs/instructions.md | 2 ++ .../concept/stack-underflow/.docs/introduction.md | 6 +++--- exercises/concept/stack-underflow/.meta/design.md | 2 ++ exercises/concept/take-a-number/.docs/hints.md | 2 ++ .../concept/take-a-number/.docs/instructions.md | 2 ++ .../concept/take-a-number/.docs/introduction.md | 2 ++ exercises/concept/take-a-number/.meta/design.md | 2 ++ exercises/concept/wine-cellar/.docs/hints.md | 2 ++ exercises/concept/wine-cellar/.docs/instructions.md | 2 ++ exercises/concept/wine-cellar/.docs/introduction.md | 2 +- exercises/concept/wine-cellar/.meta/design.md | 2 ++ exercises/practice/diffie-hellman/.docs/hints.md | 2 +- exercises/practice/secret-handshake/.docs/hints.md | 2 +- exercises/practice/strain/.docs/hints.md | 2 +- exercises/practice/tournament/.docs/hints.md | 2 +- exercises/practice/zipper/hints/README.md | 2 ++ exercises/practice/zipper/hints/hint_1.md | 2 ++ exercises/practice/zipper/hints/hint_2.md | 2 ++ exercises/practice/zipper/hints/hint_3.md | 2 ++ 237 files changed, 489 insertions(+), 61 deletions(-) diff --git a/concepts/access-behaviour/about.md b/concepts/access-behaviour/about.md index bce209f4c6..2e2917076c 100644 --- a/concepts/access-behaviour/about.md +++ b/concepts/access-behaviour/about.md @@ -1,3 +1,5 @@ +# About + Elixir uses [_Behaviours_][behaviours] to provide common generic interfaces while facilitating specific implementations for each module which implements the behaviour. One of those behaviours is the _Access Behaviour_. The _Access Behaviour_ provides a common interface for retrieving key-based data from a data structure. It is implemented for maps and keyword lists. diff --git a/concepts/access-behaviour/introduction.md b/concepts/access-behaviour/introduction.md index 3bd1db1069..4d971de305 100644 --- a/concepts/access-behaviour/introduction.md +++ b/concepts/access-behaviour/introduction.md @@ -1,3 +1,5 @@ +# Introduction + Elixir uses code _Behaviours_ to provide common generic interfaces while facilitating specific implementations for each module which implements it. One such common example is the _Access Behaviour_. The _Access Behaviour_ provides a common interface for retrieving data from a key-based data structure. The _Access Behaviour_ is implemented for maps and keyword lists, but let's look at its use for maps to get a feel for it. _Access Behaviour_ specifies that when you have a map, you may follow it with _square brackets_ and then use the key to retrieve the value associated with that key. diff --git a/concepts/agent/about.md b/concepts/agent/about.md index 5e92dae7a8..3180abda48 100644 --- a/concepts/agent/about.md +++ b/concepts/agent/about.md @@ -1,3 +1,5 @@ +# About + While spawning a process is easy, managing its state and behavior can become very complicated. The [`Agent`][agent-module] module is an abstraction to facilitate managing a shared state in an Elixir process. When using `Agent` module functions it is customary to encapsulate the agent-related functions in a single module. diff --git a/concepts/agent/introduction.md b/concepts/agent/introduction.md index c6022cd4bf..f4560703e3 100644 --- a/concepts/agent/introduction.md +++ b/concepts/agent/introduction.md @@ -1,3 +1,5 @@ +# Introduction + The `Agent` module facilitates an abstraction for spawning processes and the _receive-send_ loop. From here, we will call processes started using the `Agent` module _'agent processes'_. An _agent process_ might be chosen to represent a central shared state. To start an _agent process_, `Agent` provides the `start/2` function. The supplied function when `start`_-ing_ the _agent process_ returns the initial state of the process: diff --git a/concepts/anonymous-functions/about.md b/concepts/anonymous-functions/about.md index dd80237aa6..d0e7ec6e11 100644 --- a/concepts/anonymous-functions/about.md +++ b/concepts/anonymous-functions/about.md @@ -1,3 +1,5 @@ +# About + [Anonymous functions][anon-fns] are commonly used throughout Elixir on their own, as return values, and as arguments in higher order functions such as `Enum.map/2`: ```elixir diff --git a/concepts/anonymous-functions/introduction.md b/concepts/anonymous-functions/introduction.md index 56480da485..269d545c8f 100644 --- a/concepts/anonymous-functions/introduction.md +++ b/concepts/anonymous-functions/introduction.md @@ -1,3 +1,5 @@ +# Introduction + Functions are treated as first class citizens in Elixir. This means functions: - Can be assigned to variables. diff --git a/concepts/atoms/about.md b/concepts/atoms/about.md index 49f614c426..220ea9854c 100644 --- a/concepts/atoms/about.md +++ b/concepts/atoms/about.md @@ -1,3 +1,5 @@ +# About + You can use [atoms][atom] whenever you have a set of constants to express. Atoms provide a type-safe way to compare values. An atom is defined by its name, prefixed by a colon: ```elixir diff --git a/concepts/atoms/introduction.md b/concepts/atoms/introduction.md index 33f5c3f1e6..278eed17aa 100644 --- a/concepts/atoms/introduction.md +++ b/concepts/atoms/introduction.md @@ -1,3 +1,5 @@ +# Introduction + Elixir's `atom` type represents a fixed constant. An atom's value is simply its own name. This gives us a type-safe way to interact with data. Atoms can be defined as follows: ```elixir diff --git a/concepts/basics/about.md b/concepts/basics/about.md index 347607839d..7a04cd4fd4 100644 --- a/concepts/basics/about.md +++ b/concepts/basics/about.md @@ -1,3 +1,5 @@ +# About + - Elixir is dynamically-typed. - The type of a variable is only checked at run-time. - Using the match [`=`][match] operator, we can bind a value of any type to a variable name: diff --git a/concepts/basics/introduction.md b/concepts/basics/introduction.md index e10c574c03..2b859985ce 100644 --- a/concepts/basics/introduction.md +++ b/concepts/basics/introduction.md @@ -1,3 +1,5 @@ +# Introduction + Elixir is a dynamically-typed language, meaning that the type of a variable is only checked at runtime. Using the match `=` operator, we can bind a value of any type to a variable name: ```elixir @@ -9,7 +11,7 @@ count = false # You may re-bind any type to a variable message = "Success!" # Strings can be created by enclosing characters within double quotes ``` -### Modules +## Modules Elixir is an [functional-programming language][functional-programming] and requires all named functions to be defined in a _module_. The `defmodule` keyword is used to define a module. All modules are available to all other modules at runtime and do not require an _access modifier_ to make them visible to other parts of the program. A _module_ is analogous to a _class_ in other programming languages. @@ -19,7 +21,7 @@ defmodule Calculator do end ``` -### Named functions +## Named functions _Named Functions_ must be defined in a module. Each function can have zero or more arguments. All arguments are dynamically-typed, and the return type is not explicitly declared, it is the type of the value returned. An _access modifier_ can be specified for functions, making only desired functions available for use external to the module. In a function, the value of the last expression is _implicitly returned_ to the calling function. @@ -42,7 +44,7 @@ sum = Calculator.short_add(2, 2) # => 4 ``` -### Arity of functions +## Arity of functions It is common to refer to functions with their _arity_. The _arity_ of a function is the number of arguments it accepts. @@ -53,7 +55,7 @@ def add(x, y, z) do end ``` -### Standard library +## Standard library Elixir has a very rich and well-documented standard library. The documentation is available online at [hexdocs.pm/elixir][docs]. Save this link somewhere - you will use it a lot! @@ -61,7 +63,7 @@ Most built-in data types have a corresponding module that offers functions for w A notable module is the `Kernel` module. It provides the basic capabilities on top of which the rest of the standard library is built, like arithmetic operators, control-flow macros, and much more. Functions for the `Kernel` module are automatically imported, so you can use them without the `Kernel.` prefix. -### Documentation +## Documentation Documentation is a priority in high-quality Elixir code bases, and there are 3 ways to write inline documentation: diff --git a/concepts/binaries/about.md b/concepts/binaries/about.md index 4e33e91d34..721e560fbc 100644 --- a/concepts/binaries/about.md +++ b/concepts/binaries/about.md @@ -1,3 +1,5 @@ +# About + - The [binary][binary] type is a specialization of the [bitstring][bitstring] type. - Binaries are made up of [bytes][wiki-byte]. - Bytes are 8 [bits][wiki-bit]. diff --git a/concepts/binaries/introduction.md b/concepts/binaries/introduction.md index ab39e203c8..79f40949e7 100644 --- a/concepts/binaries/introduction.md +++ b/concepts/binaries/introduction.md @@ -1,3 +1,5 @@ +# Introduction + Elixir provides an elegant syntax for working with binary data as we have seen with the `<<>>` special form provided for working with _bitstrings_. The binary type is a specialization on the bitstring type. Where bitstrings could be of any length (any number of [bits][wiki-bit]), binaries are where the number of bits can be evenly divided by 8. That is, when working with binaries, we often think of things in terms of [bytes][wiki-byte] (8 bits). A byte can represent integer numbers from `0` to `255`. It is common to work with byte values in [hexadecimal][wiki-hexadecimal], `0x00 - 0xFF`. @@ -12,7 +14,7 @@ Binary literals are defined using the bitstring special form `<<>>`. When defini A _null-byte_ is another name for `<<0>>`. -### Pattern matching on binary data +## Pattern matching on binary data Pattern matching is even extended to binaries, and we can pattern match on a portion of binary data much like we could for a list. diff --git a/concepts/bit-manipulation/about.md b/concepts/bit-manipulation/about.md index 40b11fbff0..35fe63889d 100644 --- a/concepts/bit-manipulation/about.md +++ b/concepts/bit-manipulation/about.md @@ -1,3 +1,5 @@ +# About + [Bitwise binary functions][bitwise-wiki] can be performed on integers using functions from the [Bitwise module][bitwise-hexdocs]. - [`&&&/2`][bitwise-and]: bitwise AND diff --git a/concepts/bit-manipulation/introduction.md b/concepts/bit-manipulation/introduction.md index 13e76c6674..68836e1ed6 100644 --- a/concepts/bit-manipulation/introduction.md +++ b/concepts/bit-manipulation/introduction.md @@ -1,3 +1,5 @@ +# Introduction + Elixir supports many functions for working with bits found in the _Bitwise module_. - `&&&/2`: bitwise AND diff --git a/concepts/bitstrings/about.md b/concepts/bitstrings/about.md index 664e6a89fc..28c25c4016 100644 --- a/concepts/bitstrings/about.md +++ b/concepts/bitstrings/about.md @@ -1,3 +1,5 @@ +# About + [Bitstrings][bitstring] allow programmers to work with binary data effectively. - You can construct bitstrings elegantly using the [`<<>>` special form][bitstring-form]. diff --git a/concepts/bitstrings/introduction.md b/concepts/bitstrings/introduction.md index 713e227e7f..dd303c399e 100644 --- a/concepts/bitstrings/introduction.md +++ b/concepts/bitstrings/introduction.md @@ -1,3 +1,5 @@ +# Introduction + Working with binary data is an important concept in any language, and Elixir provides an elegant syntax to write, match, and construct binary data. In Elixir, binary data is referred to as the bitstring type. The binary data *type* (not to be confused with binary data in general) is a specific form of a bitstring, which we will discuss in a later exercise. @@ -27,7 +29,7 @@ By default, bitstrings are displayed in chunks of 8 bits (a byte). # => <<251, 3::size(3)>> ``` -### Constructing +## Constructing We can combine bitstrings stored in variables using the special form: @@ -38,7 +40,7 @@ combined = <> # => <<49::size(6)>> ``` -### Pattern matching +## Pattern matching Pattern matching can also be done to obtain the value from within the special form: diff --git a/concepts/booleans/about.md b/concepts/booleans/about.md index 219e1d5ac2..a8aadf9bbe 100644 --- a/concepts/booleans/about.md +++ b/concepts/booleans/about.md @@ -1,3 +1,5 @@ +# About + Elixir represents true and false values with the boolean type. There are only two values: `true` and `false`. These values can be combined with boolean operators ([`and/2`][strict-and], [`or/2`][strict-or], [`not/1`][strict-not]): ```elixir diff --git a/concepts/booleans/introduction.md b/concepts/booleans/introduction.md index 531b9b950f..bcd6b3801d 100644 --- a/concepts/booleans/introduction.md +++ b/concepts/booleans/introduction.md @@ -1,3 +1,5 @@ +# Introduction + Elixir represents true and false values with the boolean type. There are only two values: `true` and `false`. ```elixir diff --git a/concepts/case/about.md b/concepts/case/about.md index 9207e6752e..9d6e4828dc 100644 --- a/concepts/case/about.md +++ b/concepts/case/about.md @@ -1,3 +1,5 @@ +# About + [`case`][case] is a control flow structure that allows us to compare a given value against many patterns. Clauses in a `case` expression are evaluated from top to bottom, until a match is found. In many cases, using `case` is interchangeable with defining multiple function clauses. Pattern matching and guards can be used in `case` clauses. diff --git a/concepts/case/introduction.md b/concepts/case/introduction.md index f5090f8845..e46db83222 100644 --- a/concepts/case/introduction.md +++ b/concepts/case/introduction.md @@ -1,3 +1,5 @@ +# Introduction + `case` is a control flow structure that allows us to compare a given value against many patterns. Clauses in a `case` statement are evaluated from top to bottom, until a match is found. ```elixir diff --git a/concepts/charlists/about.md b/concepts/charlists/about.md index 3e2768d56f..87e2c437aa 100644 --- a/concepts/charlists/about.md +++ b/concepts/charlists/about.md @@ -1,3 +1,5 @@ +# About + Charlists are created using single quotes. ```elixir diff --git a/concepts/charlists/introduction.md b/concepts/charlists/introduction.md index a03b85c96f..9aab129ef6 100644 --- a/concepts/charlists/introduction.md +++ b/concepts/charlists/introduction.md @@ -1,3 +1,5 @@ +# Introduction + Charlists are created using single quotes. ```elixir diff --git a/concepts/closures/about.md b/concepts/closures/about.md index 0e525bd048..d98a599bf9 100644 --- a/concepts/closures/about.md +++ b/concepts/closures/about.md @@ -1,3 +1,5 @@ +# About + Anonymous functions in Elixir are [closures][closure]. They can access variables that are in scope when the function is defined. ```elixir diff --git a/concepts/closures/introduction.md b/concepts/closures/introduction.md index 9391900d18..d6788a76c4 100644 --- a/concepts/closures/introduction.md +++ b/concepts/closures/introduction.md @@ -1,3 +1,5 @@ +# Introduction + Anonymous functions in Elixir are [closures][closure]. They can access variables that are in scope when the function is defined. ```elixir diff --git a/concepts/cond/about.md b/concepts/cond/about.md index 883b48cc7b..86bb62451b 100644 --- a/concepts/cond/about.md +++ b/concepts/cond/about.md @@ -1,3 +1,5 @@ +# About + When we want to have branching code, we can use [`cond/1`][cond]: ```elixir diff --git a/concepts/cond/introduction.md b/concepts/cond/introduction.md index 2726580c5e..6ecd76c6f9 100644 --- a/concepts/cond/introduction.md +++ b/concepts/cond/introduction.md @@ -1,3 +1,5 @@ +# Introduction + Often, we want to write code that can branch based on a condition. While there are many ways to do this in Elixir, one of the simplest ways is using `cond/1`. At its simplest, `cond` follows the first path that evaluates to `true` with one or more branches: diff --git a/concepts/default-arguments/about.md b/concepts/default-arguments/about.md index 66c23f1520..a8d76e7297 100644 --- a/concepts/default-arguments/about.md +++ b/concepts/default-arguments/about.md @@ -1,3 +1,5 @@ +# About + Functions may declare [default values][default-arguments] for one or more arguments. ```elixir diff --git a/concepts/default-arguments/introduction.md b/concepts/default-arguments/introduction.md index 5ac8537d6d..9586108671 100644 --- a/concepts/default-arguments/introduction.md +++ b/concepts/default-arguments/introduction.md @@ -1,3 +1,5 @@ +# Introduction + Functions may declare default values for one or more arguments. Let's consider this function: ```elixir diff --git a/concepts/dynamic-dispatch/about.md b/concepts/dynamic-dispatch/about.md index 54acf3bd57..006b5316a3 100644 --- a/concepts/dynamic-dispatch/about.md +++ b/concepts/dynamic-dispatch/about.md @@ -1,3 +1,5 @@ +# About + Functions in Elixir can be dispatched dynamically. All module names are atoms. All Elixir module names are automatically prefixed with `Elixir.` when compiled. diff --git a/concepts/dynamic-dispatch/introduction.md b/concepts/dynamic-dispatch/introduction.md index e885be1ff3..eb3c73fd19 100644 --- a/concepts/dynamic-dispatch/introduction.md +++ b/concepts/dynamic-dispatch/introduction.md @@ -1,3 +1,5 @@ +# Introduction + When Elixir resolves the function to be invoked, it uses the Module's name to perform a lookup. The lookup can be done dynamically if the Module's name is bound to a variable. ```elixir diff --git a/concepts/enum/about.md b/concepts/enum/about.md index 595dd3b966..ecb4ba6621 100644 --- a/concepts/enum/about.md +++ b/concepts/enum/about.md @@ -1,3 +1,5 @@ +# About + `Enum` is a very useful module that provides a set of algorithms for working with enumerables. It offers: - sorting ([`sort/2`][enum-sort/2], [`sort_by/2`][enum-sort_by/2]), diff --git a/concepts/enum/introduction.md b/concepts/enum/introduction.md index 13232f330a..58df46de1e 100644 --- a/concepts/enum/introduction.md +++ b/concepts/enum/introduction.md @@ -1,3 +1,5 @@ +# Introduction + `Enum` is a very useful module that provides a set of algorithms for working with enumerables. It offers sorting, filtering, grouping, counting, searching, finding min/max values, and much more. In general, an _enumerable_ is any data that can be iterated over, a collection. In Elixir, an enumerable is any data type that implements the `Enumerable` protocol. The most common of those are lists and maps. diff --git a/concepts/erlang-libraries/about.md b/concepts/erlang-libraries/about.md index 6a3a20f03f..6e8a70b2d6 100644 --- a/concepts/erlang-libraries/about.md +++ b/concepts/erlang-libraries/about.md @@ -1,3 +1,5 @@ +# About + Elixir code runs in the [BEAM virtual machine][beam]. BEAM is part of the [Erlang][erlang] Run-Time System. Being inspired by Erlang, and sharing its run environment, Elixir provides great interoperability with Erlang libraries. This means that Elixir developers can use Erlang libraries from within their Elixir code. In fact, writing Elixir libraries for functionality already provided by Erlang libraries is discouraged in the Elixir community. As a result, certain functionality, like mathematical operations or timer functions, is only available in Elixir via Erlang. diff --git a/concepts/erlang-libraries/introduction.md b/concepts/erlang-libraries/introduction.md index e4062b1ac3..8cf3f7ee03 100644 --- a/concepts/erlang-libraries/introduction.md +++ b/concepts/erlang-libraries/introduction.md @@ -1,3 +1,5 @@ +# Introduction + Elixir code runs in the BEAM virtual machine. BEAM is part of the Erlang Run-Time System. Being inspired by Erlang, and sharing its run environment, Elixir provides great interoperability with Erlang libraries. This means that Elixir developers can use Erlang libraries from within their Elixir code. In fact, writing Elixir libraries for functionality already provided by Erlang libraries is discouraged in the Elixir community. As a result, certain functionality, like mathematical operations or timer functions, is only available in Elixir via Erlang. diff --git a/concepts/errors/about.md b/concepts/errors/about.md index 131ad24aee..52ff301c39 100644 --- a/concepts/errors/about.md +++ b/concepts/errors/about.md @@ -1,3 +1,5 @@ +# About + While Elixir programmers often say ["let it crash"][let-it-crash] and code for the ["happy path"][happy-path], there are often times we need to rescue the function call to return a specific value, message or release system resources. - Functions that raise errors under normal circumstances should have `!` at the end of their name. diff --git a/concepts/errors/introduction.md b/concepts/errors/introduction.md index dd57a0fe9f..eea753ea0f 100644 --- a/concepts/errors/introduction.md +++ b/concepts/errors/introduction.md @@ -1,3 +1,5 @@ +# Introduction + Errors happen. In Elixir, while people often say to "let it crash", there are times when we need to rescue the function call to a known good state to fulfil a software contract. In some languages, errors are used as method of control flow, but in Elixir, this pattern is discouraged. We can often recognize functions that may raise an error just by their name: functions that raise errors are to have `!` at the end of their name. This is in comparison with functions that return `{:ok, value}` or `:error`. Look at these library examples: ```elixir diff --git a/concepts/exceptions/about.md b/concepts/exceptions/about.md index ee20f354ff..5d908a3a96 100644 --- a/concepts/exceptions/about.md +++ b/concepts/exceptions/about.md @@ -1,3 +1,5 @@ +# About + The [_Exception Behaviour_][exception-behaviour] defines how [`errors`][getting-started-errors] are raised and displayed. It includes two optional callbacks: diff --git a/concepts/exceptions/introduction.md b/concepts/exceptions/introduction.md index ba89a5a7f5..69db5584f1 100644 --- a/concepts/exceptions/introduction.md +++ b/concepts/exceptions/introduction.md @@ -1,3 +1,5 @@ +# Introduction + All errors in Elixir implement the _Exception Behaviour_. Just like the _Access Behaviour_, the _Exception Behaviour_ defines callback functions that a module must implement to fulfill the software contract of the behaviour. Once an error is defined, it has the following properties: - The module's name defines the error's name. @@ -7,7 +9,7 @@ All errors in Elixir implement the _Exception Behaviour_. Just like the _Access The _Exception Behaviour_ also specifies two callbacks: `message/1` and `exception/1`. If unimplemented, default implementations will be used. `message/1` transforms the error-struct to a readable message when called with `raise`. `exception/1` allows additional context to be added to the message when it is called with `raise/2` -### Defining an exception +## Defining an exception To define an exception from an error module, we use the `defexception` macro: @@ -33,7 +35,7 @@ defmodule MyCustomizedError do end ``` -### Using exceptions +## Using exceptions Defined errors may be used like a built in error using either `raise/1` or `raise/2`. diff --git a/concepts/file/about.md b/concepts/file/about.md index 7b9d960584..9207d83f05 100644 --- a/concepts/file/about.md +++ b/concepts/file/about.md @@ -1,3 +1,5 @@ +# About + Functions for working with files are provided by the [`File`][file] module. To read a whole file, use [`File.read/1`][file-read]. To write to a file, use [`File.write/2`][file-write]. diff --git a/concepts/file/introduction.md b/concepts/file/introduction.md index 365935e46e..f871adb830 100644 --- a/concepts/file/introduction.md +++ b/concepts/file/introduction.md @@ -1,3 +1,5 @@ +# Introduction + Functions for working with files are provided by the `File` module. To read a whole file, use `File.read/1`. To write to a file, use `File.write/2`. diff --git a/concepts/floating-point-numbers/about.md b/concepts/floating-point-numbers/about.md index b8a3dbe35f..49c9c95bf8 100644 --- a/concepts/floating-point-numbers/about.md +++ b/concepts/floating-point-numbers/about.md @@ -1,3 +1,5 @@ +# About + There are two different kinds of numbers in Elixir - integers and floats. Floats are numbers with one or more digits behind the decimal separator. They use the 64-bit double precision floating-point format. diff --git a/concepts/floating-point-numbers/introduction.md b/concepts/floating-point-numbers/introduction.md index 636d72f65b..2a14542d9c 100644 --- a/concepts/floating-point-numbers/introduction.md +++ b/concepts/floating-point-numbers/introduction.md @@ -1,3 +1,5 @@ +# Introduction + Floats are numbers with one or more digits behind the decimal separator. They use the 64-bit double precision floating-point format. ```elixir @@ -5,11 +7,11 @@ float = 3.45 # => 3.45 ``` -### Working with numbers +## Working with numbers In the [`Integer`][integer-functions] and [`Float`][float-functions] modules you can find some useful functions for working with those types. Basic arithmetic operators are defined in the [`Kernel`][kernel-arithmetic-operators] module. -### Conversion +## Conversion Integers and floats can be mixed together in a single arithmetic expression. Using a float in an expression ensures the result will be a float too. diff --git a/concepts/guards/about.md b/concepts/guards/about.md index 3561ee3743..d441071e19 100644 --- a/concepts/guards/about.md +++ b/concepts/guards/about.md @@ -1,3 +1,5 @@ +# About + [Guards][guards] are used as a complement to pattern matching. They allow for more complex checks. They can be used in [some, but not all situations][where-guards-can-be-used] where pattern matching can be used, for example in function clauses or case clauses. ```elixir diff --git a/concepts/guards/introduction.md b/concepts/guards/introduction.md index 76e1186c40..943e8bbd3d 100644 --- a/concepts/guards/introduction.md +++ b/concepts/guards/introduction.md @@ -1,3 +1,5 @@ +# Introduction + Guards are used to prevent Elixir from invoking functions based on evaluation of the arguments by guard functions. Guards begin with the `when` keyword, followed by a boolean expression. Guard functions are special functions which: - Must be pure and not mutate any global states. diff --git a/concepts/if/about.md b/concepts/if/about.md index 09840b5bf9..41edc5e6a7 100644 --- a/concepts/if/about.md +++ b/concepts/if/about.md @@ -1,3 +1,5 @@ +# About + Besides `cond`, Elixir also provides the macros [`if/2` and `unless/2`][getting-started-if-unless] which are useful when you need to check for only one condition. [`if/2`][kernel-if] accepts a condition and two options. It returns the first option if the condition is _truthy_, and the second option if the condition is _falsy_. [`unless/2`][kernel-unless] does the opposite. diff --git a/concepts/if/introduction.md b/concepts/if/introduction.md index 7b3a22d249..2e25a01436 100644 --- a/concepts/if/introduction.md +++ b/concepts/if/introduction.md @@ -1,3 +1,5 @@ +# Introduction + Besides `cond`, Elixir also provides the macro [`if/2`][getting-started-if-unless] which is useful when you need to check for only one condition. [`if/2`][kernel-if] accepts a condition and two options. It returns the first option if the condition is _truthy_, and the second option if the condition is _falsy_. @@ -22,7 +24,7 @@ if age > 16, do: "beer", else: "no beer" This syntax is helpful for very short expressions, but should be avoided if the expression won't fit on a single line. -### _Truthy_ and _falsy_ +## _Truthy_ and _falsy_ In Elixir, all datatypes evaluate to a _truthy_ or _falsy_ value when they are encountered in a boolean context (like an `if` expression). All data is considered _truthy_ **except** for _false_ and _nil_. diff --git a/concepts/integers/about.md b/concepts/integers/about.md index 30e61af7bb..9ca3d17cf2 100644 --- a/concepts/integers/about.md +++ b/concepts/integers/about.md @@ -1,3 +1,5 @@ +# About + There are two different kinds of numbers in Elixir - integers and floats. Integers are whole numbers. diff --git a/concepts/integers/introduction.md b/concepts/integers/introduction.md index 9b776c75f1..9ce0711248 100644 --- a/concepts/integers/introduction.md +++ b/concepts/integers/introduction.md @@ -1,3 +1,5 @@ +# Introduction + There are two different kinds of numbers in Elixir - integers and floats. Integers are whole numbers. diff --git a/concepts/io/about.md b/concepts/io/about.md index 561a99dcc0..157a6333b8 100644 --- a/concepts/io/about.md +++ b/concepts/io/about.md @@ -1,3 +1,5 @@ +# About + Functions for handling input and output are provided by the [`IO` module][module-io]. - [`IO.puts/2`][io-puts] writes a string to the standard output, followed by a newline. Returns `:ok`. diff --git a/concepts/io/introduction.md b/concepts/io/introduction.md index 664f30808c..abf66789f3 100644 --- a/concepts/io/introduction.md +++ b/concepts/io/introduction.md @@ -1,6 +1,8 @@ +# Introduction + Functions for handling input and output are provided by the `IO` module. -### Output +## Output To write a string to the standard output, use `IO.puts`. `IO.puts` always adds a new line at the end of the string. If you don't want that behavior, use `IO.write` instead. Both functions return the atom `:ok` if they succeed. @@ -12,7 +14,7 @@ IO.puts("Hi!") `IO.puts` is useful for writing strings, but not much else. If you need a tool for debugging that will allow you to write any value to standard output, use `IO.inspect` instead. `IO.inspect` returns the value it was passed unchanged, so it can be inserted in any point in your code. It also accepts many options, for example `:label`, that will allow you to distinguish it form other `IO.inspect` calls. -### Input +## Input To read a line from the standard input, use `IO.gets`. `IO.gets` accepts one argument - a string that it will print as a prompt for the input. `IO.gets` doesn't add a new line after the prompt, you need it include it yourself if you need it. diff --git a/concepts/keyword-lists/about.md b/concepts/keyword-lists/about.md index a6ada23648..cb0b545909 100644 --- a/concepts/keyword-lists/about.md +++ b/concepts/keyword-lists/about.md @@ -1,3 +1,5 @@ +# About + A keyword list is a list of `{key, value}` tuples. There are two way to write a keyword list: ```elixir diff --git a/concepts/keyword-lists/introduction.md b/concepts/keyword-lists/introduction.md index 5519c390b6..3dc5585dd4 100644 --- a/concepts/keyword-lists/introduction.md +++ b/concepts/keyword-lists/introduction.md @@ -1,3 +1,5 @@ +# Introduction + Keyword lists are a key-value data structure. ```elixir diff --git a/concepts/list-comprehensions/about.md b/concepts/list-comprehensions/about.md index fa5e2439e3..af34a2bfb3 100644 --- a/concepts/list-comprehensions/about.md +++ b/concepts/list-comprehensions/about.md @@ -1,3 +1,5 @@ +# About + [Comprehension][for] provide a facility for transforming _Enumerables_ easily and declaratively. They are _syntactic sugar_ for iterating through enumerables in Elixir. ```elixir diff --git a/concepts/list-comprehensions/introduction.md b/concepts/list-comprehensions/introduction.md index c5f1dff287..a654f3d560 100644 --- a/concepts/list-comprehensions/introduction.md +++ b/concepts/list-comprehensions/introduction.md @@ -1,3 +1,5 @@ +# Introduction + Comprehensions provide a facility for transforming _Enumerables_ easily and declaratively. To declare a very simple comprehension, we can use the `for` keyword followed by a _generator_ and a _do-block_ which creates the new values from the enumerated values. diff --git a/concepts/lists/about.md b/concepts/lists/about.md index eea140df79..f78abc2853 100644 --- a/concepts/lists/about.md +++ b/concepts/lists/about.md @@ -1,3 +1,5 @@ +# About + [Lists][list] are a basic data type in Elixir for holding a collection of values. Lists are _immutable_, meaning they cannot be modified. Any operation that changes a list returns a new list. Lists implement the [Enumerable protocol][enum-protocol], which allows the use of [Enum][enum] and [Stream][stream] module functions. Lists in Elixir are implemented as [linked lists][linked-list-wiki], and not as arrays of contiguous memory location. Therefore, accessing an element in a list takes linear time depending on the length of the list. diff --git a/concepts/lists/introduction.md b/concepts/lists/introduction.md index 0bf4b84345..c89e2a94e3 100644 --- a/concepts/lists/introduction.md +++ b/concepts/lists/introduction.md @@ -1,3 +1,5 @@ +# Introduction + Lists are built-in to the Elixir language. They are considered a basic type, denoted by square brackets. Lists may be empty or hold any number of items of any type. For example: ```elixir diff --git a/concepts/maps/about.md b/concepts/maps/about.md index de154fde6b..3ecc64dffd 100644 --- a/concepts/maps/about.md +++ b/concepts/maps/about.md @@ -1,3 +1,5 @@ +# About + [Maps][maps] are a data structure that holds key-value pairs. - Keys can be of any type, but must be unique. diff --git a/concepts/maps/introduction.md b/concepts/maps/introduction.md index b54d8eca4e..eaea2aec9e 100644 --- a/concepts/maps/introduction.md +++ b/concepts/maps/introduction.md @@ -1,8 +1,10 @@ +# Introduction + Maps in Elixir are the data structure for storing information in key-value pairs. In other languages, these might also be known as associative arrays (PHP), hashes (Perl 5, Raku), or dictionaries (Python). Keys and values can be of any data type, but if the key is an atom we can use a shorthand syntax. Maps do not guarantee the order of their entries when accessed or returned. -### Literal forms +## Literal forms An empty map is simply declared with `%{}`. If we want to add items to a map literal, we can use two forms: @@ -19,7 +21,7 @@ An empty map is simply declared with `%{}`. If we want to add items to a map lit While there is no canonical format, choose a consistent way to represent the key-value literal pairs. -### Map module functions +## Map module functions Elixir provides many functions for working with maps in the _Map module_. Some _Map module_ functions require an _anonymous_ or _captured function_ to be passed into the function to assist with the map transformation. diff --git a/concepts/module-attributes-as-constants/about.md b/concepts/module-attributes-as-constants/about.md index 6ae80ae304..0b6b833f62 100644 --- a/concepts/module-attributes-as-constants/about.md +++ b/concepts/module-attributes-as-constants/about.md @@ -1,3 +1,5 @@ +# About + [Module attributes][module-attr] may be used like ["constants"][attr-as-const] which are evaluated at compile-time. ```elixir diff --git a/concepts/module-attributes-as-constants/introduction.md b/concepts/module-attributes-as-constants/introduction.md index 9f75bf78ad..446134933a 100644 --- a/concepts/module-attributes-as-constants/introduction.md +++ b/concepts/module-attributes-as-constants/introduction.md @@ -1,3 +1,5 @@ +# Introduction + In Elixir, we can define module attributes which can be used as constants in our functions. ```elixir diff --git a/concepts/multiple-clause-functions/about.md b/concepts/multiple-clause-functions/about.md index 8c187259a2..328a741a72 100644 --- a/concepts/multiple-clause-functions/about.md +++ b/concepts/multiple-clause-functions/about.md @@ -1,3 +1,5 @@ +# About + In Elixir, a single function can have multiple clauses. This is achieved by pattern matching the function's arguments and by using guards. ```elixir diff --git a/concepts/multiple-clause-functions/introduction.md b/concepts/multiple-clause-functions/introduction.md index 27c6511c21..0c442804c4 100644 --- a/concepts/multiple-clause-functions/introduction.md +++ b/concepts/multiple-clause-functions/introduction.md @@ -1,3 +1,5 @@ +# Introduction + Elixir facilitates **Open-Close Principle** practices by allowing functions to have multiple clauses, so instead of sprawling and hard-coded control-logic, pointed functions can be written to add/remove behavior easily. Elixir offers _multiple function clauses_ and _guards_ to write: diff --git a/concepts/nil/about.md b/concepts/nil/about.md index c82e33bb67..4ebc3249bc 100644 --- a/concepts/nil/about.md +++ b/concepts/nil/about.md @@ -1,3 +1,5 @@ +# About + [Nil][nil-dictionary] is an English word meaning "nothing" or "zero". In Elixir, `nil` is a special value that means an _absence_ of a value. ```elixir diff --git a/concepts/nil/introduction.md b/concepts/nil/introduction.md index 5153e95077..fb3bdf29a3 100644 --- a/concepts/nil/introduction.md +++ b/concepts/nil/introduction.md @@ -1,3 +1,5 @@ +# Introduction + [Nil][nil-dictionary] is an English word meaning "nothing" or "zero". In Elixir, `nil` is a special value that means an _absence_ of a value. ```elixir diff --git a/concepts/pattern-matching/about.md b/concepts/pattern-matching/about.md index 5444f2b411..60046bb520 100644 --- a/concepts/pattern-matching/about.md +++ b/concepts/pattern-matching/about.md @@ -1,3 +1,5 @@ +# About + When writing Elixir functions, we can make use of an [assertive style][assertive-style] with [pattern matching][pattern-match-doc]: ```elixir diff --git a/concepts/pattern-matching/introduction.md b/concepts/pattern-matching/introduction.md index 78dc757076..d4f8ec1dad 100644 --- a/concepts/pattern-matching/introduction.md +++ b/concepts/pattern-matching/introduction.md @@ -1,3 +1,5 @@ +# Introduction + The use of pattern matching is dominant in assertive, idiomatic Elixir code. You might recall that `=/2` is described as a match operator rather than as an assignment operator. When using the match operator, if the pattern on the left matches the right, any variables on the left are bound, and the value of the right side is returned. A `MatchError` is raised if there is no match. ```elixir @@ -17,7 +19,7 @@ Remember, matches occur from the right side to the left side. In the last example if we don't need a variable in a pattern match, we can discard it by referencing `_`. Any variable starting with an `_` is not tracked by the runtime. -### Pattern matching in named functions +## Pattern matching in named functions Pattern matching is also a useful tool when creating multiple function clauses. Pattern matching can be used on the functions' arguments which then determines which function clause to invoke -- starting from the top of the file down until the first match. Variables may be bound in a function head and used in the function body. diff --git a/concepts/pids/about.md b/concepts/pids/about.md index a1cd2f46b5..d6b2632fec 100644 --- a/concepts/pids/about.md +++ b/concepts/pids/about.md @@ -1,3 +1,5 @@ +# About + Each Elixir process has its own unique identifier - a _PID_ (process identifier). - PIDs are their own data type. diff --git a/concepts/pids/introduction.md b/concepts/pids/introduction.md index fe1f4a3023..708e75eca6 100644 --- a/concepts/pids/introduction.md +++ b/concepts/pids/introduction.md @@ -1 +1,3 @@ +# Introduction + Process identifiers are their own data type. They function as _mailbox addresses_ - if you have a process' PID, you can send a message to that process. PIDs are usually created indirectly, as a return value of functions that create new processes, like `spawn`. diff --git a/concepts/pipe-operator/about.md b/concepts/pipe-operator/about.md index 8d40dbbd68..2d3e1a67a5 100644 --- a/concepts/pipe-operator/about.md +++ b/concepts/pipe-operator/about.md @@ -1,3 +1,5 @@ +# About + The `|>` operator is called [the pipe operator][pipe]. It can be used to chain function calls together in such a way that the value returned by the previous function call is passed as the first argument to the next function call. ```elixir diff --git a/concepts/pipe-operator/introduction.md b/concepts/pipe-operator/introduction.md index 08266b09f0..45b072c281 100644 --- a/concepts/pipe-operator/introduction.md +++ b/concepts/pipe-operator/introduction.md @@ -1,3 +1,5 @@ +# Introduction + The `|>` operator is called the pipe operator. It can be used to chain function calls together in such a way that the value returned by the previous function call is passed as the first argument to the next function call. ```elixir diff --git a/concepts/processes/about.md b/concepts/processes/about.md index 931822e8c0..93609c044d 100644 --- a/concepts/processes/about.md +++ b/concepts/processes/about.md @@ -1,3 +1,5 @@ +# About + In Elixir, all code runs inside processes. Elixir processes: - Should not be confused with system processes. diff --git a/concepts/processes/introduction.md b/concepts/processes/introduction.md index 32bc060e38..aa38336b3b 100644 --- a/concepts/processes/introduction.md +++ b/concepts/processes/introduction.md @@ -1,3 +1,5 @@ +# Introduction + In Elixir, all code runs inside processes. By default, a function will execute in the same process from which it was called. When you need to explicitly run a certain function in a new process, use `spawn/1`: @@ -11,7 +13,7 @@ spawn(fn -> 2 + 2 end) Elixir's processes should not be confused with operating system processes. Elixir's processes use much less memory and CPU. It's perfectly fine to have Elixir applications that run hundreds of Elixir processes. -### Messages +## Messages Processes do not directly share information with one another. Processes _send and receive messages_ to share data. @@ -32,6 +34,6 @@ end `receive/1` will take _one message_ from the mailbox that matches any of the given patterns and execute the expression given for that pattern. If there are no messages in the mailbox, or none of messages in the mailbox match any of the patterns, `receive/1` is going to wait for one. -### Receive loop +## Receive loop If you want to receive more than one message, you need to call `receive/1` recursively. It is a common pattern to implement a recursive function, for example named `loop`, that calls `receive/1`, does something with the message, and then calls itself to wait for more messages. If you need to carry some state from one `receive/1` call to another, you can do it by passing an argument to that `loop` function. diff --git a/concepts/protocols/about.md b/concepts/protocols/about.md index a840ae2b0e..3ea410333d 100644 --- a/concepts/protocols/about.md +++ b/concepts/protocols/about.md @@ -1,3 +1,5 @@ +# About + Protocols are: - A mechanism to achieve polymorphism. diff --git a/concepts/protocols/introduction.md b/concepts/protocols/introduction.md index 6182a269c6..f6f22920a4 100644 --- a/concepts/protocols/introduction.md +++ b/concepts/protocols/introduction.md @@ -1,3 +1,5 @@ +# Introduction + Protocols are a mechanism to achieve polymorphism in Elixir when you want behavior to vary depending on the data type. Protocols are defined using `defprotocol` and contain one or more function header. diff --git a/concepts/randomness/about.md b/concepts/randomness/about.md index e90a51a0a8..90253f21ae 100644 --- a/concepts/randomness/about.md +++ b/concepts/randomness/about.md @@ -1,3 +1,5 @@ +# About + In Elixir, to choose a random element from an enumerable data structure (e.g. list, range), we use [`Enum.random/1`][enum-random]. This function will pick a single element, with every element having equal probability of being picked. Picking a single random value from a range is executed in constant time, without traversing the whole range. ## Random integers and letters diff --git a/concepts/randomness/introduction.md b/concepts/randomness/introduction.md index 5ce4d147c0..8bd2a1a3dc 100644 --- a/concepts/randomness/introduction.md +++ b/concepts/randomness/introduction.md @@ -1,3 +1,5 @@ +# Introduction + In Elixir, to choose a random element from an enumerable data structure (e.g. list, range), we use `Enum.random`. This function will pick a single element, with every element having equal probability of being picked. Elixir does not have its own functions for picking a random float. To do that, we have to use Erlang directly. diff --git a/concepts/ranges/about.md b/concepts/ranges/about.md index b753eb4c3d..14524031f5 100644 --- a/concepts/ranges/about.md +++ b/concepts/ranges/about.md @@ -1,3 +1,5 @@ +# About + [Ranges][range] represent a sequence of one or many consecutive integers. They: - Are created using the [`..` operator][range-operator] and can be both ascending or descending. diff --git a/concepts/ranges/introduction.md b/concepts/ranges/introduction.md index 42dc90d231..ab0e51bbf5 100644 --- a/concepts/ranges/introduction.md +++ b/concepts/ranges/introduction.md @@ -1,3 +1,5 @@ +# Introduction + Ranges represent a sequence of one or many consecutive integers. They are created by connecting two integers with `..`. ```elixir diff --git a/concepts/recursion/about.md b/concepts/recursion/about.md index 2df73786ef..39aada8c7b 100644 --- a/concepts/recursion/about.md +++ b/concepts/recursion/about.md @@ -1,3 +1,5 @@ +# About + Recursive functions are functions that call themselves. A recursive function needs to have at least one _base case_ and at least one _recursive case_. diff --git a/concepts/recursion/introduction.md b/concepts/recursion/introduction.md index a4443ad468..1959016035 100644 --- a/concepts/recursion/introduction.md +++ b/concepts/recursion/introduction.md @@ -1,3 +1,5 @@ +# Introduction + Recursive functions are functions that call themselves. A recursive function needs to have at least one _base case_ and at least one _recursive case_. diff --git a/concepts/regular-expressions/about.md b/concepts/regular-expressions/about.md index da043a522b..48bd8acc09 100644 --- a/concepts/regular-expressions/about.md +++ b/concepts/regular-expressions/about.md @@ -1,3 +1,5 @@ +# About + Regular expressions (regex) are a powerful tool for working with strings in Elixir. Regular expressions in Elixir follow the **PCRE** specification (**P**erl **C**ompatible **R**egular **E**xpressions). String patterns representing the regular expression's meaning are first compiled then used for matching all or part of a string. In Elixir, the most common way to create regular expressions is using [the `~r` sigil][sigils-regex]. Sigils provide _syntactic sugar_ shortcuts for common tasks in Elixir. In this case, `~r` is a shortcut for using [`Regex.compile!/2`][regex-compile]. diff --git a/concepts/regular-expressions/introduction.md b/concepts/regular-expressions/introduction.md index fde29e2f77..355d2845b7 100644 --- a/concepts/regular-expressions/introduction.md +++ b/concepts/regular-expressions/introduction.md @@ -1,3 +1,5 @@ +# Introduction + Regular expressions (regex) are a powerful tool for working with strings in Elixir. Regular expressions in Elixir follow the **PCRE** specification (**P**erl **C**ompatible **R**egular **E**xpressions). String patterns representing the regular expression's meaning are first compiled then used for matching all or part of a string. In Elixir, the most common way to create regular expressions is using the `~r` sigil. Sigils provide _syntactic sugar_ shortcuts for common tasks in Elixir. To match a _string literal_, we can use the string itself as a pattern following the sigil. diff --git a/concepts/streams/about.md b/concepts/streams/about.md index ac4d057e69..5cc7c5e148 100644 --- a/concepts/streams/about.md +++ b/concepts/streams/about.md @@ -1,3 +1,5 @@ +# About + The [`Stream` module][stream] is a _lazy_ alternative to the _eager_ [`Enum` module][enum]. Streams: - Implement the [_Enumerable protocol_][enumerable]. diff --git a/concepts/streams/introduction.md b/concepts/streams/introduction.md index 8fa73d0921..4f61b4a170 100644 --- a/concepts/streams/introduction.md +++ b/concepts/streams/introduction.md @@ -1,3 +1,5 @@ +# Introduction + All functions in the `Enum` module are _eager_. When performing multiple operations on enumerables with the `Enum` module, each operation is going to generate an intermediate result. The `Stream` module is a _lazy_ alternative to the _eager_ `Enum` module. It offers many of the same functions as `Enum`, but instead of generating intermediate results, it builds a series of computations that are only executed once the stream is passed to a function from the `Enum` module. diff --git a/concepts/strings/about.md b/concepts/strings/about.md index 8db5902879..c09c99c641 100644 --- a/concepts/strings/about.md +++ b/concepts/strings/about.md @@ -1,3 +1,5 @@ +# About + [Strings][getting-started-strings] in Elixir are delimited by double quotes, and they are encoded in UTF-8: ```elixir diff --git a/concepts/strings/introduction.md b/concepts/strings/introduction.md index 7c22b91ede..c1876bdbbc 100644 --- a/concepts/strings/introduction.md +++ b/concepts/strings/introduction.md @@ -1,3 +1,5 @@ +# Introduction + Strings in Elixir are delimited by double quotes, and they are encoded in UTF-8: ```elixir diff --git a/concepts/structs/about.md b/concepts/structs/about.md index 22079607bf..70ecfe2205 100644 --- a/concepts/structs/about.md +++ b/concepts/structs/about.md @@ -1,3 +1,5 @@ +# About + [Structs][getting-started] are special [maps][maps] with a defined set of keys. - Structs provide compile-time checks and default values. diff --git a/concepts/structs/introduction.md b/concepts/structs/introduction.md index 996e0e28a7..df37b19722 100644 --- a/concepts/structs/introduction.md +++ b/concepts/structs/introduction.md @@ -1,3 +1,5 @@ +# Introduction + Structs are an extension built on top of maps which provide compile-time checks and default values. A struct is named after the module it is defined in. To define a struct use the `defstruct` construct. The construct usually immediately follows after the module definition. `defstruct` accepts either a list of atoms (for `nil` default values) or a keyword list (for specified default values). The fields without defaults must precede the fields with default values. ```elixir @@ -9,7 +11,7 @@ plane = %Plane{} # => %Plane{engine: nil, wings: 2} ``` -### Accessing fields and updating +## Accessing fields and updating Since structs are built on maps, we can use most map functions to get and manipulate values. The _Access Behaviour_ is **not** implemented for structs. It is recommended to use the _static access operator_ `.` to access struct fields instead. @@ -31,7 +33,7 @@ Since structs are built on maps, we can use most map functions to get and manipu # => %Plane{engine: nil, wings: 4} ``` -### Enforcing field value initialization +## Enforcing field value initialization We can use the `@enforce_keys` module attribute with a list of the field keys to ensure that the values are initialized when the struct is created. If a key is not listed, its value will be `nil` as seen in the above example. If an enforced key is not initialized, an error is raised. diff --git a/concepts/tail-call-recursion/about.md b/concepts/tail-call-recursion/about.md index 2655f9a6d6..98323b4bb1 100644 --- a/concepts/tail-call-recursion/about.md +++ b/concepts/tail-call-recursion/about.md @@ -1,3 +1,5 @@ +# About + A function is [tail-recursive][recursion-tc] if the _last_ thing executed by the function is a call to itself. Each time any function is called, a _stack frame_ with its local variables, arguments etc. is put on top of [the function call stack][call-stack]. When a function returns, the stack frame is removed from the stack. diff --git a/concepts/tail-call-recursion/introduction.md b/concepts/tail-call-recursion/introduction.md index 04d3a50225..ac105b333c 100644 --- a/concepts/tail-call-recursion/introduction.md +++ b/concepts/tail-call-recursion/introduction.md @@ -1,3 +1,5 @@ +# Introduction + When recursing through enumerables (lists, bitstrings, strings), there are often two concerns: - how much memory is required to store the trail of recursive function calls diff --git a/concepts/try-rescue-else-after/about.md b/concepts/try-rescue-else-after/about.md index 4dc7b690dd..dd44ba5385 100644 --- a/concepts/try-rescue-else-after/about.md +++ b/concepts/try-rescue-else-after/about.md @@ -1,3 +1,5 @@ +# About + The basic `try .. rescue` concept can be extended to support `else` and `after` clauses: - The `else` block: diff --git a/concepts/try-rescue-else-after/introduction.md b/concepts/try-rescue-else-after/introduction.md index d5db76cd6f..2e7009b2f7 100644 --- a/concepts/try-rescue-else-after/introduction.md +++ b/concepts/try-rescue-else-after/introduction.md @@ -1,3 +1,5 @@ +# Introduction + Using `try..rescue` is a powerful construct for catching errors when they occur. Rescuing errors allows functions to return defined values when it is necessary. The `try..rescue` construct also offers us two additional features we can make use of: - the `else` block: diff --git a/concepts/try-rescue/about.md b/concepts/try-rescue/about.md index fa1ea3c55c..611779a28b 100644 --- a/concepts/try-rescue/about.md +++ b/concepts/try-rescue/about.md @@ -1,3 +1,5 @@ +# About + [`try .. rescue`][docs-try] can be used to capture and evaluate [errors][errors] that are raised inside a block. For example: diff --git a/concepts/try-rescue/introduction.md b/concepts/try-rescue/introduction.md index 4cf689d026..1638b1dd22 100644 --- a/concepts/try-rescue/introduction.md +++ b/concepts/try-rescue/introduction.md @@ -1,3 +1,5 @@ +# Introduction + Elixir provides a construct for rescuing from errors using `try .. rescue` ```elixir diff --git a/concepts/tuples/about.md b/concepts/tuples/about.md index 78107dba0d..7f84565bf8 100644 --- a/concepts/tuples/about.md +++ b/concepts/tuples/about.md @@ -1,3 +1,5 @@ +# About + Tuples are used commonly to group information informally. A common pattern in Elixir is to group function return values with a status. ```elixir diff --git a/concepts/tuples/introduction.md b/concepts/tuples/introduction.md index 2738d84fba..f95aa2d33c 100644 --- a/concepts/tuples/introduction.md +++ b/concepts/tuples/introduction.md @@ -1,3 +1,5 @@ +# Introduction + In Elixir, a tuple is a data structure which organizes data, holding a fixed number of items of any type, but without explicit names for each element. Tuples are often used in Elixir for memory read-intensive operations, since read-access of an element is a constant-time operation. They are not usually used when elements may need to be added/removed dynamically because rather than modifying the existing tuple, a new tuple is created which requires memory to be allocated upfront. In practice, tuples are created in Elixir using curly braces. Elements in a tuple can be individually accessed using the `elem/1` function using 0-based indexing: @@ -11,7 +13,7 @@ elem(multiple_element_tuple, 2) # => "hello" ``` -### Tuples as grouped information +## Tuples as grouped information Tuples are often used in practice to represent grouped information. diff --git a/docs/ABOUT.md b/docs/ABOUT.md index c3096096e9..03f1caf592 100644 --- a/docs/ABOUT.md +++ b/docs/ABOUT.md @@ -1,3 +1,5 @@ +# About + [Elixir](http://elixir-lang.org/), initially released in 2012, extends upon the already robust features of Erlang while also being easier for beginners to access, read, test, and write. José Valim, the creator of Elixir, explains [here](https://vimeo.com/53221562) how he built the language for applications to be: diff --git a/docs/INSTALLATION.md b/docs/INSTALLATION.md index 1993724b8c..5765a588f8 100644 --- a/docs/INSTALLATION.md +++ b/docs/INSTALLATION.md @@ -1,4 +1,6 @@ -### Installation +# Installation + +## Installation Detailed installation instructions can be found at [http://elixir-lang.org/install.html](http://elixir-lang.org/install.html). diff --git a/docs/LEARNING.md b/docs/LEARNING.md index e5b961bbb9..bfbf12e53b 100644 --- a/docs/LEARNING.md +++ b/docs/LEARNING.md @@ -1,3 +1,5 @@ +# Learning + Exercism provides exercises and feedback but can be difficult to jump into for those learning Elixir for the first time. These resources can help you get started: diff --git a/docs/RESOURCES.md b/docs/RESOURCES.md index 8cd638101f..0a41058fa2 100644 --- a/docs/RESOURCES.md +++ b/docs/RESOURCES.md @@ -1,3 +1,5 @@ +# Resources + ## Elixir Documentation * [Elixir Docs](http://elixir-lang.org/docs.html) diff --git a/docs/TESTS.md b/docs/TESTS.md index c0ef2a3703..bb3a207c33 100644 --- a/docs/TESTS.md +++ b/docs/TESTS.md @@ -1,4 +1,4 @@ -## Running tests +# Running tests From the terminal, change to the base directory of the problem then execute the tests with: @@ -8,7 +8,7 @@ $ mix test This will execute the test file found in the `test` subfolder -- a file ending in `_test.exs` -### Pending tests +## Pending tests In the test suites, all but the first test have been skipped. @@ -31,7 +31,7 @@ Or, you can enable all the tests by commenting out the # ExUnit.configure exclude: :pending, trace: true ``` -### Typespecs and Dialyzer (DIscrepancy AnalYZer for ERlang programs) +## Typespecs and Dialyzer (DIscrepancy AnalYZer for ERlang programs) Elixir exercises include a skeleton implementation file in the `lib` subdirectory. This file outlines the module and functions that you are diff --git a/exercises/concept/basketball-website/.docs/hints.md b/exercises/concept/basketball-website/.docs/hints.md index 81a08af52c..2fe816065f 100644 --- a/exercises/concept/basketball-website/.docs/hints.md +++ b/exercises/concept/basketball-website/.docs/hints.md @@ -1,3 +1,5 @@ +# Hints + ## General - Read about the [`Access` behaviour][access-behaviour] in the documentation. diff --git a/exercises/concept/basketball-website/.docs/instructions.md b/exercises/concept/basketball-website/.docs/instructions.md index 6fb205b7db..44e91d0be6 100644 --- a/exercises/concept/basketball-website/.docs/instructions.md +++ b/exercises/concept/basketball-website/.docs/instructions.md @@ -1,3 +1,5 @@ +# Instructions + You are working with a web development team to maintain a website for a local basketball team. The web development team is less familiar with Elixir and is asking for a function to be able to extract data from a series of nested maps to facilitate rapid development. ## 1. Extract data from a nested map structure diff --git a/exercises/concept/basketball-website/.docs/introduction.md b/exercises/concept/basketball-website/.docs/introduction.md index eadfed0703..977bda16e0 100644 --- a/exercises/concept/basketball-website/.docs/introduction.md +++ b/exercises/concept/basketball-website/.docs/introduction.md @@ -1,4 +1,4 @@ -## Access Behaviour +# Access Behaviour Elixir uses code _Behaviours_ to provide common generic interfaces while facilitating specific implementations for each module which implements it. One such common example is the _Access Behaviour_. diff --git a/exercises/concept/basketball-website/.meta/design.md b/exercises/concept/basketball-website/.meta/design.md index 659a83a768..3191a7a6d2 100644 --- a/exercises/concept/basketball-website/.meta/design.md +++ b/exercises/concept/basketball-website/.meta/design.md @@ -1,3 +1,5 @@ +# Design + ## Learning objectives - Know of the access _behaviour_ (Note the UK spelling.) diff --git a/exercises/concept/bird-count/.docs/hints.md b/exercises/concept/bird-count/.docs/hints.md index bfe6e6fe17..7a7098e4d5 100644 --- a/exercises/concept/bird-count/.docs/hints.md +++ b/exercises/concept/bird-count/.docs/hints.md @@ -1,3 +1,5 @@ +# Hints + ## General - Read about recursion in the official [Getting Started guide][getting-started-recursion]. diff --git a/exercises/concept/bird-count/.docs/instructions.md b/exercises/concept/bird-count/.docs/instructions.md index 9ffd51ea99..9a4ae1aaac 100644 --- a/exercises/concept/bird-count/.docs/instructions.md +++ b/exercises/concept/bird-count/.docs/instructions.md @@ -1,3 +1,5 @@ +# Instructions + You're an avid bird watcher that keeps track of how many birds have visited your garden on any given day. You decided to bring your bird watching to a new level and implement a few tools that will help you track and process the data. diff --git a/exercises/concept/bird-count/.docs/introduction.md b/exercises/concept/bird-count/.docs/introduction.md index 610423b6df..de40eedfcb 100644 --- a/exercises/concept/bird-count/.docs/introduction.md +++ b/exercises/concept/bird-count/.docs/introduction.md @@ -1,4 +1,4 @@ -## Recursion +# Recursion Recursive functions are functions that call themselves. diff --git a/exercises/concept/bird-count/.meta/design.md b/exercises/concept/bird-count/.meta/design.md index 1f26419b01..70f861a98c 100644 --- a/exercises/concept/bird-count/.meta/design.md +++ b/exercises/concept/bird-count/.meta/design.md @@ -1,3 +1,5 @@ +# Design + ## Learning objectives - Know how write a recursive function. diff --git a/exercises/concept/boutique-inventory/.docs/hints.md b/exercises/concept/boutique-inventory/.docs/hints.md index 64cb97efa4..ed21d73ea5 100644 --- a/exercises/concept/boutique-inventory/.docs/hints.md +++ b/exercises/concept/boutique-inventory/.docs/hints.md @@ -1,3 +1,5 @@ +# Hints + ## General - Read about the `Enum` module in the [official Getting Started guide][getting-started-enum] or on [elixirschool.com][elixir-school-enum]. diff --git a/exercises/concept/boutique-inventory/.docs/instructions.md b/exercises/concept/boutique-inventory/.docs/instructions.md index ca0fc83313..3eaa9d52d7 100644 --- a/exercises/concept/boutique-inventory/.docs/instructions.md +++ b/exercises/concept/boutique-inventory/.docs/instructions.md @@ -1,3 +1,5 @@ +# Instructions + You are running an online fashion boutique. Your big annual sale is coming up, so you need to take stock of your inventory to make sure you're ready. A single item in the inventory is represented by a map, and the whole inventory is a list of such maps. diff --git a/exercises/concept/boutique-inventory/.docs/introduction.md b/exercises/concept/boutique-inventory/.docs/introduction.md index b5cf610da6..68ba302264 100644 --- a/exercises/concept/boutique-inventory/.docs/introduction.md +++ b/exercises/concept/boutique-inventory/.docs/introduction.md @@ -1,4 +1,4 @@ -## Enum +# Enum `Enum` is a very useful module that provides a set of algorithms for working with enumerables. It offers sorting, filtering, grouping, counting, searching, finding min/max values, and much more. diff --git a/exercises/concept/boutique-inventory/.meta/design.md b/exercises/concept/boutique-inventory/.meta/design.md index b2ef512f83..1cf1f28e89 100644 --- a/exercises/concept/boutique-inventory/.meta/design.md +++ b/exercises/concept/boutique-inventory/.meta/design.md @@ -1,3 +1,5 @@ +# Design + ## Learning objectives - Know about the `Enum` module. diff --git a/exercises/concept/boutique-suggestions/.docs/hints.md b/exercises/concept/boutique-suggestions/.docs/hints.md index 6c30d9fe07..832be5ec3c 100644 --- a/exercises/concept/boutique-suggestions/.docs/hints.md +++ b/exercises/concept/boutique-suggestions/.docs/hints.md @@ -1,3 +1,5 @@ +# Hints + ## General - Read about [comprehensions][elixir-comprehensions] in the Getting Started guide. diff --git a/exercises/concept/boutique-suggestions/.docs/instructions.md b/exercises/concept/boutique-suggestions/.docs/instructions.md index 58aea852d4..a443d28f59 100644 --- a/exercises/concept/boutique-suggestions/.docs/instructions.md +++ b/exercises/concept/boutique-suggestions/.docs/instructions.md @@ -1,3 +1,5 @@ +# Instructions + Your work at the online fashion boutique store continues. You come up with the idea for a website feature where an outfit is suggested to the user. While you want to give lots of suggestions, you don't want to give bad suggestions, so you decide to use a list comprehension since you can easily _generate_ outfit combinations, then _filter_ them by some criteria. Clothing items are stored as a map: diff --git a/exercises/concept/boutique-suggestions/.docs/introduction.md b/exercises/concept/boutique-suggestions/.docs/introduction.md index 6614086de8..315eff0fd3 100644 --- a/exercises/concept/boutique-suggestions/.docs/introduction.md +++ b/exercises/concept/boutique-suggestions/.docs/introduction.md @@ -1,4 +1,4 @@ -## List Comprehensions +# List Comprehensions Comprehensions provide a facility for transforming _Enumerables_ easily and declaratively. diff --git a/exercises/concept/boutique-suggestions/.meta/design.md b/exercises/concept/boutique-suggestions/.meta/design.md index 5d506cd9ec..64040d3061 100644 --- a/exercises/concept/boutique-suggestions/.meta/design.md +++ b/exercises/concept/boutique-suggestions/.meta/design.md @@ -1,3 +1,5 @@ +# Design + ## Learning objectives - Know what a _comprehension_ is diff --git a/exercises/concept/bread-and-potions/.docs/hints.md b/exercises/concept/bread-and-potions/.docs/hints.md index 929cf4435f..df664eb059 100644 --- a/exercises/concept/bread-and-potions/.docs/hints.md +++ b/exercises/concept/bread-and-potions/.docs/hints.md @@ -1,3 +1,5 @@ +# Hints + ## General - Read about protocols in the [official Getting Started guide][getting-started-protocols] or on [elixirschool.com][elixir-school-enum]. diff --git a/exercises/concept/bread-and-potions/.docs/instructions.md b/exercises/concept/bread-and-potions/.docs/instructions.md index 489af29430..5b2edc0741 100644 --- a/exercises/concept/bread-and-potions/.docs/instructions.md +++ b/exercises/concept/bread-and-potions/.docs/instructions.md @@ -1,3 +1,5 @@ +# Instructions + You're developing your own role-playing video game. In your game, there are _characters_ and _items_. One of the many actions that you can do with an item is to make a character eat it. Not all items are edible, and not all edible items have the same effects on the character. Some items, when eaten, turn into a different item (e.g. if you eat an apple, you are left with an apple core). diff --git a/exercises/concept/bread-and-potions/.docs/introduction.md b/exercises/concept/bread-and-potions/.docs/introduction.md index 6eb544dcc9..be7df42d25 100644 --- a/exercises/concept/bread-and-potions/.docs/introduction.md +++ b/exercises/concept/bread-and-potions/.docs/introduction.md @@ -1,4 +1,4 @@ -## Protocols +# Protocols Protocols are a mechanism to achieve polymorphism in Elixir when you want behavior to vary depending on the data type. diff --git a/exercises/concept/bread-and-potions/.meta/design.md b/exercises/concept/bread-and-potions/.meta/design.md index c9ce3e9c5e..4890b829f2 100644 --- a/exercises/concept/bread-and-potions/.meta/design.md +++ b/exercises/concept/bread-and-potions/.meta/design.md @@ -1,3 +1,5 @@ +# Design + ## Learning objectives - Know how to write a protocol. diff --git a/exercises/concept/captains-log/.docs/hints.md b/exercises/concept/captains-log/.docs/hints.md index 6c4457cc47..8032a20d51 100644 --- a/exercises/concept/captains-log/.docs/hints.md +++ b/exercises/concept/captains-log/.docs/hints.md @@ -1,3 +1,5 @@ +# Hints + ## General - Read about using Erlang libraries in the [official Getting Started guide][getting-started-erlang-libraries], and in particular about [formatting strings][getting-started-formatted-text-output]. diff --git a/exercises/concept/captains-log/.docs/instructions.md b/exercises/concept/captains-log/.docs/instructions.md index 0708b6ce1b..9c090216aa 100644 --- a/exercises/concept/captains-log/.docs/instructions.md +++ b/exercises/concept/captains-log/.docs/instructions.md @@ -1,3 +1,5 @@ +# Instructions + Mary is a big fan of the TV series _Star Trek: The Next Generation_. She often plays pen-and-paper role playing games, where she and her friends pretend to be the crew of the _Starship Enterprise_. Mary's character is Captain Picard, which means she has to keep the captain's log. She loves the creative part of the game, but doesn't like to generate random data on the spot. Help Mary by creating random generators for data commonly appearing in the captain's log. diff --git a/exercises/concept/captains-log/.docs/introduction.md b/exercises/concept/captains-log/.docs/introduction.md index 46f61c40b5..bf2522704f 100644 --- a/exercises/concept/captains-log/.docs/introduction.md +++ b/exercises/concept/captains-log/.docs/introduction.md @@ -1,3 +1,5 @@ +# Introduction + ## Randomness In Elixir, to choose a random element from an enumerable data structure (e.g. list, range), we use `Enum.random`. This function will pick a single element, with every element having equal probability of being picked. diff --git a/exercises/concept/captains-log/.meta/design.md b/exercises/concept/captains-log/.meta/design.md index b1597de1ef..85eea61745 100644 --- a/exercises/concept/captains-log/.meta/design.md +++ b/exercises/concept/captains-log/.meta/design.md @@ -1,3 +1,5 @@ +# Design + ## Learning objectives - Know how to call an Erlang function diff --git a/exercises/concept/chessboard/.docs/hints.md b/exercises/concept/chessboard/.docs/hints.md index afc7e659a9..60787f4b17 100644 --- a/exercises/concept/chessboard/.docs/hints.md +++ b/exercises/concept/chessboard/.docs/hints.md @@ -1,3 +1,5 @@ +# Hints + ## General - Read the official documentation for [ranges][range]. diff --git a/exercises/concept/chessboard/.docs/instructions.md b/exercises/concept/chessboard/.docs/instructions.md index b1813a52be..9630e2cc9d 100644 --- a/exercises/concept/chessboard/.docs/instructions.md +++ b/exercises/concept/chessboard/.docs/instructions.md @@ -1,3 +1,5 @@ +# Instructions + As a chess enthusiast, you would like to write your own version of the game. Yes, there maybe plenty of implementations of chess available online already, but yours will be unique! But before you can let your imagination run wild, you need to take care of the basics. Let's start by generating the board. diff --git a/exercises/concept/chessboard/.docs/introduction.md b/exercises/concept/chessboard/.docs/introduction.md index e676f91885..1d2e73ee10 100644 --- a/exercises/concept/chessboard/.docs/introduction.md +++ b/exercises/concept/chessboard/.docs/introduction.md @@ -1,4 +1,4 @@ -## Ranges +# Ranges Ranges represent a sequence of one or many consecutive integers. They are created by connecting two integers with `..`. diff --git a/exercises/concept/chessboard/.meta/design.md b/exercises/concept/chessboard/.meta/design.md index d488ebb590..593b3011bf 100644 --- a/exercises/concept/chessboard/.meta/design.md +++ b/exercises/concept/chessboard/.meta/design.md @@ -1,3 +1,5 @@ +# Design + ## Learning objectives - Know about ranges. diff --git a/exercises/concept/community-garden/.docs/hints.md b/exercises/concept/community-garden/.docs/hints.md index caaa4a2d79..57f8a800c4 100644 --- a/exercises/concept/community-garden/.docs/hints.md +++ b/exercises/concept/community-garden/.docs/hints.md @@ -1,3 +1,5 @@ +# Hints + ## General - Read about the [`Agent` module][getting-started-agent] in the Getting Started guide. diff --git a/exercises/concept/community-garden/.docs/instructions.md b/exercises/concept/community-garden/.docs/instructions.md index 65cd417403..2304b249e6 100644 --- a/exercises/concept/community-garden/.docs/instructions.md +++ b/exercises/concept/community-garden/.docs/instructions.md @@ -1,3 +1,5 @@ +# Instructions + Your community association has asked you to implement a simple registry application to manage the community garden registrations. The `Plot` struct has already been provided for you. ## 1. Open the garden diff --git a/exercises/concept/community-garden/.docs/introduction.md b/exercises/concept/community-garden/.docs/introduction.md index f0bfae7aab..be857e21e9 100644 --- a/exercises/concept/community-garden/.docs/introduction.md +++ b/exercises/concept/community-garden/.docs/introduction.md @@ -1,4 +1,4 @@ -## Agent +# Agent The `Agent` module facilitates an abstraction for spawning processes and the _receive-send_ loop. From here, we will call processes started using the `Agent` module _'agent processes'_. An _agent process_ might be chosen to represent a central shared state. diff --git a/exercises/concept/community-garden/.meta/design.md b/exercises/concept/community-garden/.meta/design.md index 89b299c087..1807430c18 100644 --- a/exercises/concept/community-garden/.meta/design.md +++ b/exercises/concept/community-garden/.meta/design.md @@ -1,3 +1,5 @@ +# Design + ## Learning objectives - Review processes, send receive as a _raw_ form of an Agent diff --git a/exercises/concept/date-parser/.docs/hints.md b/exercises/concept/date-parser/.docs/hints.md index 99468e172f..88a52c405a 100644 --- a/exercises/concept/date-parser/.docs/hints.md +++ b/exercises/concept/date-parser/.docs/hints.md @@ -1,3 +1,5 @@ +# Hints + ## General - Review regular expression patterns from the introduction. Remember, when creating the pattern a string, you must escape some characters. diff --git a/exercises/concept/date-parser/.docs/instructions.md b/exercises/concept/date-parser/.docs/instructions.md index 6c46862104..d421e9b8fa 100644 --- a/exercises/concept/date-parser/.docs/instructions.md +++ b/exercises/concept/date-parser/.docs/instructions.md @@ -1,3 +1,5 @@ +# Instructions + You have been tasked to write a service which ingests events. Each event has a date associated with it, but you notice that 3 different formats are being submitted to your service's endpoint: - `"01/01/1970"` diff --git a/exercises/concept/date-parser/.docs/introduction.md b/exercises/concept/date-parser/.docs/introduction.md index 3177f616f4..a6d3762fcd 100644 --- a/exercises/concept/date-parser/.docs/introduction.md +++ b/exercises/concept/date-parser/.docs/introduction.md @@ -1,4 +1,4 @@ -## Regular Expressions +# Regular Expressions Regular expressions (regex) are a powerful tool for working with strings in Elixir. Regular expressions in Elixir follow the **PCRE** specification (**P**erl **C**ompatible **R**egular **E**xpressions). String patterns representing the regular expression's meaning are first compiled then used for matching all or part of a string. diff --git a/exercises/concept/date-parser/.meta/design.md b/exercises/concept/date-parser/.meta/design.md index fee94bdf8e..ebe59060c8 100644 --- a/exercises/concept/date-parser/.meta/design.md +++ b/exercises/concept/date-parser/.meta/design.md @@ -1,3 +1,5 @@ +# Design + ## Learning objectives - Learn basic regular expression patterns diff --git a/exercises/concept/dna-encoding/.docs/hints.md b/exercises/concept/dna-encoding/.docs/hints.md index 9289952dbf..d8320d0746 100644 --- a/exercises/concept/dna-encoding/.docs/hints.md +++ b/exercises/concept/dna-encoding/.docs/hints.md @@ -1,3 +1,5 @@ +# Hints + ## General - Use `?` to work with the character [code points][codepoint]. diff --git a/exercises/concept/dna-encoding/.docs/instructions.md b/exercises/concept/dna-encoding/.docs/instructions.md index 3aa699af1f..233c3f748c 100644 --- a/exercises/concept/dna-encoding/.docs/instructions.md +++ b/exercises/concept/dna-encoding/.docs/instructions.md @@ -1,3 +1,5 @@ +# Instructions + In your DNA research lab, you have been working through various ways to compress your research data to save storage space. One teammate suggests converting the DNA data to a binary representation: | Nucleic Acid | Code | diff --git a/exercises/concept/dna-encoding/.docs/introduction.md b/exercises/concept/dna-encoding/.docs/introduction.md index fca07c451a..af0448e538 100644 --- a/exercises/concept/dna-encoding/.docs/introduction.md +++ b/exercises/concept/dna-encoding/.docs/introduction.md @@ -1,3 +1,5 @@ +# Introduction + ## Bitstrings Working with binary data is an important concept in any language, and Elixir provides an elegant syntax to write, match, and construct binary data. diff --git a/exercises/concept/dna-encoding/.meta/design.md b/exercises/concept/dna-encoding/.meta/design.md index fea13104e3..c0904ce0cd 100644 --- a/exercises/concept/dna-encoding/.meta/design.md +++ b/exercises/concept/dna-encoding/.meta/design.md @@ -1,3 +1,5 @@ +# Design + ## Learning objectives - Know what a bitstring is diff --git a/exercises/concept/file-sniffer/.docs/hints.md b/exercises/concept/file-sniffer/.docs/hints.md index 57547167af..032ca33eb1 100644 --- a/exercises/concept/file-sniffer/.docs/hints.md +++ b/exercises/concept/file-sniffer/.docs/hints.md @@ -1,3 +1,5 @@ +# Hints + ## General - Remember to reference the table in the instructions. diff --git a/exercises/concept/file-sniffer/.docs/instructions.md b/exercises/concept/file-sniffer/.docs/instructions.md index e49880f8ca..59d8746a73 100644 --- a/exercises/concept/file-sniffer/.docs/instructions.md +++ b/exercises/concept/file-sniffer/.docs/instructions.md @@ -1,3 +1,5 @@ +# Instructions + You have been working on a project which allows users to upload files to the server to be shared with other users. You have been tasked with writing a function to verify that an upload matches its [media type][mimetype]. You do some research and discover that the first few bytes of a file are generally unique to that filetype, giving it a sort of signature. Use the following table for reference: diff --git a/exercises/concept/file-sniffer/.docs/introduction.md b/exercises/concept/file-sniffer/.docs/introduction.md index 02af50f699..188c003d2f 100644 --- a/exercises/concept/file-sniffer/.docs/introduction.md +++ b/exercises/concept/file-sniffer/.docs/introduction.md @@ -1,4 +1,4 @@ -## Binaries +# Binaries Elixir provides an elegant syntax for working with binary data as we have seen with the `<<>>` special form provided for working with _bitstrings_. @@ -14,7 +14,7 @@ Binary literals are defined using the bitstring special form `<<>>`. When defini A _null-byte_ is another name for `<<0>>`. -### Pattern matching on binary data +## Pattern matching on binary data Pattern matching is even extended to binaries, and we can pattern match on a portion of binary data much like we could for a list. diff --git a/exercises/concept/file-sniffer/.meta/design.md b/exercises/concept/file-sniffer/.meta/design.md index 437af32a87..e44ae63376 100644 --- a/exercises/concept/file-sniffer/.meta/design.md +++ b/exercises/concept/file-sniffer/.meta/design.md @@ -1,3 +1,5 @@ +# Design + ## Learning objectives After completing this exercise, the student should: diff --git a/exercises/concept/freelancer-rates/.docs/hints.md b/exercises/concept/freelancer-rates/.docs/hints.md index 7106b9f1ad..71d790c64a 100644 --- a/exercises/concept/freelancer-rates/.docs/hints.md +++ b/exercises/concept/freelancer-rates/.docs/hints.md @@ -1,3 +1,5 @@ +# Hints + ## General - Read about basic arithmetic in the official [Getting Started guide][getting-started-basic-arithmetic]. diff --git a/exercises/concept/freelancer-rates/.docs/instructions.md b/exercises/concept/freelancer-rates/.docs/instructions.md index c7d02fee32..719236a708 100644 --- a/exercises/concept/freelancer-rates/.docs/instructions.md +++ b/exercises/concept/freelancer-rates/.docs/instructions.md @@ -1,3 +1,5 @@ +# Instructions + In this exercise you'll be writing code to help a freelancer communicate with a project manager by providing a few utilities to quickly calculate daily and monthly rates, optionally with a given discount. diff --git a/exercises/concept/freelancer-rates/.docs/introduction.md b/exercises/concept/freelancer-rates/.docs/introduction.md index accc209581..814fa45919 100644 --- a/exercises/concept/freelancer-rates/.docs/introduction.md +++ b/exercises/concept/freelancer-rates/.docs/introduction.md @@ -1,3 +1,5 @@ +# Introduction + ## Integers There are two different kinds of numbers in Elixir - integers and floats. diff --git a/exercises/concept/freelancer-rates/.meta/design.md b/exercises/concept/freelancer-rates/.meta/design.md index a793400291..5bd9a5f221 100644 --- a/exercises/concept/freelancer-rates/.meta/design.md +++ b/exercises/concept/freelancer-rates/.meta/design.md @@ -1,3 +1,5 @@ +# Design + ## Learning objectives - Know how to write floating point literals. diff --git a/exercises/concept/german-sysadmin/.docs/hints.md b/exercises/concept/german-sysadmin/.docs/hints.md index bdd29bb034..f71bea1d61 100644 --- a/exercises/concept/german-sysadmin/.docs/hints.md +++ b/exercises/concept/german-sysadmin/.docs/hints.md @@ -1,3 +1,5 @@ +# Hints + ## General - Read about [charlists][getting-started-charlists], [Unicode and code points][getting-started-code-points], and [`case`][getting-started-case] in the official Getting Started guide. diff --git a/exercises/concept/german-sysadmin/.docs/instructions.md b/exercises/concept/german-sysadmin/.docs/instructions.md index bd78c14d3c..11a7403212 100644 --- a/exercises/concept/german-sysadmin/.docs/instructions.md +++ b/exercises/concept/german-sysadmin/.docs/instructions.md @@ -1,3 +1,5 @@ +# Instructions + You are working as a system administrator for a big company in Münich, Germany. One of your responsibilities is managing email accounts. You have been hearing complaints from people saying they are unable to write emails to Mr. Müller. You quickly realize that most of the company uses an old email client that doesn't recognize `müller@firma.de` as a valid email address because of the non-latin character. diff --git a/exercises/concept/german-sysadmin/.docs/introduction.md b/exercises/concept/german-sysadmin/.docs/introduction.md index 6f705f0e3a..0945d60eb9 100644 --- a/exercises/concept/german-sysadmin/.docs/introduction.md +++ b/exercises/concept/german-sysadmin/.docs/introduction.md @@ -1,3 +1,5 @@ +# Introduction + ## Charlists Charlists are created using single quotes. diff --git a/exercises/concept/german-sysadmin/.meta/design.md b/exercises/concept/german-sysadmin/.meta/design.md index bc0273c9e4..0ca9bbaf31 100644 --- a/exercises/concept/german-sysadmin/.meta/design.md +++ b/exercises/concept/german-sysadmin/.meta/design.md @@ -1,3 +1,5 @@ +# Design + ## Learning objectives After completing this exercise, the student should: diff --git a/exercises/concept/guessing-game/.docs/hints.md b/exercises/concept/guessing-game/.docs/hints.md index 619a30349a..f92f6aef9a 100644 --- a/exercises/concept/guessing-game/.docs/hints.md +++ b/exercises/concept/guessing-game/.docs/hints.md @@ -1,3 +1,5 @@ +# Hints + ## General - In Elixir's ['Getting Started Guide'][guide] there is a nice refresher about named functions. diff --git a/exercises/concept/guessing-game/.docs/instructions.md b/exercises/concept/guessing-game/.docs/instructions.md index f12b04b326..bb37dae9fb 100644 --- a/exercises/concept/guessing-game/.docs/instructions.md +++ b/exercises/concept/guessing-game/.docs/instructions.md @@ -1,3 +1,5 @@ +# Instructions + You are creating a trivial online game where a friend can guess a secret number. You want to give some feedback, but not give away the answer with a guess. You need to devise a function to provide different responses depending on how the guess relates to the secret number. | Condition | Response | diff --git a/exercises/concept/guessing-game/.docs/introduction.md b/exercises/concept/guessing-game/.docs/introduction.md index 9f9ca41959..2008d4e01d 100644 --- a/exercises/concept/guessing-game/.docs/introduction.md +++ b/exercises/concept/guessing-game/.docs/introduction.md @@ -1,3 +1,5 @@ +# Introduction + ## Multiple Clause Functions Elixir facilitates **Open-Close Principle** practices by allowing functions to have multiple clauses, so instead of sprawling and hard-coded control-logic, pointed functions can be written to add/remove behavior easily. diff --git a/exercises/concept/guessing-game/.meta/design.md b/exercises/concept/guessing-game/.meta/design.md index a5995a26aa..0ec88e851e 100644 --- a/exercises/concept/guessing-game/.meta/design.md +++ b/exercises/concept/guessing-game/.meta/design.md @@ -1,3 +1,5 @@ +# Design + ## Learning objectives A student upon completion will: diff --git a/exercises/concept/high-school-sweetheart/.docs/hints.md b/exercises/concept/high-school-sweetheart/.docs/hints.md index ef8045c275..b52dab7191 100644 --- a/exercises/concept/high-school-sweetheart/.docs/hints.md +++ b/exercises/concept/high-school-sweetheart/.docs/hints.md @@ -1,3 +1,5 @@ +# Hints + ## General - Read about strings in the official [Getting Started guide][getting-started-strings]. diff --git a/exercises/concept/high-school-sweetheart/.docs/instructions.md b/exercises/concept/high-school-sweetheart/.docs/instructions.md index 230c328c2c..23a4b11bbb 100644 --- a/exercises/concept/high-school-sweetheart/.docs/instructions.md +++ b/exercises/concept/high-school-sweetheart/.docs/instructions.md @@ -1,3 +1,5 @@ +# Instructions + In this exercise, you are going to help high school sweethearts profess their love on social media by generating an ASCII heart with their initials: ``` diff --git a/exercises/concept/high-school-sweetheart/.docs/introduction.md b/exercises/concept/high-school-sweetheart/.docs/introduction.md index b7be79ca07..2a8ad81c73 100644 --- a/exercises/concept/high-school-sweetheart/.docs/introduction.md +++ b/exercises/concept/high-school-sweetheart/.docs/introduction.md @@ -1,4 +1,4 @@ -## Strings +# Strings Strings in Elixir are delimited by double quotes, and they are encoded in UTF-8: diff --git a/exercises/concept/high-school-sweetheart/.meta/design.md b/exercises/concept/high-school-sweetheart/.meta/design.md index c2c97bed49..04bc3220c6 100644 --- a/exercises/concept/high-school-sweetheart/.meta/design.md +++ b/exercises/concept/high-school-sweetheart/.meta/design.md @@ -1,3 +1,5 @@ +# Design + ## Learning objectives After completing this exercise, the student should: diff --git a/exercises/concept/high-score/.docs/hints.md b/exercises/concept/high-score/.docs/hints.md index e48a268d60..e794533883 100644 --- a/exercises/concept/high-score/.docs/hints.md +++ b/exercises/concept/high-score/.docs/hints.md @@ -1,3 +1,5 @@ +# Hints + ## General - A [map][maps] is an associative data structure of key-value pairs. diff --git a/exercises/concept/high-score/.docs/instructions.md b/exercises/concept/high-score/.docs/instructions.md index 94c47ee309..07f0a6d4e4 100644 --- a/exercises/concept/high-score/.docs/instructions.md +++ b/exercises/concept/high-score/.docs/instructions.md @@ -1,3 +1,5 @@ +# Instructions + In this exercise, you're implementing a way to keep track of the high scores for the most popular game in your local arcade hall. ## 1. Define a new high score map diff --git a/exercises/concept/high-score/.docs/introduction.md b/exercises/concept/high-score/.docs/introduction.md index 45a17fe7c5..58694a1de7 100644 --- a/exercises/concept/high-score/.docs/introduction.md +++ b/exercises/concept/high-score/.docs/introduction.md @@ -1,3 +1,5 @@ +# Introduction + ## Maps Maps in Elixir are the data structure for storing information in key-value pairs. In other languages, these might also be known as associative arrays (PHP), hashes (Perl 5, Raku), or dictionaries (Python). diff --git a/exercises/concept/high-score/.meta/design.md b/exercises/concept/high-score/.meta/design.md index 0cb4c0eae5..8de03ba961 100644 --- a/exercises/concept/high-score/.meta/design.md +++ b/exercises/concept/high-score/.meta/design.md @@ -1,3 +1,5 @@ +# Design + ## Learning objectives - Know what a map is. diff --git a/exercises/concept/kitchen-calculator/.docs/hints.md b/exercises/concept/kitchen-calculator/.docs/hints.md index 2a5de138f7..ce9610ddad 100644 --- a/exercises/concept/kitchen-calculator/.docs/hints.md +++ b/exercises/concept/kitchen-calculator/.docs/hints.md @@ -1,3 +1,5 @@ +# Hints + ## General - [Tuples][tuple-module] are data structures which are arranged in contiguous memory and can hold any data-type. diff --git a/exercises/concept/kitchen-calculator/.docs/instructions.md b/exercises/concept/kitchen-calculator/.docs/instructions.md index 757af97672..4a683af0cd 100644 --- a/exercises/concept/kitchen-calculator/.docs/instructions.md +++ b/exercises/concept/kitchen-calculator/.docs/instructions.md @@ -1,3 +1,5 @@ +# Instructions + While preparing to bake cookies for your friends, you have found that you have to convert some of the ingredients used in the recipe for your friends. Being only familiar with the metric system, you need to come up with a way to convert common US baking measurements to milliliters (mL) for your own ease. Use this conversion chart for your solution: diff --git a/exercises/concept/kitchen-calculator/.docs/introduction.md b/exercises/concept/kitchen-calculator/.docs/introduction.md index edfc7c9f42..648e94c562 100644 --- a/exercises/concept/kitchen-calculator/.docs/introduction.md +++ b/exercises/concept/kitchen-calculator/.docs/introduction.md @@ -1,3 +1,5 @@ +# Introduction + ## Tuples In Elixir, a tuple is a data structure which organizes data, holding a fixed number of items of any type, but without explicit names for each element. Tuples are often used in Elixir for memory read-intensive operations, since read-access of an element is a constant-time operation. They are not usually used when elements may need to be added/removed dynamically because rather than modifying the existing tuple, a new tuple is created which requires memory to be allocated upfront. diff --git a/exercises/concept/kitchen-calculator/.meta/design.md b/exercises/concept/kitchen-calculator/.meta/design.md index 2d4da68a61..1762d775f3 100644 --- a/exercises/concept/kitchen-calculator/.meta/design.md +++ b/exercises/concept/kitchen-calculator/.meta/design.md @@ -1,3 +1,5 @@ +# Design + ## Learning objectives - Know what a tuple is diff --git a/exercises/concept/language-list/.docs/hints.md b/exercises/concept/language-list/.docs/hints.md index 127cef16c0..b225b3b854 100644 --- a/exercises/concept/language-list/.docs/hints.md +++ b/exercises/concept/language-list/.docs/hints.md @@ -1,3 +1,5 @@ +# Hints + ## General - Use the built-in [(linked) list type][list]. diff --git a/exercises/concept/language-list/.docs/instructions.md b/exercises/concept/language-list/.docs/instructions.md index f0718a7d18..8d345d9a91 100644 --- a/exercises/concept/language-list/.docs/instructions.md +++ b/exercises/concept/language-list/.docs/instructions.md @@ -1,3 +1,5 @@ +# Instructions + In this exercise you need to implement some functions to manipulate a list of programming languages. ## 1. Define a function to return an empty language list diff --git a/exercises/concept/language-list/.docs/introduction.md b/exercises/concept/language-list/.docs/introduction.md index 73926ae187..8750989653 100644 --- a/exercises/concept/language-list/.docs/introduction.md +++ b/exercises/concept/language-list/.docs/introduction.md @@ -1,4 +1,4 @@ -## Lists +# Lists Lists are built-in to the Elixir language. They are considered a basic type, denoted by square brackets. Lists may be empty or hold any number of items of any type. For example: diff --git a/exercises/concept/language-list/.meta/design.md b/exercises/concept/language-list/.meta/design.md index 816c8d1df6..f803c70241 100644 --- a/exercises/concept/language-list/.meta/design.md +++ b/exercises/concept/language-list/.meta/design.md @@ -1,3 +1,5 @@ +# Design + ## Learning objectives - Know of the existence of the `list` type. diff --git a/exercises/concept/lasagna/.docs/hints.md b/exercises/concept/lasagna/.docs/hints.md index 27691377c1..597005c738 100644 --- a/exercises/concept/lasagna/.docs/hints.md +++ b/exercises/concept/lasagna/.docs/hints.md @@ -1,3 +1,5 @@ +# Hints + ## General - An [integer value][integers] can be defined as one or more consecutive digits. diff --git a/exercises/concept/lasagna/.docs/instructions.md b/exercises/concept/lasagna/.docs/instructions.md index d89da2174e..35bde1971e 100644 --- a/exercises/concept/lasagna/.docs/instructions.md +++ b/exercises/concept/lasagna/.docs/instructions.md @@ -1,3 +1,5 @@ +# Instructions + In this exercise you're going to write some code to help you cook a brilliant lasagna from your favorite cooking book. You have five tasks, all related to the time spent cooking the lasagna. diff --git a/exercises/concept/lasagna/.docs/introduction.md b/exercises/concept/lasagna/.docs/introduction.md index a9624f19af..d0897a8aec 100644 --- a/exercises/concept/lasagna/.docs/introduction.md +++ b/exercises/concept/lasagna/.docs/introduction.md @@ -1,4 +1,4 @@ -## Basics +# Basics Elixir is a dynamically-typed language, meaning that the type of a variable is only checked at runtime. Using the match `=` operator, we can bind a value of any type to a variable name: @@ -11,7 +11,7 @@ count = false # You may re-bind any type to a variable message = "Success!" # Strings can be created by enclosing characters within double quotes ``` -### Modules +## Modules Elixir is an [functional-programming language][functional-programming] and requires all named functions to be defined in a _module_. The `defmodule` keyword is used to define a module. All modules are available to all other modules at runtime and do not require an _access modifier_ to make them visible to other parts of the program. A _module_ is analogous to a _class_ in other programming languages. @@ -21,7 +21,7 @@ defmodule Calculator do end ``` -### Named functions +## Named functions _Named Functions_ must be defined in a module. Each function can have zero or more arguments. All arguments are dynamically-typed, and the return type is not explicitly declared, it is the type of the value returned. An _access modifier_ can be specified for functions, making only desired functions available for use external to the module. In a function, the value of the last line is _implicitly returned_ to the calling function. @@ -44,7 +44,7 @@ sum = Calculator.short_add(2, 2) # => 4 ``` -### Arity of functions +## Arity of functions It is common to refer to functions with their _arity_. The _arity_ of a function is the number of arguments it accepts. @@ -55,7 +55,7 @@ def add(x, y, z) do end ``` -### Standard library +## Standard library Elixir has a very rich and well-documented standard library. The documentation is available online at [hexdocs.pm/elixir][docs]. Save this link somewhere - you will use it a lot! @@ -63,7 +63,7 @@ Most built-in data types have a corresponding module that offers functions for w A notable module is the `Kernel` module. It provides the basic capabilities on top of which the rest of the standard library is built, like arithmetic operators, control-flow macros, and much more. Functions for the `Kernel` module are automatically imported, so you can use them without the `Kernel.` prefix. -### Documentation +## Documentation Documentation is a priority in high-quality Elixir code bases, and there are 3 ways to write inline documentation: diff --git a/exercises/concept/lasagna/.meta/design.md b/exercises/concept/lasagna/.meta/design.md index 68ad090e8f..ec34e62665 100644 --- a/exercises/concept/lasagna/.meta/design.md +++ b/exercises/concept/lasagna/.meta/design.md @@ -1,3 +1,5 @@ +# Design + ## Learning objectives - Know what a variable is. diff --git a/exercises/concept/log-level/.docs/hints.md b/exercises/concept/log-level/.docs/hints.md index c60874010e..0bea2bf9ff 100644 --- a/exercises/concept/log-level/.docs/hints.md +++ b/exercises/concept/log-level/.docs/hints.md @@ -1,3 +1,5 @@ +# Hints + ## General - The [atom type is described here][atom]. diff --git a/exercises/concept/log-level/.docs/instructions.md b/exercises/concept/log-level/.docs/instructions.md index 4d15c5ffb5..e86d3ef235 100644 --- a/exercises/concept/log-level/.docs/instructions.md +++ b/exercises/concept/log-level/.docs/instructions.md @@ -1,3 +1,5 @@ +# Instructions + You are running a system that consist of a few applications producing many logs. You want to write a small program that will aggregate those logs and give them labels according to their severity level. All applications in your system use the same log codes, but some of the legacy applications don't support all the codes. | Log code | Log label | Supported in legacy apps? | diff --git a/exercises/concept/log-level/.docs/introduction.md b/exercises/concept/log-level/.docs/introduction.md index 63bf96c508..1f4b3e59dd 100644 --- a/exercises/concept/log-level/.docs/introduction.md +++ b/exercises/concept/log-level/.docs/introduction.md @@ -1,3 +1,5 @@ +# Introduction + ## Atoms Elixir's `atom` type represents a fixed constant. An atom's value is simply its own name. This gives us a type-safe way to interact with data. Atoms can be defined as follows: diff --git a/exercises/concept/log-level/.meta/design.md b/exercises/concept/log-level/.meta/design.md index 5aba6f87f9..72cd865fe5 100644 --- a/exercises/concept/log-level/.meta/design.md +++ b/exercises/concept/log-level/.meta/design.md @@ -1,3 +1,5 @@ +# Design + ## Learning objectives After completing this exercise, the student should: diff --git a/exercises/concept/mensch-aergere-dich-nicht/.docs/hints.md b/exercises/concept/mensch-aergere-dich-nicht/.docs/hints.md index 0d05f3d2f1..a3d422be6a 100644 --- a/exercises/concept/mensch-aergere-dich-nicht/.docs/hints.md +++ b/exercises/concept/mensch-aergere-dich-nicht/.docs/hints.md @@ -1,3 +1,5 @@ +# Hints + ## General - Read about enumerables and streams in the [official Getting Started guide][getting-started-streams]. diff --git a/exercises/concept/mensch-aergere-dich-nicht/.docs/instructions.md b/exercises/concept/mensch-aergere-dich-nicht/.docs/instructions.md index 051973a1d9..3214324448 100644 --- a/exercises/concept/mensch-aergere-dich-nicht/.docs/instructions.md +++ b/exercises/concept/mensch-aergere-dich-nicht/.docs/instructions.md @@ -1,3 +1,5 @@ +# Instructions + While planning a games night with friends, the group decides they will revisit their childhood favorites. Your German friend proposes _Mensch ärgere Dich nicht_ (_Man, Don't Get Angry_), a classic in many European countries (similar to the English _Ludo_ or the North American _Parcheesi_). To prepare for the game, you decide to implement the dice rolling function in Elixir. diff --git a/exercises/concept/mensch-aergere-dich-nicht/.docs/introduction.md b/exercises/concept/mensch-aergere-dich-nicht/.docs/introduction.md index ae844d1d95..889ca1a4f3 100644 --- a/exercises/concept/mensch-aergere-dich-nicht/.docs/introduction.md +++ b/exercises/concept/mensch-aergere-dich-nicht/.docs/introduction.md @@ -1,3 +1,5 @@ +# Introduction + ## Pipe Operator The `|>` operator is called the pipe operator. It can be used to chain function calls together in such a way that the value returned by the previous function call is passed as the first argument to the next function call. diff --git a/exercises/concept/mensch-aergere-dich-nicht/.meta/design.md b/exercises/concept/mensch-aergere-dich-nicht/.meta/design.md index 94005a6563..b64da26881 100644 --- a/exercises/concept/mensch-aergere-dich-nicht/.meta/design.md +++ b/exercises/concept/mensch-aergere-dich-nicht/.meta/design.md @@ -1,3 +1,5 @@ +# Design + ## Learning objectives - Know about the `|>` pipe operator for chaining function calls. diff --git a/exercises/concept/name-badge/.docs/hints.md b/exercises/concept/name-badge/.docs/hints.md index dee818bc17..e0dcca49af 100644 --- a/exercises/concept/name-badge/.docs/hints.md +++ b/exercises/concept/name-badge/.docs/hints.md @@ -1,3 +1,5 @@ +# Hints + ## General - Read about `if` in the official [Getting Started guide][getting-started-if-unless] or on [elixirschool.com][elixirschool-if-unless]. diff --git a/exercises/concept/name-badge/.docs/instructions.md b/exercises/concept/name-badge/.docs/instructions.md index 05c9277ac5..ea180c211c 100644 --- a/exercises/concept/name-badge/.docs/instructions.md +++ b/exercises/concept/name-badge/.docs/instructions.md @@ -1,3 +1,5 @@ +# Instructions + In this exercise you'll be writing code to print name badges for factory employees. Employees have an ID, name, and department name. Employee badge labels are formatted as follows: `"[id] - [name] - [DEPARTMENT]"`. ## 1. Print a badge for an employee diff --git a/exercises/concept/name-badge/.docs/introduction.md b/exercises/concept/name-badge/.docs/introduction.md index 83c4d195e2..264246d883 100644 --- a/exercises/concept/name-badge/.docs/introduction.md +++ b/exercises/concept/name-badge/.docs/introduction.md @@ -1,3 +1,5 @@ +# Introduction + ## Nil [Nil][nil-dictionary] is an English word meaning "nothing" or "zero". In Elixir, `nil` is a special value that means an _absence_ of a value. diff --git a/exercises/concept/name-badge/.meta/design.md b/exercises/concept/name-badge/.meta/design.md index f806fb7667..2a2ec5c24e 100644 --- a/exercises/concept/name-badge/.meta/design.md +++ b/exercises/concept/name-badge/.meta/design.md @@ -1,3 +1,5 @@ +# Design + ## Learning objectives - Know what `nil` represents diff --git a/exercises/concept/newsletter/.docs/hints.md b/exercises/concept/newsletter/.docs/hints.md index 860da8876d..d8ae2263a5 100644 --- a/exercises/concept/newsletter/.docs/hints.md +++ b/exercises/concept/newsletter/.docs/hints.md @@ -1,3 +1,5 @@ +# Hints + ## 1. General - Read about files in the official [Getting Started guide][getting-started-file]. diff --git a/exercises/concept/newsletter/.docs/instructions.md b/exercises/concept/newsletter/.docs/instructions.md index 8f88613596..6ea679cf66 100644 --- a/exercises/concept/newsletter/.docs/instructions.md +++ b/exercises/concept/newsletter/.docs/instructions.md @@ -1,3 +1,5 @@ +# Instructions + You're a big model train enthusiast and have decided to share your passion with the world by starting a newsletter. You'll start by sending the first issue of your newsletter to your friends and acquaintances that share your hobby. You have a text file with a list of their email addresses. ## 1. Read email addresses from a file diff --git a/exercises/concept/newsletter/.docs/introduction.md b/exercises/concept/newsletter/.docs/introduction.md index cdc2172001..921e1c72b2 100644 --- a/exercises/concept/newsletter/.docs/introduction.md +++ b/exercises/concept/newsletter/.docs/introduction.md @@ -1,4 +1,4 @@ -## File +# File Functions for working with files are provided by the `File` module. diff --git a/exercises/concept/newsletter/.meta/design.md b/exercises/concept/newsletter/.meta/design.md index 4ad0b03891..e0e5cf66e9 100644 --- a/exercises/concept/newsletter/.meta/design.md +++ b/exercises/concept/newsletter/.meta/design.md @@ -1,3 +1,5 @@ +# Design + ## Learning objectives - Know about the `File` module diff --git a/exercises/concept/pacman-rules/.docs/hints.md b/exercises/concept/pacman-rules/.docs/hints.md index cc186092f7..2b54c473bd 100644 --- a/exercises/concept/pacman-rules/.docs/hints.md +++ b/exercises/concept/pacman-rules/.docs/hints.md @@ -1,3 +1,5 @@ +# Hints + ## General - Don't worry about how the arguments are derived, just focus on combining the arguments to return the intended result. diff --git a/exercises/concept/pacman-rules/.docs/instructions.md b/exercises/concept/pacman-rules/.docs/instructions.md index b16ff9786c..7dc6e409be 100644 --- a/exercises/concept/pacman-rules/.docs/instructions.md +++ b/exercises/concept/pacman-rules/.docs/instructions.md @@ -1,3 +1,5 @@ +# Instructions + In this exercise, you need to translate some rules from the classic game Pac-Man into Elixir functions. You have four rules to translate, all related to the game states. diff --git a/exercises/concept/pacman-rules/.docs/introduction.md b/exercises/concept/pacman-rules/.docs/introduction.md index 50b663b82d..acaad44b5d 100644 --- a/exercises/concept/pacman-rules/.docs/introduction.md +++ b/exercises/concept/pacman-rules/.docs/introduction.md @@ -1,4 +1,4 @@ -## Booleans +# Booleans Elixir represents true and false values with the boolean type. There are only two values: _true_ and _false_. These values can be bound to a variable: diff --git a/exercises/concept/pacman-rules/.meta/design.md b/exercises/concept/pacman-rules/.meta/design.md index d4965f3dd5..0df897c078 100644 --- a/exercises/concept/pacman-rules/.meta/design.md +++ b/exercises/concept/pacman-rules/.meta/design.md @@ -1,3 +1,5 @@ +# Design + ## Learning objectives - Know what a variable is. diff --git a/exercises/concept/remote-control-car/.docs/hints.md b/exercises/concept/remote-control-car/.docs/hints.md index d9715c78bd..f15ef18cb0 100644 --- a/exercises/concept/remote-control-car/.docs/hints.md +++ b/exercises/concept/remote-control-car/.docs/hints.md @@ -1,3 +1,5 @@ +# Hints + ## General - Read about [structs][getting-started-structs] in the Getting Started guide. diff --git a/exercises/concept/remote-control-car/.docs/instructions.md b/exercises/concept/remote-control-car/.docs/instructions.md index 093f1d1fea..81b32e26d9 100644 --- a/exercises/concept/remote-control-car/.docs/instructions.md +++ b/exercises/concept/remote-control-car/.docs/instructions.md @@ -1,3 +1,5 @@ +# Instructions + In this exercise you'll be playing around with a remote controlled car, which you've finally saved enough money for to buy. Cars start with full (100%) batteries. Each time you drive the car using the remote control, it covers 20 meters and drains one percent of the battery. The car's nickname is not known until it is created. diff --git a/exercises/concept/remote-control-car/.docs/introduction.md b/exercises/concept/remote-control-car/.docs/introduction.md index e57ea3acff..719e53902a 100644 --- a/exercises/concept/remote-control-car/.docs/introduction.md +++ b/exercises/concept/remote-control-car/.docs/introduction.md @@ -1,4 +1,4 @@ -## Structs +# Structs Structs are an extension built on top of maps which provide compile-time checks and default values. A struct is named after the module it is defined in. To define a struct use the `defstruct` construct. The construct usually immediately follows after the module definition. `defstruct` accepts either a list of atoms (for `nil` default values) or key-value tuples (for specified default values). The fields without defaults must precede the fields with default values. @@ -11,7 +11,7 @@ plane = %Plane{} # => %Plane{engine: nil, wings: 2} ``` -### Accessing fields and updating +## Accessing fields and updating Since structs are built on maps, we can use most map functions to get and manipulate values. The _Access Behaviour_ is **not** implemented for structs. It is recommended to use the _static access operator_ `.` to access struct fields instead. @@ -33,7 +33,7 @@ Since structs are built on maps, we can use most map functions to get and manipu # => %Plane{engine: nil, wings: 4} ``` -### Enforcing field value initialization +## Enforcing field value initialization We can use the `@enforce_keys` module attribute with a list of the field keys to ensure that the values are initialized when the struct is created. If a key is not listed, its value will be `nil` as seen in the above example. If an enforced key is not initialized, an error is raised. diff --git a/exercises/concept/remote-control-car/.meta/design.md b/exercises/concept/remote-control-car/.meta/design.md index 1535733e00..b98d0b562b 100644 --- a/exercises/concept/remote-control-car/.meta/design.md +++ b/exercises/concept/remote-control-car/.meta/design.md @@ -1,3 +1,5 @@ +# Design + ## Learning objectives - Know what a struct is diff --git a/exercises/concept/rpg-character-sheet/.docs/hints.md b/exercises/concept/rpg-character-sheet/.docs/hints.md index 94b1d4915b..11ff064455 100644 --- a/exercises/concept/rpg-character-sheet/.docs/hints.md +++ b/exercises/concept/rpg-character-sheet/.docs/hints.md @@ -1,3 +1,5 @@ +# Hints + ## General - Read about [IO][getting-started-io] in the Getting Started guide. diff --git a/exercises/concept/rpg-character-sheet/.docs/instructions.md b/exercises/concept/rpg-character-sheet/.docs/instructions.md index 2f819082aa..8d26371856 100644 --- a/exercises/concept/rpg-character-sheet/.docs/instructions.md +++ b/exercises/concept/rpg-character-sheet/.docs/instructions.md @@ -1,3 +1,5 @@ +# Instructions + You and your friends love to play pen-and-paper role-playing games, but you noticed that it's difficult to get new people to join your group. They often struggle with character creation. They don't know where to start. To help new players out, you decided to write a small program that will guide them through the process. ## 1. Welcome the new player diff --git a/exercises/concept/rpg-character-sheet/.docs/introduction.md b/exercises/concept/rpg-character-sheet/.docs/introduction.md index d45e0d316e..204946c826 100644 --- a/exercises/concept/rpg-character-sheet/.docs/introduction.md +++ b/exercises/concept/rpg-character-sheet/.docs/introduction.md @@ -1,8 +1,8 @@ -## IO +# IO Functions for handling input and output are provided by the `IO` module. -### Output +## Output To write a string to the standard output, use `IO.puts`. `IO.puts` always adds a new line at the end of the string. If you don't want that behavior, use `IO.write` instead. Both functions return the atom `:ok` if they succeed. @@ -14,7 +14,7 @@ IO.puts("Hi!") `IO.puts` is useful for writing strings, but not much else. If you need a tool for debugging that will allow you to write any value to standard output, use `IO.inspect` instead. `IO.inspect` returns the value it was passed unchanged, so it can be inserted in any point in your code. It also accepts many options, for example `:label`, that will allow you to distinguish it form other `IO.inspect` calls. -### Input +## Input To read a line from the standard input, use `IO.gets`. `IO.gets` accepts one argument - a string that it will print as a prompt for the input. `IO.gets` doesn't add a new line after the prompt, you need it include it yourself if you need it. diff --git a/exercises/concept/rpg-character-sheet/.meta/design.md b/exercises/concept/rpg-character-sheet/.meta/design.md index e10d7295e4..9f8eb073fe 100644 --- a/exercises/concept/rpg-character-sheet/.meta/design.md +++ b/exercises/concept/rpg-character-sheet/.meta/design.md @@ -1,3 +1,5 @@ +# Design + ## Learning objectives - Know how to write a string to stdio or stderr diff --git a/exercises/concept/rpn-calculator-output/.docs/hints.md b/exercises/concept/rpn-calculator-output/.docs/hints.md index 3d41d7af72..d1b758bbcf 100644 --- a/exercises/concept/rpn-calculator-output/.docs/hints.md +++ b/exercises/concept/rpn-calculator-output/.docs/hints.md @@ -1,3 +1,5 @@ +# Hints + ## General - Read about [errors][getting-started-errors] in the Getting Started guide. diff --git a/exercises/concept/rpn-calculator-output/.docs/instructions.md b/exercises/concept/rpn-calculator-output/.docs/instructions.md index 5a9cd01b6d..6b6b174593 100644 --- a/exercises/concept/rpn-calculator-output/.docs/instructions.md +++ b/exercises/concept/rpn-calculator-output/.docs/instructions.md @@ -1,3 +1,5 @@ +# Instructions + Work is progressing well at _Instruments of Texas_ on the RPN Calculator. Your team now wants to be able to write a string version of the equation to an _IO_ resource. ## 1. Open a file diff --git a/exercises/concept/rpn-calculator-output/.docs/introduction.md b/exercises/concept/rpn-calculator-output/.docs/introduction.md index 9395e8fe00..6b479d1bab 100644 --- a/exercises/concept/rpn-calculator-output/.docs/introduction.md +++ b/exercises/concept/rpn-calculator-output/.docs/introduction.md @@ -1,3 +1,5 @@ +# Introduction + ## Try Rescue Else After Using `try..rescue` is a powerful construct for catching errors when they occur. Rescuing errors allows functions to return defined values when it is necessary. The `try..rescue` construct also offers us two additional features we can make use of: diff --git a/exercises/concept/rpn-calculator-output/.meta/design.md b/exercises/concept/rpn-calculator-output/.meta/design.md index 59190a7a5c..75de81732e 100644 --- a/exercises/concept/rpn-calculator-output/.meta/design.md +++ b/exercises/concept/rpn-calculator-output/.meta/design.md @@ -1,3 +1,5 @@ +# Design + ## Learning objectives - Know of `try..rescue`'s additional options: diff --git a/exercises/concept/rpn-calculator/.docs/hints.md b/exercises/concept/rpn-calculator/.docs/hints.md index abd5346d5e..61ac0e57ae 100644 --- a/exercises/concept/rpn-calculator/.docs/hints.md +++ b/exercises/concept/rpn-calculator/.docs/hints.md @@ -1,3 +1,5 @@ +# Hints + ## General - Read about [errors][errors] in the Getting Started guide. diff --git a/exercises/concept/rpn-calculator/.docs/instructions.md b/exercises/concept/rpn-calculator/.docs/instructions.md index 0f8f2a77c0..20daf808bb 100644 --- a/exercises/concept/rpn-calculator/.docs/instructions.md +++ b/exercises/concept/rpn-calculator/.docs/instructions.md @@ -1,3 +1,5 @@ +# Instructions + While working at _Instruments of Texas_, you are tasked to work on an experimental calculator written in Elixir. Your team is having a problem with some operations raising errors and crashing the process. You have been tasked to write a function which wraps the operation function so that the errors can be handled more elegantly with idiomatic Elixir code. ## 1. Warn the team diff --git a/exercises/concept/rpn-calculator/.docs/introduction.md b/exercises/concept/rpn-calculator/.docs/introduction.md index 515b7bd838..676df13659 100644 --- a/exercises/concept/rpn-calculator/.docs/introduction.md +++ b/exercises/concept/rpn-calculator/.docs/introduction.md @@ -1,3 +1,5 @@ +# Introduction + ## Errors Errors happen. In Elixir, while people often say to "let it crash", there are times when we need to rescue the function call to a known good state to fulfil a software contract. In some languages, errors are used as method of control flow, but in Elixir, this pattern is discouraged. We can often recognize functions that may raise an error just by their name: functions that raise errors are to have `!` at the end of their name. This is in comparison with functions that return `{:ok, value}` or `:error`. Look at these library examples: diff --git a/exercises/concept/rpn-calculator/.meta/design.md b/exercises/concept/rpn-calculator/.meta/design.md index 367da9d6f6..959eea36d9 100644 --- a/exercises/concept/rpn-calculator/.meta/design.md +++ b/exercises/concept/rpn-calculator/.meta/design.md @@ -1,3 +1,5 @@ +# Design + ## Learning objectives - Know what an error is diff --git a/exercises/concept/secrets/.docs/hints.md b/exercises/concept/secrets/.docs/hints.md index c542248da6..e0f0044469 100644 --- a/exercises/concept/secrets/.docs/hints.md +++ b/exercises/concept/secrets/.docs/hints.md @@ -1,3 +1,5 @@ +# Hints + ## General - Make use of [anonymous functions][anon-fns]. diff --git a/exercises/concept/secrets/.docs/instructions.md b/exercises/concept/secrets/.docs/instructions.md index 6d75aa5f2b..e22e3ad071 100644 --- a/exercises/concept/secrets/.docs/instructions.md +++ b/exercises/concept/secrets/.docs/instructions.md @@ -1,3 +1,5 @@ +# Instructions + In this exercise, you've been tasked with writing the software for an encryption device that works by performing transformations on data. You need a way to flexibly create complicated functions by combining simpler functions together. For each task, make use of a closure and return a function that can be invoked from the calling scope. diff --git a/exercises/concept/secrets/.docs/introduction.md b/exercises/concept/secrets/.docs/introduction.md index 01ca5f35d0..bf07bcd9e3 100644 --- a/exercises/concept/secrets/.docs/introduction.md +++ b/exercises/concept/secrets/.docs/introduction.md @@ -1,3 +1,5 @@ +# Introduction + ## Anonymous Functions Functions are treated as first class citizens in Elixir. This means functions: diff --git a/exercises/concept/secrets/.meta/design.md b/exercises/concept/secrets/.meta/design.md index 1aee7f5b79..c8a0fca2cd 100644 --- a/exercises/concept/secrets/.meta/design.md +++ b/exercises/concept/secrets/.meta/design.md @@ -1,3 +1,5 @@ +# Design + ## Learning objectives After completing this exercise, the student should: diff --git a/exercises/concept/stack-underflow/.docs/hints.md b/exercises/concept/stack-underflow/.docs/hints.md index eb47de2454..b39fcb842e 100644 --- a/exercises/concept/stack-underflow/.docs/hints.md +++ b/exercises/concept/stack-underflow/.docs/hints.md @@ -1,3 +1,5 @@ +# Hints + ## General - Read about [errors][getting-started-errors] in the Getting Started guide. diff --git a/exercises/concept/stack-underflow/.docs/instructions.md b/exercises/concept/stack-underflow/.docs/instructions.md index aabeb05227..4612225ce0 100644 --- a/exercises/concept/stack-underflow/.docs/instructions.md +++ b/exercises/concept/stack-underflow/.docs/instructions.md @@ -1,3 +1,5 @@ +# Instructions + While continuing your work at _Instruments of Texas_, there is progress being made on the Elixir implementation of the RPN calculator. Your team would like to be able to raise errors that are more specific than the generic errors provided by the standard library. You are doing some research, but you have decided to implement two new errors which implement the _Exception Behaviour_. ## 1. Error for Division by Zero diff --git a/exercises/concept/stack-underflow/.docs/introduction.md b/exercises/concept/stack-underflow/.docs/introduction.md index c262965b4a..fd4c40ae09 100644 --- a/exercises/concept/stack-underflow/.docs/introduction.md +++ b/exercises/concept/stack-underflow/.docs/introduction.md @@ -1,4 +1,4 @@ -## Exceptions +# Exceptions All errors in Elixir implement the _Exception Behaviour_. Just like the _Access Behaviour_, the _Exception Behaviour_ defines callback functions that a module must implement to fulfill the software contract of the behaviour. Once an error is defined, it has the following properties: @@ -9,7 +9,7 @@ All errors in Elixir implement the _Exception Behaviour_. Just like the _Access The _Exception Behaviour_ also specifies two callbacks: `message/1` and `exception/1`. If unimplemented, default implementations will be used. `message/1` transforms the error-struct to a readable message when called with `raise`. `exception/1` allows additional context to be added to the message when it is called with `raise/2` -### Defining an exception +## Defining an exception To define an exception from an error module, we use the `defexception` macro: @@ -35,7 +35,7 @@ defmodule MyCustomizedError do end ``` -### Using exceptions +## Using exceptions Defined errors may be used like a built in error using either `raise/1` or `raise/2`. diff --git a/exercises/concept/stack-underflow/.meta/design.md b/exercises/concept/stack-underflow/.meta/design.md index 5172bc805f..ecc4b1cef3 100644 --- a/exercises/concept/stack-underflow/.meta/design.md +++ b/exercises/concept/stack-underflow/.meta/design.md @@ -1,3 +1,5 @@ +# Design + ## Learning objectives - Know what the _Exception behaviour_ is diff --git a/exercises/concept/take-a-number/.docs/hints.md b/exercises/concept/take-a-number/.docs/hints.md index d1dd4d2783..10cc9e2f5c 100644 --- a/exercises/concept/take-a-number/.docs/hints.md +++ b/exercises/concept/take-a-number/.docs/hints.md @@ -1,3 +1,5 @@ +# Hints + ## General - Read about processes in the official [Getting Started guide][getting-started-processes]. diff --git a/exercises/concept/take-a-number/.docs/instructions.md b/exercises/concept/take-a-number/.docs/instructions.md index fbd954f3e8..b0ad5ae430 100644 --- a/exercises/concept/take-a-number/.docs/instructions.md +++ b/exercises/concept/take-a-number/.docs/instructions.md @@ -1,3 +1,5 @@ +# Instructions + You are writing an embedded system for a Take-A-Number machine. It is a very simple model. It can give out consecutive numbers and report what was the last number given out. ## 1. Start the machine diff --git a/exercises/concept/take-a-number/.docs/introduction.md b/exercises/concept/take-a-number/.docs/introduction.md index 4600eacd70..06299436d1 100644 --- a/exercises/concept/take-a-number/.docs/introduction.md +++ b/exercises/concept/take-a-number/.docs/introduction.md @@ -1,3 +1,5 @@ +# Introduction + ## Processes In Elixir, all code runs inside processes. diff --git a/exercises/concept/take-a-number/.meta/design.md b/exercises/concept/take-a-number/.meta/design.md index 0ee6234b59..bc2b52b362 100644 --- a/exercises/concept/take-a-number/.meta/design.md +++ b/exercises/concept/take-a-number/.meta/design.md @@ -1,3 +1,5 @@ +# Design + ## Learning objectives - Know what a process is. diff --git a/exercises/concept/wine-cellar/.docs/hints.md b/exercises/concept/wine-cellar/.docs/hints.md index acee7bd8b6..cf2f1f56b5 100644 --- a/exercises/concept/wine-cellar/.docs/hints.md +++ b/exercises/concept/wine-cellar/.docs/hints.md @@ -1,3 +1,5 @@ +# Hints + ## General - Read about keyword lists in the official [Getting Started guide][getting-started-keyword-lists]. diff --git a/exercises/concept/wine-cellar/.docs/instructions.md b/exercises/concept/wine-cellar/.docs/instructions.md index 8c3ccfb23c..df2ecd2b1f 100644 --- a/exercises/concept/wine-cellar/.docs/instructions.md +++ b/exercises/concept/wine-cellar/.docs/instructions.md @@ -1,3 +1,5 @@ +# Instructions + You are the manager of a fancy restaurant that has a sizable wine cellar. A lot of your customers are demanding wine enthusiasts. Finding the right bottle of wine for a particular customer is not an easy task. As a tech-savvy restaurant owner, you decided to speed up the wine selection process by writing an app that will let guests filter your wines by their preferences. diff --git a/exercises/concept/wine-cellar/.docs/introduction.md b/exercises/concept/wine-cellar/.docs/introduction.md index 9cc2567bcb..14be25d8c3 100644 --- a/exercises/concept/wine-cellar/.docs/introduction.md +++ b/exercises/concept/wine-cellar/.docs/introduction.md @@ -1,4 +1,4 @@ -## Keyword Lists +# Keyword Lists Keyword lists are a key-value data structure. diff --git a/exercises/concept/wine-cellar/.meta/design.md b/exercises/concept/wine-cellar/.meta/design.md index 47675801e4..8237574787 100644 --- a/exercises/concept/wine-cellar/.meta/design.md +++ b/exercises/concept/wine-cellar/.meta/design.md @@ -1,3 +1,5 @@ +# Design + ## Learning objectives - Know that keyword lists are key-value storage. diff --git a/exercises/practice/diffie-hellman/.docs/hints.md b/exercises/practice/diffie-hellman/.docs/hints.md index b4465938b9..65970cffa6 100644 --- a/exercises/practice/diffie-hellman/.docs/hints.md +++ b/exercises/practice/diffie-hellman/.docs/hints.md @@ -1,4 +1,4 @@ -## General +# General - For generating random numbers, Erlang's `:rand.uniform` or `Enum.random` are good places to start. diff --git a/exercises/practice/secret-handshake/.docs/hints.md b/exercises/practice/secret-handshake/.docs/hints.md index 6db57cbe92..b89df1200b 100644 --- a/exercises/practice/secret-handshake/.docs/hints.md +++ b/exercises/practice/secret-handshake/.docs/hints.md @@ -1,4 +1,4 @@ -## General +# General - Use `Bitwise` (or div/rem). - If you use `Bitwise`, an easy way to see if a particular bit is set is to compare diff --git a/exercises/practice/strain/.docs/hints.md b/exercises/practice/strain/.docs/hints.md index 7de43cf9a9..5a9ca0d86c 100644 --- a/exercises/practice/strain/.docs/hints.md +++ b/exercises/practice/strain/.docs/hints.md @@ -1,3 +1,3 @@ -## General +# General - `apply` will let you pass arguments to a function, as will `fun.(args)`. diff --git a/exercises/practice/tournament/.docs/hints.md b/exercises/practice/tournament/.docs/hints.md index 1eaf50668d..3437023912 100644 --- a/exercises/practice/tournament/.docs/hints.md +++ b/exercises/practice/tournament/.docs/hints.md @@ -1,4 +1,4 @@ -## General +# General - Formatting the output is easy with `String`'s padding functions. All number columns can be left-padded with spaces to a width of 2 characters, while the diff --git a/exercises/practice/zipper/hints/README.md b/exercises/practice/zipper/hints/README.md index 6a8de1c862..f981e76980 100644 --- a/exercises/practice/zipper/hints/README.md +++ b/exercises/practice/zipper/hints/README.md @@ -1,2 +1,4 @@ +# Readme + This directory contains some hints to help you complete this exercise. The higher the number of a hint file, the most explicit the hint. diff --git a/exercises/practice/zipper/hints/hint_1.md b/exercises/practice/zipper/hints/hint_1.md index f534b5b88e..803c14e0e6 100644 --- a/exercises/practice/zipper/hints/hint_1.md +++ b/exercises/practice/zipper/hints/hint_1.md @@ -1 +1,3 @@ +# hint 1 + The difficult part is not getting there but remembering how you got there. diff --git a/exercises/practice/zipper/hints/hint_2.md b/exercises/practice/zipper/hints/hint_2.md index 37dae2f948..57ba703768 100644 --- a/exercises/practice/zipper/hints/hint_2.md +++ b/exercises/practice/zipper/hints/hint_2.md @@ -1,2 +1,4 @@ +# hint 2 + Keep a trail of what choices you made. Be sure to include alternative branches, lest you forget them. diff --git a/exercises/practice/zipper/hints/hint_3.md b/exercises/practice/zipper/hints/hint_3.md index 7486b59f08..3d84b9781e 100644 --- a/exercises/practice/zipper/hints/hint_3.md +++ b/exercises/practice/zipper/hints/hint_3.md @@ -1,3 +1,5 @@ +# hint 3 + ```elixir @type trail :: { :left, any, BinTree.t, trail } | { :right, any, BinTree.t, trail }