-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Starts docs and exercises, implement verify-exercises
- Loading branch information
Showing
24 changed files
with
271 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,13 @@ | ||
# About | ||
|
||
<!-- TODO: write document | ||
Roc is a modern, fast, and safe programming language designed for building reliable software with simplicity in mind. With an emphasis on performance and minimalism, Roc brings a fresh perspective to the world of functional programming, aiming to make it accessible and efficient for developers. | ||
|
||
This document contains a short introduction to the language. | ||
## Main Features | ||
|
||
The introduction should be relatively brief and touch upon what | ||
makes the language interesting (and possibly unique). The goal | ||
is to help students decide if they want to join this track. | ||
- **Simplicity and Safety**: Roc is designed to reduce common programming errors through its type system and by enforcing immutability by default, which leads to more predictable and maintainable code. | ||
- **Optimized Performance**: Roc's compiler is built to generate highly optimized machine code, ensuring that applications run fast and efficiently. | ||
- **No Nonsense Dependencies**: Roc encourages simplicity not just in code, but also in dependency management, aiming for minimal external dependencies. | ||
- **Clean Syntax**: Roc's syntax is straightforward and easy to read, drawing inspiration from modern functional languages while stripping away unnecessary complexity. | ||
- **Interoperability**: Roc is built to work well with other languages, making it easier to integrate into existing projects. | ||
|
||
The contents of this document are displayed on the track page, | ||
provided the student has not joined the track. | ||
See https://exercism.org/docs/building/tracks/docs for more information. --> | ||
For more details, visit [roc-lang.org](https://roc-lang.org). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,3 @@ | ||
# Installation | ||
|
||
<!-- TODO: write document | ||
This document should describe what the student needs to install | ||
to allow working on the track on their local system using the CLI. | ||
You can include the installation instructions in this document, but | ||
usually it is better to link to a resource with the official installation | ||
instructions, to prevent the instructions from becoming outdated. | ||
The contents of this document are displayed on the track's documentation | ||
page at `https://exercism.org/docs/tracks/<track>/installation`. | ||
See https://exercism.org/docs/building/tracks/docs for more information. --> | ||
To install Roc, please follow the instructions at [roc-lang.org/install](https://roc-lang.org/install). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,7 @@ | ||
# Learning | ||
|
||
<!-- TODO: write document | ||
- The [Roc tutorial](https://www.roc-lang.org/tutorial) is a good place to start. | ||
- You can then go through the [code examples](https://www.roc-lang.org/examples). | ||
- Then you will want to get your hands dirty! Go through the Exercism practice exercises in this Roc track. | ||
|
||
This document should link to learning resources. | ||
Feel free to link to any good learning resources you know, whether they | ||
be websites, blogs, books, videos or courses. | ||
The contents of this document are displayed on the track's documentation | ||
page at `https://exercism.org/docs/tracks/<track>/learning`. | ||
See https://exercism.org/docs/building/tracks/docs for more information. --> | ||
Have fun learning Roc! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,6 @@ | ||
# Resources | ||
|
||
<!-- TODO: write document | ||
This document should link to useful resources. | ||
Feel free to link to any good resources you know, whether they | ||
be websites, videos, mailing lists, etc. | ||
The contents of this document are displayed on the track's documentation | ||
page at `https://exercism.org/docs/tracks/<track>/resources`. | ||
See https://exercism.org/docs/building/tracks/docs for more information. --> | ||
- Official website: https://www.roc-lang.org/ | ||
- Code examples: https://www.roc-lang.org/examples | ||
- Community: https://www.roc-lang.org/community | ||
- Github: https://github.com/roc-lang/roc/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,17 @@ | ||
TODO: add snippet | ||
main = | ||
Path.fromStr "url.txt" | ||
|> storeEmail | ||
|> Task.onErr handleErr | ||
|
||
storeEmail = \path -> | ||
url = File.readUtf8! path | ||
user = Http.get! url Json.utf8 | ||
dest = Path.fromStr "$(user.name).txt" | ||
File.writeUtf8! dest user.email | ||
Stdout.line! "Wrote email to $(Path.display dest)" | ||
|
||
handleErr = \err -> | ||
when err is | ||
HttpErr url _ -> Stderr.line! "Error fetching URL $(url)" | ||
FileReadErr path _ -> Stderr.line! "Error reading from $(Path.display path)" | ||
FileWriteErr path _ -> Stderr.line! "Error writing to $(Path.display path)" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,5 @@ | ||
# Tests | ||
|
||
<!-- TODO: write document | ||
Roc comes with its own integrated test tools, no need to install anything else. | ||
|
||
This document should describe everything related to running tests in the track. | ||
If your track uses skipped tests, this document can explain why thet is used and | ||
how to unskip tests. | ||
This document can also link to the testing framework documentation. | ||
The contents of this document are displayed on the track's documentation | ||
page at `https://exercism.org/docs/tracks/<track>/tests`. | ||
See https://exercism.org/docs/building/tracks/docs for more information. --> | ||
To test your solution to an exercise, open a terminal, go to the exercise directory, run `roc test <exercise-name>-test.roc`, for example `roc test hello-world-test.roc`, and ensure that all the tests pass. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Instructions append | ||
|
||
The file to edit is named `HelloWorld.roc`. | ||
|
||
If you are using the command line, run the test suite using `roc test hello-world-test.roc` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Instructions | ||
|
||
The classical introductory exercise. | ||
Just say "Hello, World!". | ||
|
||
["Hello, World!"][hello-world] is the traditional first program for beginning programming in a new language or environment. | ||
|
||
The objectives are simple: | ||
|
||
- Modify the provided code so that it produces the string "Hello, World!". | ||
- Run the test suite and make sure that it succeeds. | ||
- Submit your solution and check it at the website. | ||
|
||
If everything goes well, you will be ready to fetch your first real exercise. | ||
|
||
[hello-world]: https://en.wikipedia.org/wiki/%22Hello,_world!%22_program |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module [hello] | ||
|
||
hello = "Hello, World!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"authors": [ | ||
"ageron" | ||
], | ||
"contributors": [ | ||
"keiravillekode" | ||
], | ||
"files": { | ||
"solution": [ | ||
"HelloWorld.roc" | ||
], | ||
"test": [ | ||
"hello-world-test.roc" | ||
], | ||
"example": [ | ||
".meta/Example.roc" | ||
] | ||
}, | ||
"blurb": "Exercism's classic introductory exercise. Just say \"Hello, World!\".", | ||
"source": "This is an exercise to introduce users to using Exercism", | ||
"source_url": "https://en.wikipedia.org/wiki/%22Hello,_world!%22_program" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# This is an auto-generated file. | ||
# | ||
# Regenerating this file via `configlet sync` will: | ||
# - Recreate every `description` key/value pair | ||
# - Recreate every `reimplements` key/value pair, where they exist in problem-specifications | ||
# - Remove any `include = true` key/value pair (an omitted `include` key implies inclusion) | ||
# - Preserve any other key/value pair | ||
# | ||
# As user-added comments (using the # character) will be removed when this file | ||
# is regenerated, comments can be added via a `comment` key. | ||
|
||
[af9ffe10-dc13-42d8-a742-e7bdafac449d] | ||
description = "Say Hi!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module [hello] | ||
|
||
hello = "Goodbye, Mars!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
app [main] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.12.0/Lb8EgiejTUzbggO2HVVuPJFkwvvsfW6LojkLR20kTVE.tar.br" } | ||
|
||
import pf.Task exposing [Task] | ||
import HelloWorld exposing [hello] | ||
|
||
expect hello == "Hello, World!" | ||
|
||
main = | ||
Task.ok {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Instructions | ||
|
||
Your task is to determine whether a given year is a leap year. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Introduction | ||
|
||
A leap year (in the Gregorian calendar) occurs: | ||
|
||
- In every year that is evenly divisible by 4. | ||
- Unless the year is evenly divisible by 100, in which case it's only a leap year if the year is also evenly divisible by 400. | ||
|
||
Some examples: | ||
|
||
- 1997 was not a leap year as it's not divisible by 4. | ||
- 1900 was not a leap year as it's not divisible by 400. | ||
- 2000 was a leap year! | ||
|
||
~~~~exercism/note | ||
For a delightful, four-minute explanation of the whole phenomenon of leap years, check out [this YouTube video](https://www.youtube.com/watch?v=xX96xng7sAE). | ||
~~~~ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module [isLeapYear] | ||
|
||
isLeapYear = \year -> | ||
(year % 4 == 0) && (year % 400 == 0 || year % 100 != 0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"authors": ["ageron"], | ||
"files": { | ||
"solution": ["Leap.roc"], | ||
"test": ["leap-test.roc"], | ||
"example": [".meta/Example.roc"] | ||
}, | ||
"blurb": "Determine whether a given year is a leap year.", | ||
"source": "CodeRanch Cattle Drive, Assignment 3", | ||
"source_url": "https://coderanch.com/t/718816/Leap" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# This is an auto-generated file. | ||
# | ||
# Regenerating this file via `configlet sync` will: | ||
# - Recreate every `description` key/value pair | ||
# - Recreate every `reimplements` key/value pair, where they exist in problem-specifications | ||
# - Remove any `include = true` key/value pair (an omitted `include` key implies inclusion) | ||
# - Preserve any other key/value pair | ||
# | ||
# As user-added comments (using the # character) will be removed when this file | ||
# is regenerated, comments can be added via a `comment` key. | ||
|
||
[6466b30d-519c-438e-935d-388224ab5223] | ||
description = "year not divisible by 4 in common year" | ||
|
||
[ac227e82-ee82-4a09-9eb6-4f84331ffdb0] | ||
description = "year divisible by 2, not divisible by 4 in common year" | ||
|
||
[4fe9b84c-8e65-489e-970b-856d60b8b78e] | ||
description = "year divisible by 4, not divisible by 100 in leap year" | ||
|
||
[7fc6aed7-e63c-48f5-ae05-5fe182f60a5d] | ||
description = "year divisible by 4 and 5 is still a leap year" | ||
|
||
[78a7848f-9667-4192-ae53-87b30c9a02dd] | ||
description = "year divisible by 100, not divisible by 400 in common year" | ||
|
||
[9d70f938-537c-40a6-ba19-f50739ce8bac] | ||
description = "year divisible by 100 but not by 3 is still not a leap year" | ||
|
||
[42ee56ad-d3e6-48f1-8e3f-c84078d916fc] | ||
description = "year divisible by 400 is leap year" | ||
|
||
[57902c77-6fe9-40de-8302-587b5c27121e] | ||
description = "year divisible by 400 but not by 125 is still a leap year" | ||
|
||
[c30331f6-f9f6-4881-ad38-8ca8c12520c1] | ||
description = "year divisible by 200, not divisible by 400 in common year" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module [isLeapYear] | ||
|
||
isLeapYear = \year -> | ||
year > 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
app [main] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.12.0/Lb8EgiejTUzbggO2HVVuPJFkwvvsfW6LojkLR20kTVE.tar.br" } | ||
|
||
import pf.Task exposing [Task] | ||
import Leap exposing [isLeapYear] | ||
|
||
# year not divisible by 4 in common year | ||
expect !(isLeapYear 2015) | ||
# year divisible by 2, not divisible by 4 in common year | ||
expect !(isLeapYear 1970) | ||
# year divisible by 4, not divisible by 100 in leap year | ||
expect isLeapYear 1996 | ||
# year divisible by 4 and 5 is still a leap year | ||
expect isLeapYear 1960 | ||
# year divisible by 100, not divisible by 400 in common year | ||
expect !(isLeapYear 2100) | ||
# year divisible by 100 but not by 3 is still not a leap year | ||
expect !(isLeapYear 1900) | ||
# year divisible by 400 is leap year | ||
expect isLeapYear 2000 | ||
# year divisible by 400 but not by 125 is still a leap year | ||
expect isLeapYear 2400 | ||
# year divisible by 200, not divisible by 400 in common year | ||
expect !(isLeapYear 1800) | ||
|
||
main = | ||
Task.ok {} |
Oops, something went wrong.