Skip to content

Commit

Permalink
Merge branch 'exercism:main' into impliment-dart
Browse files Browse the repository at this point in the history
  • Loading branch information
meatball133 authored Dec 14, 2024
2 parents b359c1d + 00c0ba8 commit d44eb86
Show file tree
Hide file tree
Showing 130 changed files with 1,807 additions and 568 deletions.
2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ updates:
- package-ecosystem: 'github-actions'
directory: '/'
schedule:
interval: 'daily'
interval: 'monthly'
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
RUNALL: "true"
steps:
- name: Checkout code
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683

- name: Run tests
run: swift test
Expand All @@ -24,15 +24,15 @@ jobs:
RUNALL: "true"
steps:
- name: Checkout code
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683

- name: Run tests
run: swift test --package-path ./generator
generator-template-tests:
runs-on: macos-13
steps:
- name: Checkout code
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683

- name: Run tests
run: ./bin/test_generator.sh
2 changes: 2 additions & 0 deletions .github/workflows/configlet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@ permissions:
jobs:
configlet:
uses: exercism/github-actions/.github/workflows/configlet.yml@main
with:
fmt: true
23 changes: 23 additions & 0 deletions .github/workflows/no-important-files-changed.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: No important files changed

on:
pull_request_target:
types: [opened]
branches: [main]
paths:
- "exercises/concept/**"
- "exercises/practice/**"
- "!exercises/*/*/.approaches/**"
- "!exercises/*/*/.articles/**"
- "!exercises/*/*/.docs/**"
- "!exercises/*/*/.meta/**"

permissions:
pull-requests: write

jobs:
check:
uses: exercism/github-actions/.github/workflows/check-no-important-files-changed.yml@main
with:
repository: ${{ github.event.pull_request.head.repo.owner.login }}/${{ github.event.pull_request.head.repo.name }}
ref: ${{ github.head_ref }}
16 changes: 16 additions & 0 deletions .github/workflows/ping-cross-track-maintainers-team.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Ping cross-track maintainers team

on:
pull_request_target:
types:
- opened

permissions:
pull-requests: write

jobs:
ping:
if: github.repository_owner == 'exercism' # Stops this job from running on forks
uses: exercism/github-actions/.github/workflows/ping-cross-track-maintainers-team.yml@main
secrets:
github_membership_token: ${{ secrets.COMMUNITY_CONTRIBUTIONS_WORKFLOW_TOKEN }}
2 changes: 1 addition & 1 deletion CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,4 @@ This policy was initially adopted from the Front-end London Slack community and
A version history can be seen on [GitHub](https://github.com/exercism/website-copy/edit/main/pages/code_of_conduct.md).

_This policy is a "living" document, and subject to refinement and expansion in the future.
This policy applies to the Exercism website, the Exercism GitHub organization, any other Exercism-related communication channels (e.g. Slack, Twitter, email) and any other Exercism entity or event._
This policy applies to the Exercism website, the Exercism GitHub organization, any other Exercism-related communication channels (e.g. Discord, Forum, Twitter, email) and any other Exercism entity or event._
23 changes: 12 additions & 11 deletions bin/fetch-configlet
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@ get_download_url() {
local latest='https://api.github.com/repos/exercism/configlet/releases/latest'
local arch
case "$(uname -m)" in
x86_64) arch='x86-64' ;;
*686*) arch='i386' ;;
*386*) arch='i386' ;;
*) arch='x86-64' ;;
aarch64|arm64) arch='arm64' ;;
x86_64) arch='x86-64' ;;
*686*) arch='i386' ;;
*386*) arch='i386' ;;
*) arch='x86-64' ;;
esac
local suffix="${os}_${arch}.${ext}"
curl "${curlopts[@]}" --header 'Accept: application/vnd.github.v3+json' "${latest}" |
Expand All @@ -47,7 +48,7 @@ main() {
fi

local os
case "$(uname)" in
case "$(uname -s)" in
Darwin*) os='macos' ;;
Linux*) os='linux' ;;
Windows*) os='windows' ;;
Expand All @@ -58,8 +59,8 @@ main() {

local ext
case "${os}" in
windows*) ext='zip' ;;
*) ext='tar.gz' ;;
windows) ext='zip' ;;
*) ext='tar.gz' ;;
esac

