Skip to content

Commit

Permalink
Merge branch 'main' into add-symbols
Browse files Browse the repository at this point in the history
  • Loading branch information
meatball133 authored Aug 7, 2024
2 parents cdf9dac + dd1f89b commit 138cb04
Show file tree
Hide file tree
Showing 92 changed files with 1,978 additions and 421 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/doc-generator.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ jobs:
- name: Install Crystal
uses: crystal-lang/install-crystal@cdf26dcd488490c9939e9d4d62cab169c9e4f20d
with:
crystal: "1.12.1"
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29
crystal: "1.13.1"
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
- name: Run generator tests
run: crystal spec ./document-generator/spec/*
comment_on_failed_test:
Expand All @@ -26,8 +26,8 @@ jobs:
- name: Install Crystal
uses: crystal-lang/install-crystal@cdf26dcd488490c9939e9d4d62cab169c9e4f20d
with:
crystal: "1.12.1"
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29
crystal: "1.13.1"
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
- name: Run generator tests
run: crystal document-generator/scripts/check_docs.cr
- name: Comment on PR if test failed
Expand Down
16 changes: 8 additions & 8 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ jobs:
container:
image: crystallang/crystal
steps:
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
- name: Run generator tests
run: crystal spec test-generator/spec/*
run: crystal spec test-generator
test-generator-templates:
name: Check Generator Templates
runs-on: ubuntu-22.04
container:
image: crystallang/crystal
steps:
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
- name: Check generator templates tests
run: ./bin/test_specs
template:
Expand All @@ -33,7 +33,7 @@ jobs:
container:
image: crystallang/crystal
steps:
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
- name: Run file formatting
run: crystal ./bin/check-format.cr
exercises:
Expand All @@ -42,11 +42,11 @@ jobs:
strategy:
# Allows running the job multiple times with different configurations
matrix:
crystal: ["1.8", "1.9", "1.10", "1.11", "1.12.1"]
crystal: ["1.9", "1.10", "1.11", "1.12", "1.13.1"]
container:
image: crystallang/crystal:${{ matrix.crystal }}
steps:
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
- name: Install jq
run: apt-get update && apt-get install -y jq
- name: Run tests
Expand All @@ -58,9 +58,9 @@ jobs:
- name: Install Crystal
uses: crystal-lang/install-crystal@cdf26dcd488490c9939e9d4d62cab169c9e4f20d
with:
crystal: "1.12.1"
crystal: "1.13.1"
- name: 'Setup jq'
run: choco install jq
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
- name: Run tests
run: ./bin/test-exercises.ps1
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<p vertical-align="middle"><h1>Exercism Crystal Track</h1></p>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[![Discourse topics](https://img.shields.io/discourse/topics?color=8A08E6&label=Connect%20&labelColor=FFDF58&logo=Discourse&logoColor=8A08E6&server=https%3A%2F%2Fforum.exercism.org&style=social)](https://forum.exercism.org)
&nbsp;[![Exercism_II](https://img.shields.io/badge/Exercism--Built-9101FF?logo=crystal&logoColor=000000&labelColor=E5E5E5&label=Crystal%201.12.1%20Powered)](https://exercism.org)
&nbsp;[![Exercism_II](https://img.shields.io/badge/Exercism--Built-9101FF?logo=crystal&logoColor=000000&labelColor=E5E5E5&label=Crystal%201.13.2%20Powered)](https://exercism.org)
&nbsp;[![Exercism_III](https://img.shields.io/badge/Open-11b30e?labelColor=3D454D&label=Contributions)](https://exercism.org/blog/freeing-our-maintainers) &nbsp;[![Build Status](https://github.com/exercism/crystal/workflows/Tests/badge.svg)](https://github.com/exercism/crystal/actions/workflows/tests.yml)

<br>
Expand All @@ -16,7 +16,7 @@ Hi. &nbsp;👋🏽 &nbsp;👋 &nbsp;**We are happy you are here.**&nbsp; 🎉&nb
**`exercism/Crystal`** is one of many programming language tracks on [exercism(dot)org][exercism-website].
This repo holds all the instructions, tests, code, & support files for Crystal _exercises_ currently under development or implemented & available for students.

🌟 &nbsp;&nbsp;Track tooling (_test-runner, representer, analyzer, and Continuous Integration_) runs on Crystal `1.12.1`. <br>
🌟 &nbsp;&nbsp;Track tooling (_test-runner, representer, analyzer, and Continuous Integration_) runs on Crystal `1.13.2`. <br>
🌟 &nbsp;&nbsp;Most exercises are solvable with Crystal `1.0.0` or higher.

This track is made up of **Practice Exercises**. Practice exercises are open-ended, and can be used to practice concepts learned, try out new techniques, and play.
Expand Down
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
30 changes: 15 additions & 15 deletions concepts/char/about.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# Char

`Char` is a data type in Crystal that represents a 32-bit [Unicode][unicode] code point.
Their size makes so they are memory efficient, and also gives it certain properties that Strings don't have.
They are created using single quotes (`'`) and do only allow for one Unicode code point to be placed inside.
`Char` is a data type in Crystal representing a 32-bit [Unicode][unicode] code point.
Their size makes them memory efficient and gives them specific properties that Strings doesn't have.
They are created using single quotes (`'`) and only allow one Unicode code point to be placed inside.

```crystal
'a' # => 'a'
'a'.class # => Char
```

When working with Strings in Crystal is it quite common to work with Chars, since quite a few methods in the String class return Chars or takes Chars as arguments.
It is quite common to work with Chars when working with Strings in Crystal since quite a few methods in the String class return Chars or take Chars as arguments.
For example, the [`String#[]`][index] method returns a Char, or the [`String#chars`][chars] method returns a collection of Chars.

## Incrementing / Decrementing
Expand All @@ -24,7 +24,7 @@ Due to char being a 32 Unicode point do they support incrementing and decrementi
# => 'a'
```

There is also a method called [`Char#succ`][succ] which will return the next char in the Unicode table and [`Char#pred`][pred] which will return the previous char in the Unicode table.
There is also a method called [`Char#succ`][succ], which returns the next char in the Unicode table, and [`Char#pred`][pred], which returns the previous char in the Unicode table.

```crystal
'a'.succ
Expand All @@ -36,8 +36,8 @@ There is also a method called [`Char#succ`][succ] which will return the next cha

## concatenation

Since Chars is only meant to represent a 32-bit Unicode, can't 2 chars be concatenation.
Thereby Chars can only be concatenated with Strings.
Since Chars is only meant to represent a 32-bit Unicode, two chars can't be concatenated.
Therefore, Chars can only be concatenated with Strings.

```Crystal
'a' + "bc"
Expand All @@ -49,23 +49,23 @@ Thereby Chars can only be concatenated with Strings.

## Properties methods

Crystal has a few methods that can be used to get information about a Char, like if it is a number or a letter, or if it is uppercase or lowercase.
Here is a list of some of the methods, for a full list see the [Char API][char-api]:
Crystal has a few methods for getting information about a Character, such as whether it is a number or a letter or whether it is uppercase or lowercase.
Here is a list of some of the methods, for a complete list see the [Char API][char-api]:

| Method | Description |
| -------------------------------- | ---------------------------------------------------- |
| [`Char#number?`][number] | Returns `true` if the Char is a number |
| [`Char#letter?`][letter] | Returns `true` if the Char is a letter |
| [`Char#lowercase?`][lowercase] | Returns `true` if the Char is lowercase |
| [`Char#uppercase?`][uppercase] | Returns `true` if the Char is uppercase |
| [`Char#ascii?`][ascii] | Returns `true` if the Char is an ASCII character |
| [`Char#ascii?`][ascii] | Returns `true` if the Char is an ASCII character |
| [`Char#whitespace?`][whitespace] | Returns `true` if the Char is a whitespace character |

## Converting

### Converting between code points and Chars

Since Chars is a 32-bit Unicode point, so can you convert between Chars and code points (Int).
Since Chars is a 32-bit Unicode point, can you convert between Chars and code points (Int).
This can be done using the [`Char#ord`][ord] method which will return the code point of the Char, or the [`Int#chr`][chr] method which will return the Char of the code point.

```crystal
Expand All @@ -78,8 +78,8 @@ This can be done using the [`Char#ord`][ord] method which will return the code p

### Converting between types

As with other data types so does Chars have a few methods that can be used to convert between types.
The most common one is the `Char#to_s` method which will convert the Char to a String, but there is also the `Char#to_i` method which will convert the Char to an Int, And the `Char#to_f` method which will convert the Char to a Float.
As with other data types, chars have a few methods for converting between types.
The most common one is the `Char#to_s` method, which converts the Char to a String. However, there is also the `Char#to_i` method, which converts the Char to an Int, and the `Char#to_f` method, which converts the Char to a Float.

```crystal
'a'.to_s
Expand All @@ -94,8 +94,8 @@ The most common one is the `Char#to_s` method which will convert the Char to a S

## Escaping

As with Strings are certain characters that can't be written directly, and to write them you need to escape them.
To write an escape sequence you can use the `\` character followed by the character you want to escape.
As with Strings, there are certain characters that can't be written directly, and to write them, you need to escape them.
You can use the `\` character to write an escape sequence followed by the character you want to escape.

These are the special characters in Crystal:

Expand Down
26 changes: 13 additions & 13 deletions concepts/char/introduction.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# Char

`Char` is a data type in Crystal that represents a 32-bit [Unicode][unicode] code point.
Their size makes so they are memory efficient, and also gives it certain properties that Strings don't have.
They are created using single quotes (`'`) and do only allow for one Unicode code point to be placed inside.
`Char` is a data type in Crystal representing a 32-bit [Unicode][unicode] code point.
Their size makes them memory efficient and gives them specific properties that Strings doesn't have.
They are created using single quotes (`'`) and only allow one Unicode code point to be placed inside.

```crystal
'a' # => 'a'
'a'.class # => Char
```

When working with Strings in Crystal is it quite common to work with Chars, since quite a few methods in the String class return Chars or takes Chars as arguments.
It is quite common to work with Chars when working with Strings in Crystal since quite a few methods in the String class return Chars or take Chars as arguments.
For example, the [`String#[]`][index] method returns a Char, or the [`String#chars`][chars] method returns a collection of Chars.

## Incrementing / Decrementing
Expand All @@ -24,7 +24,7 @@ Due to char being a 32 Unicode point do they support incrementing and decrementi
# => 'a'
```

There is also a method called [`Char#succ`][succ] which will return the next char in the Unicode table and [`Char#pred`][pred] which will return the previous char in the Unicode table.
There is also a method called [`Char#succ`][succ], which returns the next char in the Unicode table, and [`Char#pred`][pred], which returns the previous char in the Unicode table.

```crystal
'a'.succ
Expand All @@ -36,8 +36,8 @@ There is also a method called [`Char#succ`][succ] which will return the next cha

## concatenation

Since Chars is only meant to represent a 32-bit Unicode, can't 2 chars be concatenation.
Thereby Chars can only be concatenated with Strings.
Since Chars is only meant to represent a 32-bit Unicode, two chars can't be concatenated.
Therefore, Chars can only be concatenated with Strings.

```Crystal
'a' + "bc"
Expand All @@ -49,23 +49,23 @@ Thereby Chars can only be concatenated with Strings.

## Properties methods

Crystal has a few methods that can be used to get information about a Char, like if it is a number or a letter, or if it is uppercase or lowercase.
Here is a list of some of the methods, for a full list see the [Char API][char-api]:
Crystal has a few methods for getting information about a Character, such as whether it is a number or a letter or whether it is uppercase or lowercase.
Here is a list of some of the methods, for a complete list see the [Char API][char-api]:

| Method | Description |
| -------------------------------- | ---------------------------------------------------- |
| [`Char#number?`][number] | Returns `true` if the Char is a number |
| [`Char#letter?`][letter] | Returns `true` if the Char is a letter |
| [`Char#lowercase?`][lowercase] | Returns `true` if the Char is lowercase |
| [`Char#uppercase?`][uppercase] | Returns `true` if the Char is uppercase |
| [`Char#ascii?`][ascii] | Returns `true` if the Char is an ASCII character |
| [`Char#ascii?`][ascii] | Returns `true` if the Char is an ASCII character |
| [`Char#whitespace?`][whitespace] | Returns `true` if the Char is a whitespace character |

## Converting

### Converting between code points and Chars

Since Chars is a 32-bit Unicode point, so can you convert between Chars and code points (Int).
Since Chars is a 32-bit Unicode point, can you convert between Chars and code points (Int).
This can be done using the [`Char#ord`][ord] method which will return the code point of the Char, or the [`Int#chr`][chr] method which will return the Char of the code point.

```crystal
Expand All @@ -78,8 +78,8 @@ This can be done using the [`Char#ord`][ord] method which will return the code p

### Converting between types

As with other data types so does Chars have a few methods that can be used to convert between types.
The most common one is the `Char#to_s` method which will convert the Char to a String, but there is also the `Char#to_i` method which will convert the Char to an Int, And the `Char#to_f` method which will convert the Char to a Float.
As with other data types, chars have a few methods for converting between types.
The most common one is the `Char#to_s` method, which converts the Char to a String. However, there is also the `Char#to_i` method, which converts the Char to an Int, and the `Char#to_f` method, which converts the Char to a Float.

```crystal
'a'.to_s
Expand Down
5 changes: 5 additions & 0 deletions concepts/iteration/.meta/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"blurb": "Iteration refers to the process of repeating a set of instructions. Crystal has various methods to iterate over collections, ranges, and other data structures.",
"authors": ["meatball133"],
"contributors": ["ryanplusplus"]
}
1 change: 1 addition & 0 deletions concepts/iteration/.meta/template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{% $iteration \ $iteration.Shorthand %}
Loading

0 comments on commit 138cb04

Please sign in to comment.