echo "Fetching configlet..." >&2
Expand All @@ -69,16 +70,16 @@ main() {
curl "${curlopts[@]}" --output "${output_path}" "${download_url}"

case "${ext}" in
*zip) unzip "${output_path}" -d "${output_dir}" ;;
*) tar xzf "${output_path}" -C "${output_dir}" ;;
zip) unzip "${output_path}" -d "${output_dir}" ;;
*) tar xzf "${output_path}" -C "${output_dir}" ;;
esac

rm -f "${output_path}"

local executable_ext
case "${os}" in
windows*) executable_ext='.exe' ;;
*) executable_ext='' ;;
windows) executable_ext='.exe' ;;
*) executable_ext='' ;;
esac

local configlet_path="${output_dir}/configlet${executable_ext}"
Expand Down
17 changes: 7 additions & 10 deletions concepts/basics/about.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,7 @@ var variableName = 10
```

Swift is a type-safe, statically typed language, which means all values have a type at compile time.
You can either explicitly specify the type of a variable or let the compiler [infer the type][type-infering] based on the assigned value.

When assigning a value to a variable are there two ways either through explicit typing through [type annotations][type annotations] or implicit typing.

You can either explicitly specify the type of a variable with [type annotations][type annotations] or let the compiler [infer the type][type-inferring].
```swift
var explicitVar: Int = 10 // Explicitly typed
var implicitVar = 10 // Implicitly typed
Expand Down Expand Up @@ -89,8 +86,8 @@ print(2 * 2) // Prints 4
### Functions

In Swift, [functions][functions] are a chunk of code that performs a task.
A function has a return type and can thereby be used as a value and be parsed as arguments to other functions.
In Swift are functions defined using the `func` keyword followed by the name of the function, arguments separated by commas, and a return type.
A function has a return type and can thereby be used as a value and be passed as an argument to other functions.
In Swift, functions are defined using the `func` keyword followed by the name of the function, arguments separated by commas, and a return type.

The arguments are defined by an argument label, a parameter name followed by a colon and then a type.
The return type is defined by a `->` followed by the type of the return value.
Expand All @@ -101,11 +98,11 @@ func functionName(argumentName parameterName: ArgumentType) -> ReturnType {
}
```

Swift arguments are a bit special compared to other languages, they use [argument labels][argumment-labels].
Swift arguments are a bit special compared to other languages, they use [argument labels][argument-labels].
The argument label is used when calling the function.
The parameter name is used inside the function body to refer to the argument value.
If you only assign one name to the argument it will be used as both the argument label and the parameter name.
When assigning the argument label name as: `_` so will the argument not have a label when calling the function, e.g: `functionName(argumentValue)`
When assigning the argument label name as: `_` the argument will not have a label when calling the function, e.g: `functionName(argumentValue)`

To call a function you use the function name followed by the argument label and the argument value, like this:

Expand Down Expand Up @@ -141,7 +138,7 @@ Single line comments are preceded by `//` and multiline comments are inserted be
[comments]: https://docs.swift.org/swift-book/documentation/the-swift-programming-language/thebasics/#Comments
[constants-variables]: https://docs.swift.org/swift-book/documentation/the-swift-programming-language/thebasics#Constants-and-Variables
[type annotations]: https://docs.swift.org/swift-book/documentation/the-swift-programming-language/thebasics/#Type-Annotations
[type-infering]: https://docs.swift.org/swift-book/documentation/the-swift-programming-language/thebasics#Type-Safety-and-Type-Inference
[type-inferring]: https://docs.swift.org/swift-book/documentation/the-swift-programming-language/thebasics#Type-Safety-and-Type-Inference
[functions]: https://docs.swift.org/swift-book/documentation/the-swift-programming-language/functions/#Defining-and-Calling-Functions
[arithmetical-operators]: https://docs.swift.org/swift-book/documentation/the-swift-programming-language/basicoperators/#Arithmetic-Operators
[argumment-labels]: https://docs.swift.org/swift-book/documentation/the-swift-programming-language/functions/#Function-Argument-Labels-and-Parameter-Names
[argument-labels]: https://docs.swift.org/swift-book/documentation/the-swift-programming-language/functions/#Function-Argument-Labels-and-Parameter-Names
16 changes: 7 additions & 9 deletions concepts/basics/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ var variableName = 10
```

Swift is a type-safe, statically typed language, which means all values have a type at compile time.
You can either explicitly specify the type of a variable or let the compiler [infer the type][type-infering] based on the assigned value.

When assigning a value to a variable are there two ways either through explicit typing through [type annotations][type annotations] or implicit typing.
You can either explicitly specify the type of a variable with [type annotations][type annotations] or let the compiler [infer the type][type-inferring].

```swift
var explicitVar: Int = 10 // Explicitly typed
Expand Down Expand Up @@ -75,8 +73,8 @@ print(2 * 2) // Prints 4
### Functions

In Swift, [functions][functions] are a chunk of code that performs a task.
A function has a return type and can thereby be used as a value and be parsed as arguments to other functions.
In Swift are functions defined using the `func` keyword followed by the name of the function, arguments separated by commas, and a return type.
A function has a return type and can thereby be used as a value and be passed as an argument to other functions.
In Swift, functions are defined using the `func` keyword followed by the name of the function, arguments separated by commas, and a return type.

The arguments are defined by an argument label, a parameter name followed by a colon and then a type.
The return type is defined by a `->` followed by the type of the return value.
Expand All @@ -87,11 +85,11 @@ func functionName(argumentName parameterName: ArgumentType) -> ReturnType {
}
```

Swift arguments are a bit special compared to other languages, they use [argument labels][argumment-labels].
Swift arguments are a bit special compared to other languages, they use [argument labels][argument-labels].
The argument label is used when calling the function.
The parameter name is used inside the function body to refer to the argument value.
If you only assign one name to the argument it will be used as both the argument label and the parameter name.
When assigning the argument label name as: `_` so will the argument not have a label when calling the function, e.g: `functionName(argumentValue)`
When assigning the argument label name as: `_` the argument will not have a label when calling the function, e.g: `functionName(argumentValue)`

To call a function you use the function name followed by the argument label and the argument value, like this:

Expand Down Expand Up @@ -127,7 +125,7 @@ Single line comments are preceded by `//` and multiline comments are inserted be
[comments]: https://docs.swift.org/swift-book/documentation/the-swift-programming-language/thebasics/#Comments
[constants-variables]: https://docs.swift.org/swift-book/documentation/the-swift-programming-language/thebasics#Constants-and-Variables
[type annotations]: https://docs.swift.org/swift-book/documentation/the-swift-programming-language/thebasics/#Type-Annotations
[type-infering]: https://docs.swift.org/swift-book/documentation/the-swift-programming-language/thebasics#Type-Safety-and-Type-Inference
[type-inferring]: https://docs.swift.org/swift-book/documentation/the-swift-programming-language/thebasics#Type-Safety-and-Type-Inference
[functions]: https://docs.swift.org/swift-book/documentation/the-swift-programming-language/functions/#Defining-and-Calling-Functions
[arithmetical-operators]: https://docs.swift.org/swift-book/documentation/the-swift-programming-language/basicoperators/#Arithmetic-Operators
[argumment-labels]: https://docs.swift.org/swift-book/documentation/the-swift-programming-language/functions/#Function-Argument-Labels-and-Parameter-Names
[argument-labels]: https://docs.swift.org/swift-book/documentation/the-swift-programming-language/functions/#Function-Argument-Labels-and-Parameter-Names
4 changes: 2 additions & 2 deletions concepts/characters-and-strings/about.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# About

Strings are a data type that represent a text value.
[`Strings`][strings-and-characters] in Swift are a collection of `Character`s, which themselves hold a [Unicode scalar values][unicode-scalar-values].
[`Strings`][strings-and-characters] in Swift are a collection of `Character`s, which themselves hold a [Unicode scalar value][unicode-scalar-values].

You can create a String through a string literal, which is a series of characters enclosed in double quotation marks (`"`).
For multi-line strings, you can use triple quotation marks (`"""`).
Expand Down Expand Up @@ -46,7 +46,7 @@ let badChar: Character = "Too many characters"

## Concatenation

In Swift can strings be [concatenated][] using the `+` operator.
In Swift, strings can be [concatenated][] using the `+` operator.
Characters can **not** be concatenated with strings using the `+` operator without first converting the character to a string.

```swift
Expand Down
4 changes: 2 additions & 2 deletions concepts/characters-and-strings/introduction.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# About

Strings are a data type that represent a text value.
[`Strings`][strings-and-characters] in Swift are a collection of `Character`s, which themselves hold a [Unicode scalar values][unicode-scalar-values].
[`Strings`][strings-and-characters] in Swift are a collection of `Character`s, which themselves hold a [Unicode scalar value][unicode-scalar-values].

You can create a String through a string literal, which is a series of characters enclosed in double quotation marks (`"`).
For multi-line strings, you can use triple quotation marks (`"""`).
Expand Down Expand Up @@ -46,7 +46,7 @@ let badChar: Character = "Too many characters"

## Concatenation

In Swift can strings be [concatenated][] using the `+` operator.
In Swift, strings can be [concatenated][] using the `+` operator.
Characters can **not** be concatenated with strings using the `+` operator without first converting the character to a string.

```swift
Expand Down
2 changes: 1 addition & 1 deletion concepts/conditionals/about.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Here is a list of the comparison operators and an example of when they give a `t
| ------ | --------------------- | ------- |
| == | equal | 1 == 1 |
| != | not equal | 1 != 2 |
| < | less than | 5 < 4 |
| < | less than | 4 < 5 |
| <= | less than or equal | 4 <= 4 |
| > | greater than | 3 > 1 |
| >= | greater than or equal | 2 >= 2 |
Expand Down
2 changes: 1 addition & 1 deletion concepts/conditionals/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Here is a list of the comparison operators and an example of when they give a `t
| ------ | --------------------- | ------- |
| == | equal | 1 == 1 |
| != | not equal | 1 != 2 |
| < | less than | 5 < 4 |
| < | less than | 4 < 5 |
| <= | less than or equal | 4 <= 4 |
| > | greater than | 3 > 1 |
| >= | greater than or equal | 2 >= 2 |
Expand Down
18 changes: 15 additions & 3 deletions concepts/dictionaries/about.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ As [dictionaries][dictionaries] are one of Swift's three primary collection type
```swift
var addresses: Dictionary<String, String> = ["The Munsters": "1313 Mockingbird Lane", "The Simpsons": "742 Evergreen Terrace", "Buffy Summers": "1630 Revello Drive"]
var sequences: [String: [Int]] = ["Euler's totient": [1, 1, 2, 2, 4, 2, 6, 4], "Lazy caterer": [1, 2, 4, 7, 11, 16, 22, 29, 37], "Carmichael": [561, 1105, 1729, 2465, 2821, 6601, 8911, 10585, 15841]]
let constants: = ["pi": 3.14159, "e": 2.71828, "phi": 1.618033, "avogadro": 6.02214076e22]
let constants: = ["pi": 3.14159, "e": 2.71828, "phi": 1.618033, "avogadro": 6.02214076e23]
```

- Empty dictionaries can be written by following the type name of the dictionary by a pair of parenthesis, e.g. `[Int: String]()`, or, if the type can be determined from the context, as just a pair of square brackets surrounding a colon, `[:]`.
- Type names for dictionaries are written in one of two ways: `Dictionary<K, V>` or `[K: V]` where `K` is the type of the keys in the dictionary and `V` is the type of the values.
- Dictionary elements can be accessed using subscript notation, e.g. `addresses["The Simpsons"]`.
- Values returned from these look-ups are optionals; `nil` is returned if a requested key is not present in the dictionary.```
- Values returned from these look-ups are optionals; `nil` is returned if a requested key is not present in the dictionary.
- To avoid the optional type of the return, one can supply a default value to return if the key in not found in the dictionary.

```swift
Expand All @@ -35,7 +35,19 @@ let betty = addresses["Betty Cooper", default: "Address unknown"]
- This can be used to update the value associated with a key or to add a new _key: value_ pair to the dictionary.
- Dictionaries can be sorted by passing a sorting function into the dictionary's `sorted(by:)` method.
- For-in loops can be used to iterate through the _key: value_ pairs of a dictionary
- Each pair is presented as a tuple and can be destructured like other tuples to assign each element to a name. For example, to print out the address book, on can write:
- Each pair is presented as a tuple and can be destructured like other tuples to assign each element to a name. For example, to print out the address book, one can write:

```swift
for (name, address) in addresses {
print("\(name) lives at \(address)")
}

// prints out:
// Betty Cooper lives at 111 Queens Ave.
// The Munsters lives at 1313 Mockingbird Lane
// The Simpsons lives at 742 Evergreen Terrace
// Buffy Summers lives at 1630 Revello Drive
```

[The other methods][dictionary-docs] available for working with dictionaries can be seen in the Apple Swift API documentation.

Expand Down
2 changes: 1 addition & 1 deletion concepts/dictionaries/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Dictionary literals are written as a series of `key: value` pairs, separated by
```swift
var addresses: Dictionary<String, String> = ["The Munsters": "1313 Mockingbird Lane", "The Simpsons": "742 Evergreen Terrace", "Buffy Summers": "1630 Revello Drive"]
var sequences: [String: [Int]] = ["Euler's totient": [1, 1, 2, 2, 4, 2, 6, 4], "Lazy caterer": [1, 2, 4, 7, 11, 16, 22, 29, 37], "Carmichael": [561, 1105, 1729, 2465, 2821, 6601, 8911, 10585, 15841]]
let constants = ["pi": 3.14159, "e": 2.71828, "phi": 1.618033, "avogadro": 6.02214076e22]
let constants = ["pi": 3.14159, "e": 2.71828, "phi": 1.618033, "avogadro": 6.02214076e23]
var emptyDict1: [Int: Int] = [:]
var emptyDict2 = [Character: String]()
var emptyDict3 = Dictionary<Int, Double>()
Expand Down
2 changes: 1 addition & 1 deletion concepts/enumerations/about.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ enum NESButton {
}
```

This defines a new type named `NESButtons` with possible values `up`, `down`, `left`, `right`, `a`, `b`, `select`, and `start`. These values can be referred to by following the name of the type with a dot (`.`) and the value. In cases where the type name can be inferred, only the dot and value are needed. These values can then be used like any other values in Swift.
This defines a new type named `NESButton` with possible values `up`, `down`, `left`, `right`, `a`, `b`, `select`, and `start`. These values can be referred to by following the name of the type with a dot (`.`) and the value. In cases where the type name can be inferred, only the dot and value are needed. These values can then be used like any other values in Swift.

```swift
var lastPressed = NESButton.up
Expand Down
2 changes: 1 addition & 1 deletion concepts/enumerations/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ enum NESButton {
}
```

This defines a new type named `NESButtons` with possible values `up`, `down`, `left`, `right`, `a`, `b`, `select`, and `start`. These values can be referred to by following the name of the type with a dot (`.`) and the value. In cases where the type name can be inferred, only the dot and value are needed.
This defines a new type named `NESButton` with possible values `up`, `down`, `left`, `right`, `a`, `b`, `select`, and `start`. These values can be referred to by following the name of the type with a dot (`.`) and the value. In cases where the type name can be inferred, only the dot and value are needed.

## Methods

Expand Down
Loading

0 comments on commit d44eb86

Please sign in to comment.