From c3efb37169d74512bcc19eacba346a83b6b82eaf Mon Sep 17 00:00:00 2001 From: Anton-4 <17049058+Anton-4@users.noreply.github.com> Date: Sat, 26 Jul 2025 14:23:47 +0200 Subject: [PATCH 1/8] configlet sync --update --- exercises/practice/bob/.meta/tests.toml | 5 +++++ .../practice/crypto-square/.meta/tests.toml | 5 +++++ .../practice/flatten-array/.meta/tests.toml | 20 +++++++++++++++++++ exercises/practice/forth/.meta/tests.toml | 19 +++++++++++++++++- .../largest-series-product/.meta/tests.toml | 12 ++++++++++- exercises/practice/pig-latin/.meta/tests.toml | 3 +++ .../variable-length-quantity/.meta/tests.toml | 15 ++++++++++++++ exercises/practice/wordy/.meta/tests.toml | 12 +++++++++++ 8 files changed, 89 insertions(+), 2 deletions(-) diff --git a/exercises/practice/bob/.meta/tests.toml b/exercises/practice/bob/.meta/tests.toml index ea47d6bb..5299e289 100644 --- a/exercises/practice/bob/.meta/tests.toml +++ b/exercises/practice/bob/.meta/tests.toml @@ -71,6 +71,7 @@ description = "alternate silence" [66953780-165b-4e7e-8ce3-4bcb80b6385a] description = "multiple line question" +include = false [5371ef75-d9ea-4103-bcfa-2da973ddec1b] description = "starting with whitespace" @@ -83,3 +84,7 @@ description = "other whitespace" [12983553-8601-46a8-92fa-fcaa3bc4a2a0] description = "non-question ending with whitespace" + +[2c7278ac-f955-4eb4-bf8f-e33eb4116a15] +description = "multiple line question" +reimplements = "66953780-165b-4e7e-8ce3-4bcb80b6385a" diff --git a/exercises/practice/crypto-square/.meta/tests.toml b/exercises/practice/crypto-square/.meta/tests.toml index 085d142e..94ef0819 100644 --- a/exercises/practice/crypto-square/.meta/tests.toml +++ b/exercises/practice/crypto-square/.meta/tests.toml @@ -32,3 +32,8 @@ description = "8 character plaintext results in 3 chunks, the last one with a tr [fbcb0c6d-4c39-4a31-83f6-c473baa6af80] description = "54 character plaintext results in 7 chunks, the last two with trailing spaces" +include = false + +[33fd914e-fa44-445b-8f38-ff8fbc9fe6e6] +description = "54 character plaintext results in 8 chunks, the last two with trailing spaces" +reimplements = "fbcb0c6d-4c39-4a31-83f6-c473baa6af80" diff --git a/exercises/practice/flatten-array/.meta/tests.toml b/exercises/practice/flatten-array/.meta/tests.toml index 6300219d..44acf175 100644 --- a/exercises/practice/flatten-array/.meta/tests.toml +++ b/exercises/practice/flatten-array/.meta/tests.toml @@ -32,12 +32,32 @@ description = "null values are omitted from the final result" [c6cf26de-8ccd-4410-84bd-b9efd88fd2bc] description = "consecutive null values at the front of the list are omitted from the final result" +include = false + +[bc72da10-5f55-4ada-baf3-50e4da02ec8e] +description = "consecutive null values at the front of the array are omitted from the final result" +reimplements = "c6cf26de-8ccd-4410-84bd-b9efd88fd2bc" [382c5242-587e-4577-b8ce-a5fb51e385a1] description = "consecutive null values in the middle of the list are omitted from the final result" +include = false + +[6991836d-0d9b-4703-80a0-3f1f23eb5981] +description = "consecutive null values in the middle of the array are omitted from the final result" +reimplements = "382c5242-587e-4577-b8ce-a5fb51e385a1" [ef1d4790-1b1e-4939-a179-51ace0829dbd] description = "6 level nest list with null values" +include = false + +[dc90a09c-5376-449c-a7b3-c2d20d540069] +description = "6 level nested array with null values" +reimplements = "ef1d4790-1b1e-4939-a179-51ace0829dbd" [85721643-705a-4150-93ab-7ae398e2942d] description = "all values in nested list are null" +include = false + +[51f5d9af-8f7f-4fb5-a156-69e8282cb275] +description = "all values in nested array are null" +reimplements = "85721643-705a-4150-93ab-7ae398e2942d" diff --git a/exercises/practice/forth/.meta/tests.toml b/exercises/practice/forth/.meta/tests.toml index cd443c7a..af25f3de 100644 --- a/exercises/practice/forth/.meta/tests.toml +++ b/exercises/practice/forth/.meta/tests.toml @@ -24,6 +24,9 @@ description = "addition -> errors if there is nothing on the stack" [06efb9a4-817a-435e-b509-06166993c1b8] description = "addition -> errors if there is only one value on the stack" +[1e07a098-c5fa-4c66-97b2-3c81205dbc2f] +description = "addition -> more than two values on the stack" + [09687c99-7bbc-44af-8526-e402f997ccbf] description = "subtraction -> can subtract two numbers" @@ -33,6 +36,9 @@ description = "subtraction -> errors if there is nothing on the stack" [b3cee1b2-9159-418a-b00d-a1bb3765c23b] description = "subtraction -> errors if there is only one value on the stack" +[2c8cc5ed-da97-4cb1-8b98-fa7b526644f4] +description = "subtraction -> more than two values on the stack" + [5df0ceb5-922e-401f-974d-8287427dbf21] description = "multiplication -> can multiply two numbers" @@ -42,6 +48,9 @@ description = "multiplication -> errors if there is nothing on the stack" [8ba4b432-9f94-41e0-8fae-3b3712bd51b3] description = "multiplication -> errors if there is only one value on the stack" +[5cd085b5-deb1-43cc-9c17-6b1c38bc9970] +description = "multiplication -> more than two values on the stack" + [e74c2204-b057-4cff-9aa9-31c7c97a93f5] description = "division -> can divide two numbers" @@ -57,12 +66,21 @@ description = "division -> errors if there is nothing on the stack" [d5547f43-c2ff-4d5c-9cb0-2a4f6684c20d] description = "division -> errors if there is only one value on the stack" +[f224f3e0-b6b6-4864-81de-9769ecefa03f] +description = "division -> more than two values on the stack" + [ee28d729-6692-4a30-b9be-0d830c52a68c] description = "combined arithmetic -> addition and subtraction" [40b197da-fa4b-4aca-a50b-f000d19422c1] description = "combined arithmetic -> multiplication and division" +[f749b540-53aa-458e-87ec-a70797eddbcb] +description = "combined arithmetic -> multiplication and addition" + +[c8e5a4c2-f9bf-4805-9a35-3c3314e4989a] +description = "combined arithmetic -> addition and multiplication" + [c5758235-6eef-4bf6-ab62-c878e50b9957] description = "dup -> copies a value on the stack" @@ -137,7 +155,6 @@ include = false [5180f261-89dd-491e-b230-62737e09806f] description = "user-defined words -> errors if executing a non-existent word" -# This case is not relevant for Roc because it is not stateful [3c8bfef3-edbb-49c1-9993-21d4030043cb] description = "user-defined words -> only defines locally" include = false diff --git a/exercises/practice/largest-series-product/.meta/tests.toml b/exercises/practice/largest-series-product/.meta/tests.toml index e7cfd095..e43d447f 100644 --- a/exercises/practice/largest-series-product/.meta/tests.toml +++ b/exercises/practice/largest-series-product/.meta/tests.toml @@ -38,6 +38,11 @@ description = "reports zero if all spans include zero" [5d81aaf7-4f67-4125-bf33-11493cc7eab7] description = "rejects span longer than string length" +include = false + +[0ae1ce53-d9ba-41bb-827f-2fceb64f058b] +description = "rejects span longer than string length" +reimplements = "5d81aaf7-4f67-4125-bf33-11493cc7eab7" [06bc8b90-0c51-4c54-ac22-3ec3893a079e] description = "reports 1 for empty string and empty product (0 span)" @@ -47,6 +52,11 @@ description = "reports 1 for nonempty string and empty product (0 span)" [6d96c691-4374-4404-80ee-2ea8f3613dd4] description = "rejects empty string and nonzero span" +include = false + +[6cf66098-a6af-4223-aab1-26aeeefc7402] +description = "rejects empty string and nonzero span" +reimplements = "6d96c691-4374-4404-80ee-2ea8f3613dd4" [7a38f2d6-3c35-45f6-8d6f-12e6e32d4d74] description = "rejects invalid character in digits" @@ -57,5 +67,5 @@ include = false [c859f34a-9bfe-4897-9c2f-6d7f8598e7f0] description = "rejects negative span" -reimplements = "5fe3c0e5-a945-49f2-b584-f0814b4dd1ef" include = false +reimplements = "5fe3c0e5-a945-49f2-b584-f0814b4dd1ef" diff --git a/exercises/practice/pig-latin/.meta/tests.toml b/exercises/practice/pig-latin/.meta/tests.toml index c29168c5..d524305b 100644 --- a/exercises/practice/pig-latin/.meta/tests.toml +++ b/exercises/practice/pig-latin/.meta/tests.toml @@ -39,6 +39,9 @@ description = "first letter and ay are moved to the end of words that start with [bce94a7a-a94e-4e2b-80f4-b2bb02e40f71] description = "first letter and ay are moved to the end of words that start with consonants -> word beginning with q without a following u" +[e59dbbe8-ccee-4619-a8e9-ce017489bfc0] +description = "first letter and ay are moved to the end of words that start with consonants -> word beginning with consonant and vowel containing qu" + [c01e049a-e3e2-451c-bf8e-e2abb7e438b8] description = "some letter clusters are treated like a single consonant -> word beginning with ch" diff --git a/exercises/practice/variable-length-quantity/.meta/tests.toml b/exercises/practice/variable-length-quantity/.meta/tests.toml index c9af549f..53be789a 100644 --- a/exercises/practice/variable-length-quantity/.meta/tests.toml +++ b/exercises/practice/variable-length-quantity/.meta/tests.toml @@ -15,6 +15,9 @@ description = "Encode a series of integers, producing a series of bytes. -> zero [be44d299-a151-4604-a10e-d4b867f41540] description = "Encode a series of integers, producing a series of bytes. -> arbitrary single byte" +[890bc344-cb80-45af-b316-6806a6971e81] +description = "Encode a series of integers, producing a series of bytes. -> asymmetric single byte" + [ea399615-d274-4af6-bbef-a1c23c9e1346] description = "Encode a series of integers, producing a series of bytes. -> largest single byte" @@ -24,6 +27,9 @@ description = "Encode a series of integers, producing a series of bytes. -> smal [63955a49-2690-4e22-a556-0040648d6b2d] description = "Encode a series of integers, producing a series of bytes. -> arbitrary double byte" +[4977d113-251b-4d10-a3ad-2f5a7756bb58] +description = "Encode a series of integers, producing a series of bytes. -> asymmetric double byte" + [29da7031-0067-43d3-83a7-4f14b29ed97a] description = "Encode a series of integers, producing a series of bytes. -> largest double byte" @@ -33,6 +39,9 @@ description = "Encode a series of integers, producing a series of bytes. -> smal [5df0bc2d-2a57-4300-a653-a75ee4bd0bee] description = "Encode a series of integers, producing a series of bytes. -> arbitrary triple byte" +[6731045f-1e00-4192-b5ae-98b22e17e9f7] +description = "Encode a series of integers, producing a series of bytes. -> asymmetric triple byte" + [f51d8539-312d-4db1-945c-250222c6aa22] description = "Encode a series of integers, producing a series of bytes. -> largest triple byte" @@ -42,6 +51,9 @@ description = "Encode a series of integers, producing a series of bytes. -> smal [11ed3469-a933-46f1-996f-2231e05d7bb6] description = "Encode a series of integers, producing a series of bytes. -> arbitrary quadruple byte" +[b45ef770-cbba-48c2-bd3c-c6362679516e] +description = "Encode a series of integers, producing a series of bytes. -> asymmetric quadruple byte" + [d5f3f3c3-e0f1-4e7f-aad0-18a44f223d1c] description = "Encode a series of integers, producing a series of bytes. -> largest quadruple byte" @@ -51,6 +63,9 @@ description = "Encode a series of integers, producing a series of bytes. -> smal [5f34ff12-2952-4669-95fe-2d11b693d331] description = "Encode a series of integers, producing a series of bytes. -> arbitrary quintuple byte" +[9be46731-7cd5-415c-b960-48061cbc1154] +description = "Encode a series of integers, producing a series of bytes. -> asymmetric quintuple byte" + [7489694b-88c3-4078-9864-6fe802411009] description = "Encode a series of integers, producing a series of bytes. -> maximum 32-bit integer input" diff --git a/exercises/practice/wordy/.meta/tests.toml b/exercises/practice/wordy/.meta/tests.toml index f812dfa9..a0a83ed0 100644 --- a/exercises/practice/wordy/.meta/tests.toml +++ b/exercises/practice/wordy/.meta/tests.toml @@ -12,9 +12,21 @@ [88bf4b28-0de3-4883-93c7-db1b14aa806e] description = "just a number" +[18983214-1dfc-4ebd-ac77-c110dde699ce] +description = "just a zero" + +[607c08ee-2241-4288-916d-dae5455c87e6] +description = "just a negative number" + [bb8c655c-cf42-4dfc-90e0-152fcfd8d4e0] description = "addition" +[bb9f2082-171c-46ad-ad4e-c3f72087c1b5] +description = "addition with a left hand zero" + +[6fa05f17-405a-4742-80ae-5d1a8edb0d5d] +description = "addition with a right hand zero" + [79e49e06-c5ae-40aa-a352-7a3a01f70015] description = "more addition" From 488e9c4b94542e0ff39304525cfaf412d3763a66 Mon Sep 17 00:00:00 2001 From: Anton-4 <17049058+Anton-4@users.noreply.github.com> Date: Sat, 26 Jul 2025 14:29:59 +0200 Subject: [PATCH 2/8] sync tests --- .../practice/accumulate/accumulate-test.roc | 49 +- exercises/practice/acronym/acronym-test.roc | 22 +- .../affine-cipher/affine-cipher-test.roc | 64 +- .../all-your-base/all-your-base-test.roc | 62 +- .../practice/allergies/allergies-test.roc | 124 +- .../practice/alphametics/alphametics-test.roc | 194 +-- exercises/practice/anagram/anagram-test.roc | 38 +- .../armstrong-numbers-test.roc | 22 +- .../atbash-cipher/atbash-cipher-test.roc | 32 +- .../binary-search-tree-test.roc | 138 +- .../binary-search/binary-search-test.roc | 48 +- exercises/practice/binary/binary-test.roc | 52 +- exercises/practice/bob/bob-test.roc | 62 +- exercises/practice/bowling/bowling-test.roc | 245 ++- exercises/practice/change/change-test.roc | 48 +- .../circular-buffer/circular-buffer-test.roc | 156 +- exercises/practice/clock/clock-test.roc | 192 +-- .../collatz-conjecture-test.roc | 24 +- .../complex-numbers/complex-numbers-test.roc | 166 +- exercises/practice/connect/connect-test.roc | 24 +- .../crypto-square/crypto-square-test.roc | 38 +- .../practice/custom-set/custom-set-test.roc | 264 +-- exercises/practice/darts/darts-test.roc | 30 +- exercises/practice/diamond/diamond-test.roc | 24 +- .../difference-of-squares-test.roc | 22 +- exercises/practice/dominoes/dominoes-test.roc | 79 +- .../practice/eliuds-eggs/eliuds-eggs-test.roc | 12 +- exercises/practice/etl/etl-test.roc | 154 +- .../flatten-array/flatten-array-test.roc | 357 ++-- .../flower-field/flower-field-test.roc | 2 +- .../practice/food-chain/food-chain-test.roc | 24 +- exercises/practice/forth/forth-test.roc | 245 +-- .../practice/gigasecond/gigasecond-test.roc | 14 +- .../practice/go-counting/go-counting-test.roc | 196 +-- exercises/practice/grains/grains-test.roc | 40 +- exercises/practice/grep/grep-test.roc | 140 +- exercises/practice/hamming/hamming-test.roc | 40 +- .../practice/hello-world/hello-world-test.roc | 4 +- .../practice/high-scores/high-scores-test.roc | 22 +- exercises/practice/house/house-test.roc | 32 +- .../isbn-verifier/isbn-verifier-test.roc | 42 +- exercises/practice/isogram/isogram-test.roc | 32 +- .../killer-sudoku-helper-test.roc | 30 +- .../kindergarten-garden-test.roc | 72 +- exercises/practice/knapsack/knapsack-test.roc | 18 +- .../largest-series-product-test.roc | 54 +- exercises/practice/leap/leap-test.roc | 22 +- exercises/practice/list-ops/list-ops-test.roc | 48 +- exercises/practice/luhn/luhn-test.roc | 48 +- .../matching-brackets-test.roc | 4 +- exercises/practice/matrix/matrix-test.roc | 36 +- exercises/practice/meetup/meetup-test.roc | 1524 ++++++++--------- .../practice/micro-blog/micro-blog-test.roc | 52 +- .../practice/minesweeper/minesweeper-test.roc | 76 +- .../practice/nth-prime/nth-prime-test.roc | 22 +- .../nucleotide-count-test.roc | 24 +- .../practice/ocr-numbers/ocr-numbers-test.roc | 68 +- .../palindrome-products-test.roc | 232 +-- exercises/practice/pangram/pangram-test.roc | 24 +- .../pascals-triangle-test.roc | 20 +- .../perfect-numbers/perfect-numbers-test.roc | 52 +- .../phone-number/phone-number-test.roc | 50 +- .../practice/pig-latin/pig-latin-test.roc | 53 +- exercises/practice/poker/poker-test.roc | 152 +- .../prime-factors/prime-factors-test.roc | 28 +- .../protein-translation-test.roc | 60 +- exercises/practice/proverb/proverb-test.roc | 16 +- .../pythagorean-triplet-test.roc | 92 +- .../queen-attack/queen-attack-test.roc | 128 +- .../rail-fence-cipher-test.roc | 28 +- .../practice/raindrops/raindrops-test.roc | 40 +- .../rational-numbers-test.roc | 176 +- .../practice/rectangles/rectangles-test.roc | 65 +- .../resistor-color-duo-test.roc | 16 +- .../resistor-color/resistor-color-test.roc | 16 +- exercises/practice/rest-api/rest-api-test.roc | 270 ++- .../reverse-string/reverse-string-test.roc | 22 +- .../rna-transcription-test.roc | 16 +- .../robot-simulator/robot-simulator-test.roc | 72 +- .../roman-numerals/roman-numerals-test.roc | 112 +- .../rotational-cipher-test.roc | 24 +- .../run-length-encoding-test.roc | 32 +- .../saddle-points/saddle-points-test.roc | 122 +- exercises/practice/say/say-test.roc | 74 +- .../scrabble-score/scrabble-score-test.roc | 26 +- .../secret-handshake-test.roc | 26 +- exercises/practice/series/series-test.roc | 24 +- .../practice/sgf-parsing/sgf-parsing-test.roc | 454 ++--- exercises/practice/sieve/sieve-test.roc | 14 +- .../practice/space-age/space-age-test.roc | 36 +- .../spiral-matrix/spiral-matrix-test.roc | 16 +- .../practice/square-root/square-root-test.roc | 16 +- exercises/practice/strain/strain-test.roc | 32 +- exercises/practice/sublist/sublist-test.roc | 40 +- .../sum-of-multiples-test.roc | 36 +- .../practice/tournament/tournament-test.roc | 85 +- .../practice/transpose/transpose-test.roc | 52 +- exercises/practice/triangle/triangle-test.roc | 46 +- .../practice/two-bucket/two-bucket-test.roc | 214 +-- exercises/practice/two-fer/two-fer-test.roc | 10 +- .../variable-length-quantity-test.roc | 103 +- .../practice/word-count/word-count-test.roc | 224 ++- .../practice/word-search/word-search-test.roc | 324 ++-- exercises/practice/wordy/wordy-test.roc | 116 +- exercises/practice/yacht/yacht-test.roc | 62 +- .../zebra-puzzle/zebra-puzzle-test.roc | 8 +- 106 files changed, 4492 insertions(+), 5137 deletions(-) diff --git a/exercises/practice/accumulate/accumulate-test.roc b/exercises/practice/accumulate/accumulate-test.roc index c1603de3..f33abb39 100644 --- a/exercises/practice/accumulate/accumulate-test.roc +++ b/exercises/practice/accumulate/accumulate-test.roc @@ -1,6 +1,6 @@ # These tests are auto-generated with test data from: # https://github.com/exercism/problem-specifications/tree/main/exercises/accumulate/canonical-data.json -# File last updated on 2025-01-04 +# File last updated on 2025-07-26 app [main!] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.19.0/Hj-J_zxz7V9YurCSTFcFdu6cQJie4guzsPMUi5kBYUk.tar.br", } @@ -8,63 +8,52 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line!("") + Stdout.line! "" import Accumulate exposing [accumulate] # accumulate empty expect - result = accumulate( - [], - |x| - x * x, - ) + result = accumulate [] |x| + x * x result == [] # accumulate squares expect - result = accumulate( - [1, 2, 3], - |x| - x * x, - ) + result = accumulate [1, 2, 3] |x| + x * x result == [1, 4, 9] # accumulate upcases expect - result = accumulate(["Hello", "world"], to_upper) + result = accumulate ["Hello", "world"] to_upper result == ["HELLO", "WORLD"] # accumulate reversed strings expect - result = accumulate(["the", "quick", "brown", "fox", "etc"], reverse) + result = accumulate ["the", "quick", "brown", "fox", "etc"] reverse result == ["eht", "kciuq", "nworb", "xof", "cte"] # accumulate recursively expect - result = accumulate( - ["a", "b", "c"], - |x| - accumulate(["1", "2", "3"], |y| Str.concat(x, y)), - ) + result = accumulate ["a", "b", "c"] |x| + accumulate ["1", "2", "3"] (|y| Str.concat x y) result == [["a1", "a2", "a3"], ["b1", "b2", "b3"], ["c1", "c2", "c3"]] reverse : Str -> Str reverse = |str| - Str.to_utf8(str) + Str.to_utf8 str |> List.reverse |> Str.from_utf8 - |> Result.with_default("") + |> Result.with_default "" to_upper : Str -> Str to_upper = |str| - Str.to_utf8(str) - |> List.map( - |byte| - if 'a' <= byte and byte <= 'z' then - byte - 'a' + 'A' - else - byte, - ) + Str.to_utf8 str + |> List.map |byte| + if 'a' <= byte and byte <= 'z' then + byte - 'a' + 'A' + else + byte |> Str.from_utf8 - |> Result.with_default("") + |> Result.with_default "" diff --git a/exercises/practice/acronym/acronym-test.roc b/exercises/practice/acronym/acronym-test.roc index 1355a401..1597c144 100644 --- a/exercises/practice/acronym/acronym-test.roc +++ b/exercises/practice/acronym/acronym-test.roc @@ -1,6 +1,6 @@ # These tests are auto-generated with test data from: # https://github.com/exercism/problem-specifications/tree/main/exercises/acronym/canonical-data.json -# File last updated on 2025-01-04 +# File last updated on 2025-07-26 app [main!] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.19.0/Hj-J_zxz7V9YurCSTFcFdu6cQJie4guzsPMUi5kBYUk.tar.br", } @@ -8,52 +8,52 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line!("") + Stdout.line! "" import Acronym exposing [abbreviate] # basic expect - result = abbreviate("Portable Network Graphics") + result = abbreviate "Portable Network Graphics" result == "PNG" # lowercase words expect - result = abbreviate("Ruby on Rails") + result = abbreviate "Ruby on Rails" result == "ROR" # punctuation expect - result = abbreviate("First In, First Out") + result = abbreviate "First In, First Out" result == "FIFO" # all caps word expect - result = abbreviate("GNU Image Manipulation Program") + result = abbreviate "GNU Image Manipulation Program" result == "GIMP" # punctuation without whitespace expect - result = abbreviate("Complementary metal-oxide semiconductor") + result = abbreviate "Complementary metal-oxide semiconductor" result == "CMOS" # very long abbreviation expect - result = abbreviate("Rolling On The Floor Laughing So Hard That My Dogs Came Over And Licked Me") + result = abbreviate "Rolling On The Floor Laughing So Hard That My Dogs Came Over And Licked Me" result == "ROTFLSHTMDCOALM" # consecutive delimiters expect - result = abbreviate("Something - I made up from thin air") + result = abbreviate "Something - I made up from thin air" result == "SIMUFTA" # apostrophes expect - result = abbreviate("Halley's Comet") + result = abbreviate "Halley's Comet" result == "HC" # underscore emphasis expect - result = abbreviate("The Road _Not_ Taken") + result = abbreviate "The Road _Not_ Taken" result == "TRNT" diff --git a/exercises/practice/affine-cipher/affine-cipher-test.roc b/exercises/practice/affine-cipher/affine-cipher-test.roc index a951527c..a04c48a6 100644 --- a/exercises/practice/affine-cipher/affine-cipher-test.roc +++ b/exercises/practice/affine-cipher/affine-cipher-test.roc @@ -1,6 +1,6 @@ # These tests are auto-generated with test data from: # https://github.com/exercism/problem-specifications/tree/main/exercises/affine-cipher/canonical-data.json -# File last updated on 2025-01-04 +# File last updated on 2025-07-26 app [main!] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.19.0/Hj-J_zxz7V9YurCSTFcFdu6cQJie4guzsPMUi5kBYUk.tar.br", } @@ -8,7 +8,7 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line!("") + Stdout.line! "" import AffineCipher exposing [encode, decode] @@ -20,71 +20,71 @@ import AffineCipher exposing [encode, decode] expect phrase = "yes" key = { a: 5, b: 7 } - result = encode(phrase, key) - expected = Ok("xbt") + result = encode phrase key + expected = Ok "xbt" result == expected # encode no expect phrase = "no" key = { a: 15, b: 18 } - result = encode(phrase, key) - expected = Ok("fu") + result = encode phrase key + expected = Ok "fu" result == expected # encode OMG expect phrase = "OMG" key = { a: 21, b: 3 } - result = encode(phrase, key) - expected = Ok("lvz") + result = encode phrase key + expected = Ok "lvz" result == expected # encode O M G expect phrase = "O M G" key = { a: 25, b: 47 } - result = encode(phrase, key) - expected = Ok("hjp") + result = encode phrase key + expected = Ok "hjp" result == expected # encode mindblowingly expect phrase = "mindblowingly" key = { a: 11, b: 15 } - result = encode(phrase, key) - expected = Ok("rzcwa gnxzc dgt") + result = encode phrase key + expected = Ok "rzcwa gnxzc dgt" result == expected # encode numbers expect phrase = "Testing,1 2 3, testing." key = { a: 3, b: 4 } - result = encode(phrase, key) - expected = Ok("jqgjc rw123 jqgjc rw") + result = encode phrase key + expected = Ok "jqgjc rw123 jqgjc rw" result == expected # encode deep thought expect phrase = "Truth is fiction." key = { a: 5, b: 17 } - result = encode(phrase, key) - expected = Ok("iynia fdqfb ifje") + result = encode phrase key + expected = Ok "iynia fdqfb ifje" result == expected # encode all the letters expect phrase = "The quick brown fox jumps over the lazy dog." key = { a: 17, b: 33 } - result = encode(phrase, key) - expected = Ok("swxtj npvyk lruol iejdc blaxk swxmh qzglf") + result = encode phrase key + expected = Ok "swxtj npvyk lruol iejdc blaxk swxmh qzglf" result == expected # encode with a not coprime to m expect phrase = "This is a test." key = { a: 6, b: 17 } - result = encode(phrase, key) + result = encode phrase key result |> Result.is_err ## @@ -95,54 +95,54 @@ expect expect phrase = "tytgn fjr" key = { a: 3, b: 7 } - result = decode(phrase, key) - expected = Ok("exercism") + result = decode phrase key + expected = Ok "exercism" result == expected # decode a sentence expect phrase = "qdwju nqcro muwhn odqun oppmd aunwd o" key = { a: 19, b: 16 } - result = decode(phrase, key) - expected = Ok("anobstacleisoftenasteppingstone") + result = decode phrase key + expected = Ok "anobstacleisoftenasteppingstone" result == expected # decode numbers expect phrase = "odpoz ub123 odpoz ub" key = { a: 25, b: 7 } - result = decode(phrase, key) - expected = Ok("testing123testing") + result = decode phrase key + expected = Ok "testing123testing" result == expected # decode all the letters expect phrase = "swxtj npvyk lruol iejdc blaxk swxmh qzglf" key = { a: 17, b: 33 } - result = decode(phrase, key) - expected = Ok("thequickbrownfoxjumpsoverthelazydog") + result = decode phrase key + expected = Ok "thequickbrownfoxjumpsoverthelazydog" result == expected # decode with no spaces in input expect phrase = "swxtjnpvyklruoliejdcblaxkswxmhqzglf" key = { a: 17, b: 33 } - result = decode(phrase, key) - expected = Ok("thequickbrownfoxjumpsoverthelazydog") + result = decode phrase key + expected = Ok "thequickbrownfoxjumpsoverthelazydog" result == expected # decode with too many spaces expect phrase = "vszzm cly yd cg qdp" key = { a: 15, b: 16 } - result = decode(phrase, key) - expected = Ok("jollygreengiant") + result = decode phrase key + expected = Ok "jollygreengiant" result == expected # decode with a not coprime to m expect phrase = "Test" key = { a: 13, b: 5 } - result = decode(phrase, key) + result = decode phrase key result |> Result.is_err diff --git a/exercises/practice/all-your-base/all-your-base-test.roc b/exercises/practice/all-your-base/all-your-base-test.roc index ba7b7700..02b626b8 100644 --- a/exercises/practice/all-your-base/all-your-base-test.roc +++ b/exercises/practice/all-your-base/all-your-base-test.roc @@ -1,6 +1,6 @@ # These tests are auto-generated with test data from: # https://github.com/exercism/problem-specifications/tree/main/exercises/all-your-base/canonical-data.json -# File last updated on 2025-01-04 +# File last updated on 2025-07-26 app [main!] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.19.0/Hj-J_zxz7V9YurCSTFcFdu6cQJie4guzsPMUi5kBYUk.tar.br", } @@ -8,92 +8,92 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line!("") + Stdout.line! "" import AllYourBase exposing [rebase] # single bit one to decimal expect - result = rebase({ input_base: 2, output_base: 10, digits: [1] }) - result == Ok([1]) + result = rebase { input_base: 2, output_base: 10, digits: [1] } + result == Ok [1] # binary to single decimal expect - result = rebase({ input_base: 2, output_base: 10, digits: [1, 0, 1] }) - result == Ok([5]) + result = rebase { input_base: 2, output_base: 10, digits: [1, 0, 1] } + result == Ok [5] # single decimal to binary expect - result = rebase({ input_base: 10, output_base: 2, digits: [5] }) - result == Ok([1, 0, 1]) + result = rebase { input_base: 10, output_base: 2, digits: [5] } + result == Ok [1, 0, 1] # binary to multiple decimal expect - result = rebase({ input_base: 2, output_base: 10, digits: [1, 0, 1, 0, 1, 0] }) - result == Ok([4, 2]) + result = rebase { input_base: 2, output_base: 10, digits: [1, 0, 1, 0, 1, 0] } + result == Ok [4, 2] # decimal to binary expect - result = rebase({ input_base: 10, output_base: 2, digits: [4, 2] }) - result == Ok([1, 0, 1, 0, 1, 0]) + result = rebase { input_base: 10, output_base: 2, digits: [4, 2] } + result == Ok [1, 0, 1, 0, 1, 0] # trinary to hexadecimal expect - result = rebase({ input_base: 3, output_base: 16, digits: [1, 1, 2, 0] }) - result == Ok([2, 10]) + result = rebase { input_base: 3, output_base: 16, digits: [1, 1, 2, 0] } + result == Ok [2, 10] # hexadecimal to trinary expect - result = rebase({ input_base: 16, output_base: 3, digits: [2, 10] }) - result == Ok([1, 1, 2, 0]) + result = rebase { input_base: 16, output_base: 3, digits: [2, 10] } + result == Ok [1, 1, 2, 0] # 15-bit integer expect - result = rebase({ input_base: 97, output_base: 73, digits: [3, 46, 60] }) - result == Ok([6, 10, 45]) + result = rebase { input_base: 97, output_base: 73, digits: [3, 46, 60] } + result == Ok [6, 10, 45] # empty list expect - result = rebase({ input_base: 2, output_base: 10, digits: [] }) - result == Ok([0]) + result = rebase { input_base: 2, output_base: 10, digits: [] } + result == Ok [0] # single zero expect - result = rebase({ input_base: 10, output_base: 2, digits: [0] }) - result == Ok([0]) + result = rebase { input_base: 10, output_base: 2, digits: [0] } + result == Ok [0] # multiple zeros expect - result = rebase({ input_base: 10, output_base: 2, digits: [0, 0, 0] }) - result == Ok([0]) + result = rebase { input_base: 10, output_base: 2, digits: [0, 0, 0] } + result == Ok [0] # leading zeros expect - result = rebase({ input_base: 7, output_base: 10, digits: [0, 6, 0] }) - result == Ok([4, 2]) + result = rebase { input_base: 7, output_base: 10, digits: [0, 6, 0] } + result == Ok [4, 2] # input base is one expect - result = rebase({ input_base: 1, output_base: 10, digits: [0] }) + result = rebase { input_base: 1, output_base: 10, digits: [0] } result |> Result.is_err # input base is zero expect - result = rebase({ input_base: 0, output_base: 10, digits: [] }) + result = rebase { input_base: 0, output_base: 10, digits: [] } result |> Result.is_err # invalid positive digit expect - result = rebase({ input_base: 2, output_base: 10, digits: [1, 2, 1, 0, 1, 0] }) + result = rebase { input_base: 2, output_base: 10, digits: [1, 2, 1, 0, 1, 0] } result |> Result.is_err # output base is one expect - result = rebase({ input_base: 2, output_base: 1, digits: [1, 0, 1, 0, 1, 0] }) + result = rebase { input_base: 2, output_base: 1, digits: [1, 0, 1, 0, 1, 0] } result |> Result.is_err # output base is zero expect - result = rebase({ input_base: 10, output_base: 0, digits: [7] }) + result = rebase { input_base: 10, output_base: 0, digits: [7] } result |> Result.is_err diff --git a/exercises/practice/allergies/allergies-test.roc b/exercises/practice/allergies/allergies-test.roc index 374ba9ec..cda6fa47 100644 --- a/exercises/practice/allergies/allergies-test.roc +++ b/exercises/practice/allergies/allergies-test.roc @@ -1,6 +1,6 @@ # These tests are auto-generated with test data from: # https://github.com/exercism/problem-specifications/tree/main/exercises/allergies/canonical-data.json -# File last updated on 2025-01-04 +# File last updated on 2025-07-26 app [main!] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.19.0/Hj-J_zxz7V9YurCSTFcFdu6cQJie4guzsPMUi5kBYUk.tar.br", } @@ -8,257 +8,257 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line!("") + Stdout.line! "" import Allergies exposing [allergic_to, set] # testing for eggs allergy not allergic to anything expect - result = allergic_to(Eggs, 0) + result = allergic_to Eggs 0 result == Bool.false # testing for eggs allergy allergic only to eggs expect - result = allergic_to(Eggs, 1) + result = allergic_to Eggs 1 result == Bool.true # testing for eggs allergy allergic to eggs and something else expect - result = allergic_to(Eggs, 3) + result = allergic_to Eggs 3 result == Bool.true # testing for eggs allergy allergic to something, but not eggs expect - result = allergic_to(Eggs, 2) + result = allergic_to Eggs 2 result == Bool.false # testing for eggs allergy allergic to everything expect - result = allergic_to(Eggs, 255) + result = allergic_to Eggs 255 result == Bool.true # testing for peanuts allergy not allergic to anything expect - result = allergic_to(Peanuts, 0) + result = allergic_to Peanuts 0 result == Bool.false # testing for peanuts allergy allergic only to peanuts expect - result = allergic_to(Peanuts, 2) + result = allergic_to Peanuts 2 result == Bool.true # testing for peanuts allergy allergic to peanuts and something else expect - result = allergic_to(Peanuts, 7) + result = allergic_to Peanuts 7 result == Bool.true # testing for peanuts allergy allergic to something, but not peanuts expect - result = allergic_to(Peanuts, 5) + result = allergic_to Peanuts 5 result == Bool.false # testing for peanuts allergy allergic to everything expect - result = allergic_to(Peanuts, 255) + result = allergic_to Peanuts 255 result == Bool.true # testing for shellfish allergy not allergic to anything expect - result = allergic_to(Shellfish, 0) + result = allergic_to Shellfish 0 result == Bool.false # testing for shellfish allergy allergic only to shellfish expect - result = allergic_to(Shellfish, 4) + result = allergic_to Shellfish 4 result == Bool.true # testing for shellfish allergy allergic to shellfish and something else expect - result = allergic_to(Shellfish, 14) + result = allergic_to Shellfish 14 result == Bool.true # testing for shellfish allergy allergic to something, but not shellfish expect - result = allergic_to(Shellfish, 10) + result = allergic_to Shellfish 10 result == Bool.false # testing for shellfish allergy allergic to everything expect - result = allergic_to(Shellfish, 255) + result = allergic_to Shellfish 255 result == Bool.true # testing for strawberries allergy not allergic to anything expect - result = allergic_to(Strawberries, 0) + result = allergic_to Strawberries 0 result == Bool.false # testing for strawberries allergy allergic only to strawberries expect - result = allergic_to(Strawberries, 8) + result = allergic_to Strawberries 8 result == Bool.true # testing for strawberries allergy allergic to strawberries and something else expect - result = allergic_to(Strawberries, 28) + result = allergic_to Strawberries 28 result == Bool.true # testing for strawberries allergy allergic to something, but not strawberries expect - result = allergic_to(Strawberries, 20) + result = allergic_to Strawberries 20 result == Bool.false # testing for strawberries allergy allergic to everything expect - result = allergic_to(Strawberries, 255) + result = allergic_to Strawberries 255 result == Bool.true # testing for tomatoes allergy not allergic to anything expect - result = allergic_to(Tomatoes, 0) + result = allergic_to Tomatoes 0 result == Bool.false # testing for tomatoes allergy allergic only to tomatoes expect - result = allergic_to(Tomatoes, 16) + result = allergic_to Tomatoes 16 result == Bool.true # testing for tomatoes allergy allergic to tomatoes and something else expect - result = allergic_to(Tomatoes, 56) + result = allergic_to Tomatoes 56 result == Bool.true # testing for tomatoes allergy allergic to something, but not tomatoes expect - result = allergic_to(Tomatoes, 40) + result = allergic_to Tomatoes 40 result == Bool.false # testing for tomatoes allergy allergic to everything expect - result = allergic_to(Tomatoes, 255) + result = allergic_to Tomatoes 255 result == Bool.true # testing for chocolate allergy not allergic to anything expect - result = allergic_to(Chocolate, 0) + result = allergic_to Chocolate 0 result == Bool.false # testing for chocolate allergy allergic only to chocolate expect - result = allergic_to(Chocolate, 32) + result = allergic_to Chocolate 32 result == Bool.true # testing for chocolate allergy allergic to chocolate and something else expect - result = allergic_to(Chocolate, 112) + result = allergic_to Chocolate 112 result == Bool.true # testing for chocolate allergy allergic to something, but not chocolate expect - result = allergic_to(Chocolate, 80) + result = allergic_to Chocolate 80 result == Bool.false # testing for chocolate allergy allergic to everything expect - result = allergic_to(Chocolate, 255) + result = allergic_to Chocolate 255 result == Bool.true # testing for pollen allergy not allergic to anything expect - result = allergic_to(Pollen, 0) + result = allergic_to Pollen 0 result == Bool.false # testing for pollen allergy allergic only to pollen expect - result = allergic_to(Pollen, 64) + result = allergic_to Pollen 64 result == Bool.true # testing for pollen allergy allergic to pollen and something else expect - result = allergic_to(Pollen, 224) + result = allergic_to Pollen 224 result == Bool.true # testing for pollen allergy allergic to something, but not pollen expect - result = allergic_to(Pollen, 160) + result = allergic_to Pollen 160 result == Bool.false # testing for pollen allergy allergic to everything expect - result = allergic_to(Pollen, 255) + result = allergic_to Pollen 255 result == Bool.true # testing for cats allergy not allergic to anything expect - result = allergic_to(Cats, 0) + result = allergic_to Cats 0 result == Bool.false # testing for cats allergy allergic only to cats expect - result = allergic_to(Cats, 128) + result = allergic_to Cats 128 result == Bool.true # testing for cats allergy allergic to cats and something else expect - result = allergic_to(Cats, 192) + result = allergic_to Cats 192 result == Bool.true # testing for cats allergy allergic to something, but not cats expect - result = allergic_to(Cats, 64) + result = allergic_to Cats 64 result == Bool.false # testing for cats allergy allergic to everything expect - result = allergic_to(Cats, 255) + result = allergic_to Cats 255 result == Bool.true # list when: no allergies expect - result = set(0) - result == Set.from_list([]) + result = set 0 + result == Set.from_list [] # list when: just eggs expect - result = set(1) - result == Set.from_list([Eggs]) + result = set 1 + result == Set.from_list [Eggs] # list when: just peanuts expect - result = set(2) - result == Set.from_list([Peanuts]) + result = set 2 + result == Set.from_list [Peanuts] # list when: just strawberries expect - result = set(8) - result == Set.from_list([Strawberries]) + result = set 8 + result == Set.from_list [Strawberries] # list when: eggs and peanuts expect - result = set(3) - result == Set.from_list([Eggs, Peanuts]) + result = set 3 + result == Set.from_list [Eggs, Peanuts] # list when: more than eggs but not peanuts expect - result = set(5) - result == Set.from_list([Eggs, Shellfish]) + result = set 5 + result == Set.from_list [Eggs, Shellfish] # list when: lots of stuff expect - result = set(248) - result == Set.from_list([Strawberries, Tomatoes, Chocolate, Pollen, Cats]) + result = set 248 + result == Set.from_list [Strawberries, Tomatoes, Chocolate, Pollen, Cats] # list when: everything expect - result = set(255) - result == Set.from_list([Eggs, Peanuts, Shellfish, Strawberries, Tomatoes, Chocolate, Pollen, Cats]) + result = set 255 + result == Set.from_list [Eggs, Peanuts, Shellfish, Strawberries, Tomatoes, Chocolate, Pollen, Cats] # list when: no allergen score parts expect - result = set(509) - result == Set.from_list([Eggs, Shellfish, Strawberries, Tomatoes, Chocolate, Pollen, Cats]) + result = set 509 + result == Set.from_list [Eggs, Shellfish, Strawberries, Tomatoes, Chocolate, Pollen, Cats] # list when: no allergen score parts without highest valid score expect - result = set(257) - result == Set.from_list([Eggs]) + result = set 257 + result == Set.from_list [Eggs] diff --git a/exercises/practice/alphametics/alphametics-test.roc b/exercises/practice/alphametics/alphametics-test.roc index 3c926595..bc40c6ea 100644 --- a/exercises/practice/alphametics/alphametics-test.roc +++ b/exercises/practice/alphametics/alphametics-test.roc @@ -1,6 +1,6 @@ # These tests are auto-generated with test data from: # https://github.com/exercism/problem-specifications/tree/main/exercises/alphametics/canonical-data.json -# File last updated on 2025-01-04 +# File last updated on 2025-07-26 app [main!] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.19.0/Hj-J_zxz7V9YurCSTFcFdu6cQJie4guzsPMUi5kBYUk.tar.br", } @@ -8,148 +8,132 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line!("") + Stdout.line! "" import Alphametics exposing [solve] # puzzle with three letters expect - result = solve("I + BB == ILL") - Result.with_default(result, []) + result = solve "I + BB == ILL" + Result.with_default result [] |> Set.from_list - == Set.from_list( - [ - ('I', 1), - ('B', 9), - ('L', 0), - ], - ) + == Set.from_list [ + ('I', 1), + ('B', 9), + ('L', 0), + ] # solution must have unique value for each letter expect - result = solve("A == B") - Result.is_err(result) + result = solve "A == B" + Result.is_err result # leading zero solution is invalid expect - result = solve("ACA + DD == BD") - Result.is_err(result) + result = solve "ACA + DD == BD" + Result.is_err result # puzzle with two digits final carry expect - result = solve("A + A + A + A + A + A + A + A + A + A + A + B == BCC") - Result.with_default(result, []) + result = solve "A + A + A + A + A + A + A + A + A + A + A + B == BCC" + Result.with_default result [] |> Set.from_list - == Set.from_list( - [ - ('A', 9), - ('B', 1), - ('C', 0), - ], - ) + == Set.from_list [ + ('A', 9), + ('B', 1), + ('C', 0), + ] # puzzle with four letters expect - result = solve("AS + A == MOM") - Result.with_default(result, []) + result = solve "AS + A == MOM" + Result.with_default result [] |> Set.from_list - == Set.from_list( - [ - ('A', 9), - ('S', 2), - ('M', 1), - ('O', 0), - ], - ) + == Set.from_list [ + ('A', 9), + ('S', 2), + ('M', 1), + ('O', 0), + ] # puzzle with six letters expect - result = solve("NO + NO + TOO == LATE") - Result.with_default(result, []) + result = solve "NO + NO + TOO == LATE" + Result.with_default result [] |> Set.from_list - == Set.from_list( - [ - ('N', 7), - ('O', 4), - ('T', 9), - ('L', 1), - ('A', 0), - ('E', 2), - ], - ) + == Set.from_list [ + ('N', 7), + ('O', 4), + ('T', 9), + ('L', 1), + ('A', 0), + ('E', 2), + ] # puzzle with seven letters expect - result = solve("HE + SEES + THE == LIGHT") - Result.with_default(result, []) + result = solve "HE + SEES + THE == LIGHT" + Result.with_default result [] |> Set.from_list - == Set.from_list( - [ - ('E', 4), - ('G', 2), - ('H', 5), - ('I', 0), - ('L', 1), - ('S', 9), - ('T', 7), - ], - ) + == Set.from_list [ + ('E', 4), + ('G', 2), + ('H', 5), + ('I', 0), + ('L', 1), + ('S', 9), + ('T', 7), + ] # puzzle with eight letters expect - result = solve("SEND + MORE == MONEY") - Result.with_default(result, []) + result = solve "SEND + MORE == MONEY" + Result.with_default result [] |> Set.from_list - == Set.from_list( - [ - ('S', 9), - ('E', 5), - ('N', 6), - ('D', 7), - ('M', 1), - ('O', 0), - ('R', 8), - ('Y', 2), - ], - ) + == Set.from_list [ + ('S', 9), + ('E', 5), + ('N', 6), + ('D', 7), + ('M', 1), + ('O', 0), + ('R', 8), + ('Y', 2), + ] # puzzle with ten letters expect - result = solve("AND + A + STRONG + OFFENSE + AS + A + GOOD == DEFENSE") - Result.with_default(result, []) + result = solve "AND + A + STRONG + OFFENSE + AS + A + GOOD == DEFENSE" + Result.with_default result [] |> Set.from_list - == Set.from_list( - [ - ('A', 5), - ('D', 3), - ('E', 4), - ('F', 7), - ('G', 8), - ('N', 0), - ('O', 2), - ('R', 1), - ('S', 6), - ('T', 9), - ], - ) + == Set.from_list [ + ('A', 5), + ('D', 3), + ('E', 4), + ('F', 7), + ('G', 8), + ('N', 0), + ('O', 2), + ('R', 1), + ('S', 6), + ('T', 9), + ] # puzzle with ten letters and 199 addends expect - result = solve("THIS + A + FIRE + THEREFORE + FOR + ALL + HISTORIES + I + TELL + A + TALE + THAT + FALSIFIES + ITS + TITLE + TIS + A + LIE + THE + TALE + OF + THE + LAST + FIRE + HORSES + LATE + AFTER + THE + FIRST + FATHERS + FORESEE + THE + HORRORS + THE + LAST + FREE + TROLL + TERRIFIES + THE + HORSES + OF + FIRE + THE + TROLL + RESTS + AT + THE + HOLE + OF + LOSSES + IT + IS + THERE + THAT + SHE + STORES + ROLES + OF + LEATHERS + AFTER + SHE + SATISFIES + HER + HATE + OFF + THOSE + FEARS + A + TASTE + RISES + AS + SHE + HEARS + THE + LEAST + FAR + HORSE + THOSE + FAST + HORSES + THAT + FIRST + HEAR + THE + TROLL + FLEE + OFF + TO + THE + FOREST + THE + HORSES + THAT + ALERTS + RAISE + THE + STARES + OF + THE + OTHERS + AS + THE + TROLL + ASSAILS + AT + THE + TOTAL + SHIFT + HER + TEETH + TEAR + HOOF + OFF + TORSO + AS + THE + LAST + HORSE + FORFEITS + ITS + LIFE + THE + FIRST + FATHERS + HEAR + OF + THE + HORRORS + THEIR + FEARS + THAT + THE + FIRES + FOR + THEIR + FEASTS + ARREST + AS + THE + FIRST + FATHERS + RESETTLE + THE + LAST + OF + THE + FIRE + HORSES + THE + LAST + TROLL + HARASSES + THE + FOREST + HEART + FREE + AT + LAST + OF + THE + LAST + TROLL + ALL + OFFER + THEIR + FIRE + HEAT + TO + THE + ASSISTERS + FAR + OFF + THE + TROLL + FASTS + ITS + LIFE + SHORTER + AS + STARS + RISE + THE + HORSES + REST + SAFE + AFTER + ALL + SHARE + HOT + FISH + AS + THEIR + AFFILIATES + TAILOR + A + ROOFS + FOR + THEIR + SAFE == FORTRESSES") - Result.with_default(result, []) + result = solve "THIS + A + FIRE + THEREFORE + FOR + ALL + HISTORIES + I + TELL + A + TALE + THAT + FALSIFIES + ITS + TITLE + TIS + A + LIE + THE + TALE + OF + THE + LAST + FIRE + HORSES + LATE + AFTER + THE + FIRST + FATHERS + FORESEE + THE + HORRORS + THE + LAST + FREE + TROLL + TERRIFIES + THE + HORSES + OF + FIRE + THE + TROLL + RESTS + AT + THE + HOLE + OF + LOSSES + IT + IS + THERE + THAT + SHE + STORES + ROLES + OF + LEATHERS + AFTER + SHE + SATISFIES + HER + HATE + OFF + THOSE + FEARS + A + TASTE + RISES + AS + SHE + HEARS + THE + LEAST + FAR + HORSE + THOSE + FAST + HORSES + THAT + FIRST + HEAR + THE + TROLL + FLEE + OFF + TO + THE + FOREST + THE + HORSES + THAT + ALERTS + RAISE + THE + STARES + OF + THE + OTHERS + AS + THE + TROLL + ASSAILS + AT + THE + TOTAL + SHIFT + HER + TEETH + TEAR + HOOF + OFF + TORSO + AS + THE + LAST + HORSE + FORFEITS + ITS + LIFE + THE + FIRST + FATHERS + HEAR + OF + THE + HORRORS + THEIR + FEARS + THAT + THE + FIRES + FOR + THEIR + FEASTS + ARREST + AS + THE + FIRST + FATHERS + RESETTLE + THE + LAST + OF + THE + FIRE + HORSES + THE + LAST + TROLL + HARASSES + THE + FOREST + HEART + FREE + AT + LAST + OF + THE + LAST + TROLL + ALL + OFFER + THEIR + FIRE + HEAT + TO + THE + ASSISTERS + FAR + OFF + THE + TROLL + FASTS + ITS + LIFE + SHORTER + AS + STARS + RISE + THE + HORSES + REST + SAFE + AFTER + ALL + SHARE + HOT + FISH + AS + THEIR + AFFILIATES + TAILOR + A + ROOFS + FOR + THEIR + SAFE == FORTRESSES" + Result.with_default result [] |> Set.from_list - == Set.from_list( - [ - ('A', 1), - ('E', 0), - ('F', 5), - ('H', 8), - ('I', 7), - ('L', 2), - ('O', 6), - ('R', 3), - ('S', 4), - ('T', 9), - ], - ) + == Set.from_list [ + ('A', 1), + ('E', 0), + ('F', 5), + ('H', 8), + ('I', 7), + ('L', 2), + ('O', 6), + ('R', 3), + ('S', 4), + ('T', 9), + ] diff --git a/exercises/practice/anagram/anagram-test.roc b/exercises/practice/anagram/anagram-test.roc index 4156219a..4ae057e6 100644 --- a/exercises/practice/anagram/anagram-test.roc +++ b/exercises/practice/anagram/anagram-test.roc @@ -1,6 +1,6 @@ # These tests are auto-generated with test data from: # https://github.com/exercism/problem-specifications/tree/main/exercises/anagram/canonical-data.json -# File last updated on 2025-01-04 +# File last updated on 2025-07-26 app [main!] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.19.0/Hj-J_zxz7V9YurCSTFcFdu6cQJie4guzsPMUi5kBYUk.tar.br", unicode: "https://github.com/roc-lang/unicode/releases/download/0.3.0/9KKFsA4CdOz0JIOL7iBSI_2jGIXQ6TsFBXgd086idpY.tar.br", @@ -9,92 +9,92 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line!("") + Stdout.line! "" import Anagram exposing [find_anagrams] # no matches expect - result = find_anagrams("diaper", ["hello", "world", "zombies", "pants"]) + result = find_anagrams "diaper" ["hello", "world", "zombies", "pants"] result == [] # detects two anagrams expect - result = find_anagrams("solemn", ["lemons", "cherry", "melons"]) + result = find_anagrams "solemn" ["lemons", "cherry", "melons"] result == ["lemons", "melons"] # does not detect anagram subsets expect - result = find_anagrams("good", ["dog", "goody"]) + result = find_anagrams "good" ["dog", "goody"] result == [] # detects anagram expect - result = find_anagrams("listen", ["enlists", "google", "inlets", "banana"]) + result = find_anagrams "listen" ["enlists", "google", "inlets", "banana"] result == ["inlets"] # detects three anagrams expect - result = find_anagrams("allergy", ["gallery", "ballerina", "regally", "clergy", "largely", "leading"]) + result = find_anagrams "allergy" ["gallery", "ballerina", "regally", "clergy", "largely", "leading"] result == ["gallery", "regally", "largely"] # detects multiple anagrams with different case expect - result = find_anagrams("nose", ["Eons", "ONES"]) + result = find_anagrams "nose" ["Eons", "ONES"] result == ["Eons", "ONES"] # does not detect non-anagrams with identical checksum expect - result = find_anagrams("mass", ["last"]) + result = find_anagrams "mass" ["last"] result == [] # detects anagrams case-insensitively expect - result = find_anagrams("Orchestra", ["cashregister", "Carthorse", "radishes"]) + result = find_anagrams "Orchestra" ["cashregister", "Carthorse", "radishes"] result == ["Carthorse"] # detects anagrams using case-insensitive subject expect - result = find_anagrams("Orchestra", ["cashregister", "carthorse", "radishes"]) + result = find_anagrams "Orchestra" ["cashregister", "carthorse", "radishes"] result == ["carthorse"] # detects anagrams using case-insensitive possible matches expect - result = find_anagrams("orchestra", ["cashregister", "Carthorse", "radishes"]) + result = find_anagrams "orchestra" ["cashregister", "Carthorse", "radishes"] result == ["Carthorse"] # does not detect an anagram if the original word is repeated expect - result = find_anagrams("go", ["goGoGO"]) + result = find_anagrams "go" ["goGoGO"] result == [] # anagrams must use all letters exactly once expect - result = find_anagrams("tapper", ["patter"]) + result = find_anagrams "tapper" ["patter"] result == [] # words are not anagrams of themselves expect - result = find_anagrams("BANANA", ["BANANA"]) + result = find_anagrams "BANANA" ["BANANA"] result == [] # words are not anagrams of themselves even if letter case is partially different expect - result = find_anagrams("BANANA", ["Banana"]) + result = find_anagrams "BANANA" ["Banana"] result == [] # words are not anagrams of themselves even if letter case is completely different expect - result = find_anagrams("BANANA", ["banana"]) + result = find_anagrams "BANANA" ["banana"] result == [] # words other than themselves can be anagrams expect - result = find_anagrams("LISTEN", ["LISTEN", "Silent"]) + result = find_anagrams "LISTEN" ["LISTEN", "Silent"] result == ["Silent"] # different characters may have the same bytes expect - result = find_anagrams("a⬂", ["€a"]) + result = find_anagrams "a⬂" ["€a"] result == [] diff --git a/exercises/practice/armstrong-numbers/armstrong-numbers-test.roc b/exercises/practice/armstrong-numbers/armstrong-numbers-test.roc index f85f5c08..41b75b7d 100644 --- a/exercises/practice/armstrong-numbers/armstrong-numbers-test.roc +++ b/exercises/practice/armstrong-numbers/armstrong-numbers-test.roc @@ -1,6 +1,6 @@ # These tests are auto-generated with test data from: # https://github.com/exercism/problem-specifications/tree/main/exercises/armstrong-numbers/canonical-data.json -# File last updated on 2025-01-04 +# File last updated on 2025-07-26 app [main!] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.19.0/Hj-J_zxz7V9YurCSTFcFdu6cQJie4guzsPMUi5kBYUk.tar.br", } @@ -8,52 +8,52 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line!("") + Stdout.line! "" import ArmstrongNumbers exposing [is_armstrong_number] # Zero is an Armstrong number expect - result = is_armstrong_number(0) + result = is_armstrong_number 0 result == Bool.true # Single-digit numbers are Armstrong numbers expect - result = is_armstrong_number(5) + result = is_armstrong_number 5 result == Bool.true # There are no two-digit Armstrong numbers expect - result = is_armstrong_number(10) + result = is_armstrong_number 10 result == Bool.false # Three-digit number that is an Armstrong number expect - result = is_armstrong_number(153) + result = is_armstrong_number 153 result == Bool.true # Three-digit number that is not an Armstrong number expect - result = is_armstrong_number(100) + result = is_armstrong_number 100 result == Bool.false # Four-digit number that is an Armstrong number expect - result = is_armstrong_number(9474) + result = is_armstrong_number 9474 result == Bool.true # Four-digit number that is not an Armstrong number expect - result = is_armstrong_number(9475) + result = is_armstrong_number 9475 result == Bool.false # Seven-digit number that is an Armstrong number expect - result = is_armstrong_number(9926315) + result = is_armstrong_number 9926315 result == Bool.true # Seven-digit number that is not an Armstrong number expect - result = is_armstrong_number(9926314) + result = is_armstrong_number 9926314 result == Bool.false diff --git a/exercises/practice/atbash-cipher/atbash-cipher-test.roc b/exercises/practice/atbash-cipher/atbash-cipher-test.roc index 1a710a75..fb8e8be0 100644 --- a/exercises/practice/atbash-cipher/atbash-cipher-test.roc +++ b/exercises/practice/atbash-cipher/atbash-cipher-test.roc @@ -1,6 +1,6 @@ # These tests are auto-generated with test data from: # https://github.com/exercism/problem-specifications/tree/main/exercises/atbash-cipher/canonical-data.json -# File last updated on 2025-01-04 +# File last updated on 2025-07-26 app [main!] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.19.0/Hj-J_zxz7V9YurCSTFcFdu6cQJie4guzsPMUi5kBYUk.tar.br", } @@ -8,7 +8,7 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line!("") + Stdout.line! "" import AtbashCipher exposing [encode, decode] @@ -21,56 +21,56 @@ expect phrase = "yes" result = phrase |> encode expected = "bvh" - result == Ok(expected) + result == Ok expected # encode no expect phrase = "no" result = phrase |> encode expected = "ml" - result == Ok(expected) + result == Ok expected # encode OMG expect phrase = "OMG" result = phrase |> encode expected = "lnt" - result == Ok(expected) + result == Ok expected # encode spaces expect phrase = "O M G" result = phrase |> encode expected = "lnt" - result == Ok(expected) + result == Ok expected # encode mindblowingly expect phrase = "mindblowingly" result = phrase |> encode expected = "nrmwy oldrm tob" - result == Ok(expected) + result == Ok expected # encode numbers expect phrase = "Testing,1 2 3, testing." result = phrase |> encode expected = "gvhgr mt123 gvhgr mt" - result == Ok(expected) + result == Ok expected # encode deep thought expect phrase = "Truth is fiction." result = phrase |> encode expected = "gifgs rhurx grlm" - result == Ok(expected) + result == Ok expected # encode all the letters expect phrase = "The quick brown fox jumps over the lazy dog." result = phrase |> encode expected = "gsvjf rxpyi ldmul cqfnk hlevi gsvoz abwlt" - result == Ok(expected) + result == Ok expected ## ## decode @@ -81,40 +81,40 @@ expect phrase = "vcvix rhn" result = phrase |> decode expected = "exercism" - result == Ok(expected) + result == Ok expected # decode a sentence expect phrase = "zmlyh gzxov rhlug vmzhg vkkrm thglm v" result = phrase |> decode expected = "anobstacleisoftenasteppingstone" - result == Ok(expected) + result == Ok expected # decode numbers expect phrase = "gvhgr mt123 gvhgr mt" result = phrase |> decode expected = "testing123testing" - result == Ok(expected) + result == Ok expected # decode all the letters expect phrase = "gsvjf rxpyi ldmul cqfnk hlevi gsvoz abwlt" result = phrase |> decode expected = "thequickbrownfoxjumpsoverthelazydog" - result == Ok(expected) + result == Ok expected # decode with too many spaces expect phrase = "vc vix r hn" result = phrase |> decode expected = "exercism" - result == Ok(expected) + result == Ok expected # decode with no spaces expect phrase = "zmlyhgzxovrhlugvmzhgvkkrmthglmv" result = phrase |> decode expected = "anobstacleisoftenasteppingstone" - result == Ok(expected) + result == Ok expected diff --git a/exercises/practice/binary-search-tree/binary-search-tree-test.roc b/exercises/practice/binary-search-tree/binary-search-tree-test.roc index a18f700a..17057c70 100644 --- a/exercises/practice/binary-search-tree/binary-search-tree-test.roc +++ b/exercises/practice/binary-search-tree/binary-search-tree-test.roc @@ -1,6 +1,6 @@ # These tests are auto-generated with test data from: # https://github.com/exercism/problem-specifications/tree/main/exercises/binary-search-tree/canonical-data.json -# File last updated on 2025-01-04 +# File last updated on 2025-07-26 app [main!] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.19.0/Hj-J_zxz7V9YurCSTFcFdu6cQJie4guzsPMUi5kBYUk.tar.br", } @@ -8,7 +8,7 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line!("") + Stdout.line! "" import BinarySearchTree exposing [from_list, to_list] @@ -19,13 +19,11 @@ import BinarySearchTree exposing [from_list, to_list] expect data = [4] result = data |> from_list - expected = Node( - { - value: 4, - left: Nil, - right: Nil, - }, - ) + expected = Node { + value: 4, + left: Nil, + right: Nil, + } result == expected ## @@ -36,57 +34,45 @@ expect expect data = [4, 2] result = data |> from_list - expected = Node( - { - value: 4, - left: Node( - { - value: 2, - left: Nil, - right: Nil, - }, - ), + expected = Node { + value: 4, + left: Node { + value: 2, + left: Nil, right: Nil, }, - ) + right: Nil, + } result == expected # same number at left node expect data = [4, 4] result = data |> from_list - expected = Node( - { + expected = Node { + value: 4, + left: Node { value: 4, - left: Node( - { - value: 4, - left: Nil, - right: Nil, - }, - ), + left: Nil, right: Nil, }, - ) + right: Nil, + } result == expected # greater number at right node expect data = [4, 5] result = data |> from_list - expected = Node( - { - value: 4, + expected = Node { + value: 4, + left: Nil, + right: Node { + value: 5, left: Nil, - right: Node( - { - value: 5, - left: Nil, - right: Nil, - }, - ), + right: Nil, }, - ) + } result == expected ## @@ -96,49 +82,35 @@ expect expect data = [4, 2, 6, 1, 3, 5, 7] result = data |> from_list - expected = Node( - { - value: 4, - left: Node( - { - value: 2, - left: Node( - { - value: 1, - left: Nil, - right: Nil, - }, - ), - right: Node( - { - value: 3, - left: Nil, - right: Nil, - }, - ), - }, - ), - right: Node( - { - value: 6, - left: Node( - { - value: 5, - left: Nil, - right: Nil, - }, - ), - right: Node( - { - value: 7, - left: Nil, - right: Nil, - }, - ), - }, - ), + expected = Node { + value: 4, + left: Node { + value: 2, + left: Node { + value: 1, + left: Nil, + right: Nil, + }, + right: Node { + value: 3, + left: Nil, + right: Nil, + }, + }, + right: Node { + value: 6, + left: Node { + value: 5, + left: Nil, + right: Nil, + }, + right: Node { + value: 7, + left: Nil, + right: Nil, + }, }, - ) + } result == expected ## diff --git a/exercises/practice/binary-search/binary-search-test.roc b/exercises/practice/binary-search/binary-search-test.roc index 68fb31fd..8e181ae9 100644 --- a/exercises/practice/binary-search/binary-search-test.roc +++ b/exercises/practice/binary-search/binary-search-test.roc @@ -1,6 +1,6 @@ # These tests are auto-generated with test data from: # https://github.com/exercism/problem-specifications/tree/main/exercises/binary-search/canonical-data.json -# File last updated on 2025-01-04 +# File last updated on 2025-07-26 app [main!] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.19.0/Hj-J_zxz7V9YurCSTFcFdu6cQJie4guzsPMUi5kBYUk.tar.br", } @@ -8,62 +8,62 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line!("") + Stdout.line! "" import BinarySearch exposing [find] # finds a value in an array with one element expect - result = [6] |> find(6) - result == Ok(0) + result = [6] |> find 6 + result == Ok 0 # finds a value in the middle of an array expect - result = [1, 3, 4, 6, 8, 9, 11] |> find(6) - result == Ok(3) + result = [1, 3, 4, 6, 8, 9, 11] |> find 6 + result == Ok 3 # finds a value at the beginning of an array expect - result = [1, 3, 4, 6, 8, 9, 11] |> find(1) - result == Ok(0) + result = [1, 3, 4, 6, 8, 9, 11] |> find 1 + result == Ok 0 # finds a value at the end of an array expect - result = [1, 3, 4, 6, 8, 9, 11] |> find(11) - result == Ok(6) + result = [1, 3, 4, 6, 8, 9, 11] |> find 11 + result == Ok 6 # finds a value in an array of odd length expect - result = [1, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 634] |> find(144) - result == Ok(9) + result = [1, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 634] |> find 144 + result == Ok 9 # finds a value in an array of even length expect - result = [1, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377] |> find(21) - result == Ok(5) + result = [1, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377] |> find 21 + result == Ok 5 # identifies that a value is not included in the array expect - result = [1, 3, 4, 6, 8, 9, 11] |> find(7) - Result.is_err(result) + result = [1, 3, 4, 6, 8, 9, 11] |> find 7 + Result.is_err result # a value smaller than the array's smallest value is not found expect - result = [1, 3, 4, 6, 8, 9, 11] |> find(0) - Result.is_err(result) + result = [1, 3, 4, 6, 8, 9, 11] |> find 0 + Result.is_err result # a value larger than the array's largest value is not found expect - result = [1, 3, 4, 6, 8, 9, 11] |> find(13) - Result.is_err(result) + result = [1, 3, 4, 6, 8, 9, 11] |> find 13 + Result.is_err result # nothing is found in an empty array expect - result = [] |> find(1) - Result.is_err(result) + result = [] |> find 1 + Result.is_err result # nothing is found when the left and right bounds cross expect - result = [1, 2] |> find(0) - Result.is_err(result) + result = [1, 2] |> find 0 + Result.is_err result diff --git a/exercises/practice/binary/binary-test.roc b/exercises/practice/binary/binary-test.roc index 432c26e5..664033d5 100644 --- a/exercises/practice/binary/binary-test.roc +++ b/exercises/practice/binary/binary-test.roc @@ -1,6 +1,6 @@ # These tests are auto-generated with test data from: # https://github.com/exercism/problem-specifications/tree/main/exercises/binary/canonical-data.json -# File last updated on 2025-01-04 +# File last updated on 2025-07-26 app [main!] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.19.0/Hj-J_zxz7V9YurCSTFcFdu6cQJie4guzsPMUi5kBYUk.tar.br", } @@ -8,82 +8,82 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line!("") + Stdout.line! "" import Binary exposing [decimal] # binary 0 is decimal 0 expect - result = decimal("0") - result == Ok(0) + result = decimal "0" + result == Ok 0 # binary 1 is decimal 1 expect - result = decimal("1") - result == Ok(1) + result = decimal "1" + result == Ok 1 # binary 10 is decimal 2 expect - result = decimal("10") - result == Ok(2) + result = decimal "10" + result == Ok 2 # binary 11 is decimal 3 expect - result = decimal("11") - result == Ok(3) + result = decimal "11" + result == Ok 3 # binary 100 is decimal 4 expect - result = decimal("100") - result == Ok(4) + result = decimal "100" + result == Ok 4 # binary 1001 is decimal 9 expect - result = decimal("1001") - result == Ok(9) + result = decimal "1001" + result == Ok 9 # binary 11010 is decimal 26 expect - result = decimal("11010") - result == Ok(26) + result = decimal "11010" + result == Ok 26 # binary 10001101000 is decimal 1128 expect - result = decimal("10001101000") - result == Ok(1128) + result = decimal "10001101000" + result == Ok 1128 # binary ignores leading zeros expect - result = decimal("000011111") - result == Ok(31) + result = decimal "000011111" + result == Ok 31 # 2 is not a valid binary digit expect - result = decimal("2") + result = decimal "2" result |> Result.is_err # a number containing a non-binary digit is invalid expect - result = decimal("01201") + result = decimal "01201" result |> Result.is_err # a number with trailing non-binary characters is invalid expect - result = decimal("10nope") + result = decimal "10nope" result |> Result.is_err # a number with leading non-binary characters is invalid expect - result = decimal("nope10") + result = decimal "nope10" result |> Result.is_err # a number with internal non-binary characters is invalid expect - result = decimal("10nope10") + result = decimal "10nope10" result |> Result.is_err # a number and a word whitespace separated is invalid expect - result = decimal("001 nope") + result = decimal "001 nope" result |> Result.is_err diff --git a/exercises/practice/bob/bob-test.roc b/exercises/practice/bob/bob-test.roc index 9aea6e77..d7d70186 100644 --- a/exercises/practice/bob/bob-test.roc +++ b/exercises/practice/bob/bob-test.roc @@ -1,6 +1,6 @@ # These tests are auto-generated with test data from: # https://github.com/exercism/problem-specifications/tree/main/exercises/bob/canonical-data.json -# File last updated on 2025-01-04 +# File last updated on 2025-07-26 app [main!] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.19.0/Hj-J_zxz7V9YurCSTFcFdu6cQJie4guzsPMUi5kBYUk.tar.br", } @@ -8,132 +8,132 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line!("") + Stdout.line! "" import Bob exposing [response] # stating something expect - result = response("Tom-ay-to, tom-aaaah-to.") + result = response "Tom-ay-to, tom-aaaah-to." result == "Whatever." # shouting expect - result = response("WATCH OUT!") + result = response "WATCH OUT!" result == "Whoa, chill out!" # shouting gibberish expect - result = response("FCECDFCAAB") + result = response "FCECDFCAAB" result == "Whoa, chill out!" # asking a question expect - result = response("Does this cryogenic chamber make me look fat?") + result = response "Does this cryogenic chamber make me look fat?" result == "Sure." # asking a numeric question expect - result = response("You are, what, like 15?") + result = response "You are, what, like 15?" result == "Sure." # asking gibberish expect - result = response("fffbbcbeab?") + result = response "fffbbcbeab?" result == "Sure." # talking forcefully expect - result = response("Hi there!") + result = response "Hi there!" result == "Whatever." # using acronyms in regular speech expect - result = response("It's OK if you don't want to go work for NASA.") + result = response "It's OK if you don't want to go work for NASA." result == "Whatever." # forceful question expect - result = response("WHAT'S GOING ON?") + result = response "WHAT'S GOING ON?" result == "Calm down, I know what I'm doing!" # shouting numbers expect - result = response("1, 2, 3 GO!") + result = response "1, 2, 3 GO!" result == "Whoa, chill out!" # no letters expect - result = response("1, 2, 3") + result = response "1, 2, 3" result == "Whatever." # question with no letters expect - result = response("4?") + result = response "4?" result == "Sure." # shouting with special characters expect - result = response("ZOMG THE %^*@#\$(*^ ZOMBIES ARE COMING!!11!!1!") + result = response "ZOMG THE %^*@#\$(*^ ZOMBIES ARE COMING!!11!!1!" result == "Whoa, chill out!" # shouting with no exclamation mark expect - result = response("I HATE THE DENTIST") + result = response "I HATE THE DENTIST" result == "Whoa, chill out!" # statement containing question mark expect - result = response("Ending with ? means a question.") + result = response "Ending with ? means a question." result == "Whatever." # non-letters with question expect - result = response(":) ?") + result = response ":) ?" result == "Sure." # prattling on expect - result = response("Wait! Hang on. Are you going to be OK?") + result = response "Wait! Hang on. Are you going to be OK?" result == "Sure." # silence expect - result = response("") + result = response "" result == "Fine. Be that way!" # prolonged silence expect - result = response(" ") + result = response " " result == "Fine. Be that way!" # alternate silence expect - result = response("\t\t\t\t\t\t\t\t\t\t") + result = response "\t\t\t\t\t\t\t\t\t\t" result == "Fine. Be that way!" -# multiple line question -expect - result = response("\nDoes this cryogenic chamber make me look fat?\nNo.") - result == "Whatever." - # starting with whitespace expect - result = response(" hmmmmmmm...") + result = response " hmmmmmmm..." result == "Whatever." # ending with whitespace expect - result = response("Okay if like my spacebar quite a bit? ") + result = response "Okay if like my spacebar quite a bit? " result == "Sure." # other whitespace expect - result = response("\n\r \t") + result = response "\n\r \t" result == "Fine. Be that way!" # non-question ending with whitespace expect - result = response("This is a statement ending with whitespace ") + result = response "This is a statement ending with whitespace " result == "Whatever." +# multiple line question +expect + result = response "\nDoes this cryogenic chamber make\n me look fat?" + result == "Sure." + diff --git a/exercises/practice/bowling/bowling-test.roc b/exercises/practice/bowling/bowling-test.roc index 0932935c..6b9c05bf 100644 --- a/exercises/practice/bowling/bowling-test.roc +++ b/exercises/practice/bowling/bowling-test.roc @@ -1,6 +1,6 @@ # These tests are auto-generated with test data from: # https://github.com/exercism/problem-specifications/tree/main/exercises/bowling/canonical-data.json -# File last updated on 2025-01-04 +# File last updated on 2025-07-26 app [main!] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.19.0/Hj-J_zxz7V9YurCSTFcFdu6cQJie4guzsPMUi5kBYUk.tar.br", } @@ -8,344 +8,323 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line!("") + Stdout.line! "" import Bowling exposing [Game, create, roll, score] replay_game : List U64 -> Result Game _ replay_game = |rolls| - new_game = create({})? + new_game = create? {} rolls - |> List.walk_until( - Ok(new_game), - |state, pins| - when state is - Ok(game) -> - when game |> roll(pins) is - Ok(updated_game) -> Continue(Ok(updated_game)) - Err(err) -> Break(Err(err)) - - Err(_) -> crash("Impossible, we don't start or Continue with an Err"), - ) + |> List.walk_until (Ok new_game) |state, pins| + when state is + Ok game -> + when game |> roll pins is + Ok updated_game -> Continue (Ok updated_game) + Err err -> Break (Err err) + + Err _ -> crash "Impossible, we don't start or Continue with an Err" # should be able to score a game with all zeros expect - maybe_game = create({ previous_rolls: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] }) - result = maybe_game |> Result.try(|game| score(game)) - result == Ok(0) + maybe_game = create { previous_rolls: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] } + result = maybe_game |> Result.try |game| score game + result == Ok 0 # should be able to replay this finished game from the start expect rolls = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] - result = replay_game(rolls) + result = replay_game rolls result |> Result.is_ok # should be able to score a game with no strikes or spares expect - maybe_game = create({ previous_rolls: [3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6] }) - result = maybe_game |> Result.try(|game| score(game)) - result == Ok(90) + maybe_game = create { previous_rolls: [3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6] } + result = maybe_game |> Result.try |game| score game + result == Ok 90 # should be able to replay this finished game from the start expect rolls = [3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6] - result = replay_game(rolls) + result = replay_game rolls result |> Result.is_ok # a spare followed by zeros is worth ten points expect - maybe_game = create({ previous_rolls: [6, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] }) - result = maybe_game |> Result.try(|game| score(game)) - result == Ok(10) + maybe_game = create { previous_rolls: [6, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] } + result = maybe_game |> Result.try |game| score game + result == Ok 10 # should be able to replay this finished game from the start expect rolls = [6, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] - result = replay_game(rolls) + result = replay_game rolls result |> Result.is_ok # points scored in the roll after a spare are counted twice expect - maybe_game = create({ previous_rolls: [6, 4, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] }) - result = maybe_game |> Result.try(|game| score(game)) - result == Ok(16) + maybe_game = create { previous_rolls: [6, 4, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] } + result = maybe_game |> Result.try |game| score game + result == Ok 16 # should be able to replay this finished game from the start expect rolls = [6, 4, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] - result = replay_game(rolls) + result = replay_game rolls result |> Result.is_ok # consecutive spares each get a one roll bonus expect - maybe_game = create({ previous_rolls: [5, 5, 3, 7, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] }) - result = maybe_game |> Result.try(|game| score(game)) - result == Ok(31) + maybe_game = create { previous_rolls: [5, 5, 3, 7, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] } + result = maybe_game |> Result.try |game| score game + result == Ok 31 # should be able to replay this finished game from the start expect rolls = [5, 5, 3, 7, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] - result = replay_game(rolls) + result = replay_game rolls result |> Result.is_ok # a spare in the last frame gets a one roll bonus that is counted once expect - maybe_game = create({ previous_rolls: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 3, 7] }) - result = maybe_game |> Result.try(|game| score(game)) - result == Ok(17) + maybe_game = create { previous_rolls: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 3, 7] } + result = maybe_game |> Result.try |game| score game + result == Ok 17 # should be able to replay this finished game from the start expect rolls = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 3, 7] - result = replay_game(rolls) + result = replay_game rolls result |> Result.is_ok # a strike earns ten points in a frame with a single roll expect - maybe_game = create({ previous_rolls: [10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] }) - result = maybe_game |> Result.try(|game| score(game)) - result == Ok(10) + maybe_game = create { previous_rolls: [10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] } + result = maybe_game |> Result.try |game| score game + result == Ok 10 # should be able to replay this finished game from the start expect rolls = [10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] - result = replay_game(rolls) + result = replay_game rolls result |> Result.is_ok # points scored in the two rolls after a strike are counted twice as a bonus expect - maybe_game = create({ previous_rolls: [10, 5, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] }) - result = maybe_game |> Result.try(|game| score(game)) - result == Ok(26) + maybe_game = create { previous_rolls: [10, 5, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] } + result = maybe_game |> Result.try |game| score game + result == Ok 26 # should be able to replay this finished game from the start expect rolls = [10, 5, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] - result = replay_game(rolls) + result = replay_game rolls result |> Result.is_ok # consecutive strikes each get the two roll bonus expect - maybe_game = create({ previous_rolls: [10, 10, 10, 5, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] }) - result = maybe_game |> Result.try(|game| score(game)) - result == Ok(81) + maybe_game = create { previous_rolls: [10, 10, 10, 5, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] } + result = maybe_game |> Result.try |game| score game + result == Ok 81 # should be able to replay this finished game from the start expect rolls = [10, 10, 10, 5, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] - result = replay_game(rolls) + result = replay_game rolls result |> Result.is_ok # a strike in the last frame gets a two roll bonus that is counted once expect - maybe_game = create({ previous_rolls: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 7, 1] }) - result = maybe_game |> Result.try(|game| score(game)) - result == Ok(18) + maybe_game = create { previous_rolls: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 7, 1] } + result = maybe_game |> Result.try |game| score game + result == Ok 18 # should be able to replay this finished game from the start expect rolls = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 7, 1] - result = replay_game(rolls) + result = replay_game rolls result |> Result.is_ok # rolling a spare with the two roll bonus does not get a bonus roll expect - maybe_game = create({ previous_rolls: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 7, 3] }) - result = maybe_game |> Result.try(|game| score(game)) - result == Ok(20) + maybe_game = create { previous_rolls: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 7, 3] } + result = maybe_game |> Result.try |game| score game + result == Ok 20 # should be able to replay this finished game from the start expect rolls = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 7, 3] - result = replay_game(rolls) + result = replay_game rolls result |> Result.is_ok # strikes with the two roll bonus do not get bonus rolls expect - maybe_game = create({ previous_rolls: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 10, 10] }) - result = maybe_game |> Result.try(|game| score(game)) - result == Ok(30) + maybe_game = create { previous_rolls: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 10, 10] } + result = maybe_game |> Result.try |game| score game + result == Ok 30 # should be able to replay this finished game from the start expect rolls = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 10, 10] - result = replay_game(rolls) + result = replay_game rolls result |> Result.is_ok # last two strikes followed by only last bonus with non strike points expect - maybe_game = create({ previous_rolls: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 10, 0, 1] }) - result = maybe_game |> Result.try(|game| score(game)) - result == Ok(31) + maybe_game = create { previous_rolls: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 10, 0, 1] } + result = maybe_game |> Result.try |game| score game + result == Ok 31 # should be able to replay this finished game from the start expect rolls = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 10, 0, 1] - result = replay_game(rolls) + result = replay_game rolls result |> Result.is_ok # a strike with the one roll bonus after a spare in the last frame does not get a bonus expect - maybe_game = create({ previous_rolls: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 3, 10] }) - result = maybe_game |> Result.try(|game| score(game)) - result == Ok(20) + maybe_game = create { previous_rolls: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 3, 10] } + result = maybe_game |> Result.try |game| score game + result == Ok 20 # should be able to replay this finished game from the start expect rolls = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 3, 10] - result = replay_game(rolls) + result = replay_game rolls result |> Result.is_ok # all strikes is a perfect game expect - maybe_game = create({ previous_rolls: [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10] }) - result = maybe_game |> Result.try(|game| score(game)) - result == Ok(300) + maybe_game = create { previous_rolls: [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10] } + result = maybe_game |> Result.try |game| score game + result == Ok 300 # should be able to replay this finished game from the start expect rolls = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10] - result = replay_game(rolls) + result = replay_game rolls result |> Result.is_ok # a roll cannot score more than 10 points expect - maybe_game = create({ previous_rolls: [] }) + maybe_game = create { previous_rolls: [] } result = maybe_game - |> Result.try( - |game| - game |> roll(11), - ) + |> Result.try |game| + game |> roll 11 result |> Result.is_err # two rolls in a frame cannot score more than 10 points expect - maybe_game = create({ previous_rolls: [5] }) + maybe_game = create { previous_rolls: [5] } result = maybe_game - |> Result.try( - |game| - game |> roll(6), - ) + |> Result.try |game| + game |> roll 6 result |> Result.is_err # bonus roll after a strike in the last frame cannot score more than 10 points expect - maybe_game = create({ previous_rolls: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10] }) + maybe_game = create { previous_rolls: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10] } result = maybe_game - |> Result.try( - |game| - game |> roll(11), - ) + |> Result.try |game| + game |> roll 11 result |> Result.is_err # two bonus rolls after a strike in the last frame cannot score more than 10 points expect - maybe_game = create({ previous_rolls: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 5] }) + maybe_game = create { previous_rolls: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 5] } result = maybe_game - |> Result.try( - |game| - game |> roll(6), - ) + |> Result.try |game| + game |> roll 6 result |> Result.is_err # two bonus rolls after a strike in the last frame can score more than 10 points if one is a strike expect - maybe_game = create({ previous_rolls: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 10, 6] }) - result = maybe_game |> Result.try(|game| score(game)) - result == Ok(26) + maybe_game = create { previous_rolls: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 10, 6] } + result = maybe_game |> Result.try |game| score game + result == Ok 26 # should be able to replay this finished game from the start expect rolls = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 10, 6] - result = replay_game(rolls) + result = replay_game rolls result |> Result.is_ok # the second bonus rolls after a strike in the last frame cannot be a strike if the first one is not a strike expect - maybe_game = create({ previous_rolls: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 6] }) + maybe_game = create { previous_rolls: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 6] } result = maybe_game - |> Result.try( - |game| - game |> roll(10), - ) + |> Result.try |game| + game |> roll 10 result |> Result.is_err # second bonus roll after a strike in the last frame cannot score more than 10 points expect - maybe_game = create({ previous_rolls: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 10] }) + maybe_game = create { previous_rolls: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 10] } result = maybe_game - |> Result.try( - |game| - game |> roll(11), - ) + |> Result.try |game| + game |> roll 11 result |> Result.is_err # an unstarted game cannot be scored expect - maybe_game = create({ previous_rolls: [] }) - result = maybe_game |> Result.try(|game| score(game)) + maybe_game = create { previous_rolls: [] } + result = maybe_game |> Result.try |game| score game result |> Result.is_err # an incomplete game cannot be scored expect - maybe_game = create({ previous_rolls: [0, 0] }) - result = maybe_game |> Result.try(|game| score(game)) + maybe_game = create { previous_rolls: [0, 0] } + result = maybe_game |> Result.try |game| score game result |> Result.is_err # cannot roll if game already has ten frames expect - maybe_game = create({ previous_rolls: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] }) + maybe_game = create { previous_rolls: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] } result = maybe_game - |> Result.try( - |game| - game |> roll(0), - ) + |> Result.try |game| + game |> roll 0 result |> Result.is_err # bonus rolls for a strike in the last frame must be rolled before score can be calculated expect - maybe_game = create({ previous_rolls: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10] }) - result = maybe_game |> Result.try(|game| score(game)) + maybe_game = create { previous_rolls: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10] } + result = maybe_game |> Result.try |game| score game result |> Result.is_err # both bonus rolls for a strike in the last frame must be rolled before score can be calculated expect - maybe_game = create({ previous_rolls: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 10] }) - result = maybe_game |> Result.try(|game| score(game)) + maybe_game = create { previous_rolls: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 10] } + result = maybe_game |> Result.try |game| score game result |> Result.is_err # bonus roll for a spare in the last frame must be rolled before score can be calculated expect - maybe_game = create({ previous_rolls: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 3] }) - result = maybe_game |> Result.try(|game| score(game)) + maybe_game = create { previous_rolls: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 3] } + result = maybe_game |> Result.try |game| score game result |> Result.is_err # cannot roll after bonus roll for spare expect - maybe_game = create({ previous_rolls: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 3, 2] }) + maybe_game = create { previous_rolls: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 3, 2] } result = maybe_game - |> Result.try( - |game| - game |> roll(2), - ) + |> Result.try |game| + game |> roll 2 result |> Result.is_err # cannot roll after bonus rolls for strike expect - maybe_game = create({ previous_rolls: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 3, 2] }) + maybe_game = create { previous_rolls: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 3, 2] } result = maybe_game - |> Result.try( - |game| - game |> roll(2), - ) + |> Result.try |game| + game |> roll 2 result |> Result.is_err diff --git a/exercises/practice/change/change-test.roc b/exercises/practice/change/change-test.roc index c37ca304..35705306 100644 --- a/exercises/practice/change/change-test.roc +++ b/exercises/practice/change/change-test.roc @@ -1,6 +1,6 @@ # These tests are auto-generated with test data from: # https://github.com/exercism/problem-specifications/tree/main/exercises/change/canonical-data.json -# File last updated on 2025-01-04 +# File last updated on 2025-07-26 app [main!] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.19.0/Hj-J_zxz7V9YurCSTFcFdu6cQJie4guzsPMUi5kBYUk.tar.br", } @@ -8,79 +8,79 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line!("") + Stdout.line! "" import Change exposing [find_fewest_coins] # change for 1 cent expect coins = [1, 5, 10, 25] - result = coins |> find_fewest_coins(1) - result == Ok([1]) + result = coins |> find_fewest_coins 1 + result == Ok [1] # single coin change expect coins = [1, 5, 10, 25, 100] - result = coins |> find_fewest_coins(25) - result == Ok([25]) + result = coins |> find_fewest_coins 25 + result == Ok [25] # multiple coin change expect coins = [1, 5, 10, 25, 100] - result = coins |> find_fewest_coins(15) - result == Ok([5, 10]) + result = coins |> find_fewest_coins 15 + result == Ok [5, 10] # change with Lilliputian Coins expect coins = [1, 4, 15, 20, 50] - result = coins |> find_fewest_coins(23) - result == Ok([4, 4, 15]) + result = coins |> find_fewest_coins 23 + result == Ok [4, 4, 15] # change with Lower Elbonia Coins expect coins = [1, 5, 10, 21, 25] - result = coins |> find_fewest_coins(63) - result == Ok([21, 21, 21]) + result = coins |> find_fewest_coins 63 + result == Ok [21, 21, 21] # large target values expect coins = [1, 2, 5, 10, 20, 50, 100] - result = coins |> find_fewest_coins(999) - result == Ok([2, 2, 5, 20, 20, 50, 100, 100, 100, 100, 100, 100, 100, 100, 100]) + result = coins |> find_fewest_coins 999 + result == Ok [2, 2, 5, 20, 20, 50, 100, 100, 100, 100, 100, 100, 100, 100, 100] # possible change without unit coins available expect coins = [2, 5, 10, 20, 50] - result = coins |> find_fewest_coins(21) - result == Ok([2, 2, 2, 5, 10]) + result = coins |> find_fewest_coins 21 + result == Ok [2, 2, 2, 5, 10] # another possible change without unit coins available expect coins = [4, 5] - result = coins |> find_fewest_coins(27) - result == Ok([4, 4, 4, 5, 5, 5]) + result = coins |> find_fewest_coins 27 + result == Ok [4, 4, 4, 5, 5, 5] # a greedy approach is not optimal expect coins = [1, 10, 11] - result = coins |> find_fewest_coins(20) - result == Ok([10, 10]) + result = coins |> find_fewest_coins 20 + result == Ok [10, 10] # no coins make 0 change expect coins = [1, 5, 10, 21, 25] - result = coins |> find_fewest_coins(0) - result == Ok([]) + result = coins |> find_fewest_coins 0 + result == Ok [] # error testing for change smaller than the smallest of coins expect coins = [5, 10] - result = coins |> find_fewest_coins(3) + result = coins |> find_fewest_coins 3 result |> Result.is_err # error if no combination can add up to target expect coins = [5, 10] - result = coins |> find_fewest_coins(94) + result = coins |> find_fewest_coins 94 result |> Result.is_err diff --git a/exercises/practice/circular-buffer/circular-buffer-test.roc b/exercises/practice/circular-buffer/circular-buffer-test.roc index e22a9172..e37a4731 100644 --- a/exercises/practice/circular-buffer/circular-buffer-test.roc +++ b/exercises/practice/circular-buffer/circular-buffer-test.roc @@ -1,6 +1,6 @@ # These tests are auto-generated with test data from: # https://github.com/exercism/problem-specifications/tree/main/exercises/circular-buffer/canonical-data.json -# File last updated on 2025-01-04 +# File last updated on 2025-07-26 app [main!] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.19.0/Hj-J_zxz7V9YurCSTFcFdu6cQJie4guzsPMUi5kBYUk.tar.br", } @@ -8,64 +8,64 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line!("") + Stdout.line! "" import CircularBuffer exposing [create, read, write, overwrite, clear] # reading empty buffer should fail run_operations1 = |_| result = - create({ capacity: 1 }) + create { capacity: 1 } |> |buffer_before_read| read_result = buffer_before_read |> read - expect read_result == Err(BufferEmpty) + expect read_result == Err BufferEmpty buffer_before_read - Ok(result) + Ok result expect - result = run_operations1({}) + result = run_operations1 {} result |> Result.is_ok # can read an item just written run_operations2 = |_| result = - create({ capacity: 1 }) - |> write(1)? + create { capacity: 1 } + |> write? 1 |> read? |> |read_result| expect read_result.value == 1 read_result.new_buffer - Ok(result) + Ok result expect - result = run_operations2({}) + result = run_operations2 {} result |> Result.is_ok # each item may only be read once run_operations3 = |_| result = - create({ capacity: 1 }) - |> write(1)? + create { capacity: 1 } + |> write? 1 |> read? |> |read_result| expect read_result.value == 1 read_result.new_buffer |> |buffer_before_read| read_result = buffer_before_read |> read - expect read_result == Err(BufferEmpty) + expect read_result == Err BufferEmpty buffer_before_read - Ok(result) + Ok result expect - result = run_operations3({}) + result = run_operations3 {} result |> Result.is_ok # items are read in the order they are written run_operations4 = |_| result = - create({ capacity: 2 }) - |> write(1)? - |> write(2)? + create { capacity: 2 } + |> write? 1 + |> write? 2 |> read? |> |read_result| expect read_result.value == 1 @@ -74,58 +74,58 @@ run_operations4 = |_| |> |read_result| expect read_result.value == 2 read_result.new_buffer - Ok(result) + Ok result expect - result = run_operations4({}) + result = run_operations4 {} result |> Result.is_ok # full buffer can't be written to run_operations5 = |_| result = - create({ capacity: 1 }) - |> write(1)? + create { capacity: 1 } + |> write? 1 |> |buffer_before_write| - write_result = buffer_before_write |> write(2) - expect write_result == Err(BufferFull) + write_result = buffer_before_write |> write 2 + expect write_result == Err BufferFull buffer_before_write - Ok(result) + Ok result expect - result = run_operations5({}) + result = run_operations5 {} result |> Result.is_ok # a read frees up capacity for another write run_operations6 = |_| result = - create({ capacity: 1 }) - |> write(1)? + create { capacity: 1 } + |> write? 1 |> read? |> |read_result| expect read_result.value == 1 read_result.new_buffer - |> write(2)? + |> write? 2 |> read? |> |read_result| expect read_result.value == 2 read_result.new_buffer - Ok(result) + Ok result expect - result = run_operations6({}) + result = run_operations6 {} result |> Result.is_ok # read position is maintained even across multiple writes run_operations7 = |_| result = - create({ capacity: 3 }) - |> write(1)? - |> write(2)? + create { capacity: 3 } + |> write? 1 + |> write? 2 |> read? |> |read_result| expect read_result.value == 1 read_result.new_buffer - |> write(3)? + |> write? 3 |> read? |> |read_result| expect read_result.value == 2 @@ -134,67 +134,67 @@ run_operations7 = |_| |> |read_result| expect read_result.value == 3 read_result.new_buffer - Ok(result) + Ok result expect - result = run_operations7({}) + result = run_operations7 {} result |> Result.is_ok # items cleared out of buffer can't be read run_operations8 = |_| result = - create({ capacity: 1 }) - |> write(1)? + create { capacity: 1 } + |> write? 1 |> clear |> |buffer_before_read| read_result = buffer_before_read |> read - expect read_result == Err(BufferEmpty) + expect read_result == Err BufferEmpty buffer_before_read - Ok(result) + Ok result expect - result = run_operations8({}) + result = run_operations8 {} result |> Result.is_ok # clear frees up capacity for another write run_operations9 = |_| result = - create({ capacity: 1 }) - |> write(1)? + create { capacity: 1 } + |> write? 1 |> clear - |> write(2)? + |> write? 2 |> read? |> |read_result| expect read_result.value == 2 read_result.new_buffer - Ok(result) + Ok result expect - result = run_operations9({}) + result = run_operations9 {} result |> Result.is_ok # clear does nothing on empty buffer run_operations10 = |_| result = - create({ capacity: 1 }) + create { capacity: 1 } |> clear - |> write(1)? + |> write? 1 |> read? |> |read_result| expect read_result.value == 1 read_result.new_buffer - Ok(result) + Ok result expect - result = run_operations10({}) + result = run_operations10 {} result |> Result.is_ok # overwrite acts like write on non-full buffer run_operations11 = |_| result = - create({ capacity: 2 }) - |> write(1)? - |> overwrite(2) + create { capacity: 2 } + |> write? 1 + |> overwrite 2 |> read? |> |read_result| expect read_result.value == 1 @@ -203,19 +203,19 @@ run_operations11 = |_| |> |read_result| expect read_result.value == 2 read_result.new_buffer - Ok(result) + Ok result expect - result = run_operations11({}) + result = run_operations11 {} result |> Result.is_ok # overwrite replaces the oldest item on full buffer run_operations12 = |_| result = - create({ capacity: 2 }) - |> write(1)? - |> write(2)? - |> overwrite(3) + create { capacity: 2 } + |> write? 1 + |> write? 2 + |> overwrite 3 |> read? |> |read_result| expect read_result.value == 2 @@ -224,25 +224,25 @@ run_operations12 = |_| |> |read_result| expect read_result.value == 3 read_result.new_buffer - Ok(result) + Ok result expect - result = run_operations12({}) + result = run_operations12 {} result |> Result.is_ok # overwrite replaces the oldest item remaining in buffer following a read run_operations13 = |_| result = - create({ capacity: 3 }) - |> write(1)? - |> write(2)? - |> write(3)? + create { capacity: 3 } + |> write? 1 + |> write? 2 + |> write? 3 |> read? |> |read_result| expect read_result.value == 1 read_result.new_buffer - |> write(4)? - |> overwrite(5) + |> write? 4 + |> overwrite 5 |> read? |> |read_result| expect read_result.value == 3 @@ -255,21 +255,21 @@ run_operations13 = |_| |> |read_result| expect read_result.value == 5 read_result.new_buffer - Ok(result) + Ok result expect - result = run_operations13({}) + result = run_operations13 {} result |> Result.is_ok # initial clear does not affect wrapping around run_operations14 = |_| result = - create({ capacity: 2 }) + create { capacity: 2 } |> clear - |> write(1)? - |> write(2)? - |> overwrite(3) - |> overwrite(4) + |> write? 1 + |> write? 2 + |> overwrite 3 + |> overwrite 4 |> read? |> |read_result| expect read_result.value == 3 @@ -280,11 +280,11 @@ run_operations14 = |_| read_result.new_buffer |> |buffer_before_read| read_result = buffer_before_read |> read - expect read_result == Err(BufferEmpty) + expect read_result == Err BufferEmpty buffer_before_read - Ok(result) + Ok result expect - result = run_operations14({}) + result = run_operations14 {} result |> Result.is_ok diff --git a/exercises/practice/clock/clock-test.roc b/exercises/practice/clock/clock-test.roc index a353f2a7..3e7d74f9 100644 --- a/exercises/practice/clock/clock-test.roc +++ b/exercises/practice/clock/clock-test.roc @@ -1,6 +1,6 @@ # These tests are auto-generated with test data from: # https://github.com/exercism/problem-specifications/tree/main/exercises/clock/canonical-data.json -# File last updated on 2025-01-04 +# File last updated on 2025-07-26 app [main!] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.19.0/Hj-J_zxz7V9YurCSTFcFdu6cQJie4guzsPMUi5kBYUk.tar.br", } @@ -8,7 +8,7 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line!("") + Stdout.line! "" import Clock exposing [create, add, subtract, to_str] @@ -18,140 +18,140 @@ import Clock exposing [create, add, subtract, to_str] # on the hour expect - clock = create({ hours: 8 }) + clock = create { hours: 8 } result = clock |> to_str expected = "08:00" result == expected # past the hour expect - clock = create({ hours: 11, minutes: 9 }) + clock = create { hours: 11, minutes: 9 } result = clock |> to_str expected = "11:09" result == expected # midnight is zero hours expect - clock = create({ hours: 24 }) + clock = create { hours: 24 } result = clock |> to_str expected = "00:00" result == expected # hour rolls over expect - clock = create({ hours: 25 }) + clock = create { hours: 25 } result = clock |> to_str expected = "01:00" result == expected # hour rolls over continuously expect - clock = create({ hours: 100 }) + clock = create { hours: 100 } result = clock |> to_str expected = "04:00" result == expected # sixty minutes is next hour expect - clock = create({ hours: 1, minutes: 60 }) + clock = create { hours: 1, minutes: 60 } result = clock |> to_str expected = "02:00" result == expected # minutes roll over expect - clock = create({ minutes: 160 }) + clock = create { minutes: 160 } result = clock |> to_str expected = "02:40" result == expected # minutes roll over continuously expect - clock = create({ minutes: 1723 }) + clock = create { minutes: 1723 } result = clock |> to_str expected = "04:43" result == expected # hour and minutes roll over expect - clock = create({ hours: 25, minutes: 160 }) + clock = create { hours: 25, minutes: 160 } result = clock |> to_str expected = "03:40" result == expected # hour and minutes roll over continuously expect - clock = create({ hours: 201, minutes: 3001 }) + clock = create { hours: 201, minutes: 3001 } result = clock |> to_str expected = "11:01" result == expected # hour and minutes roll over to exactly midnight expect - clock = create({ hours: 72, minutes: 8640 }) + clock = create { hours: 72, minutes: 8640 } result = clock |> to_str expected = "00:00" result == expected # negative hour expect - clock = create({ hours: -1, minutes: 15 }) + clock = create { hours: -1, minutes: 15 } result = clock |> to_str expected = "23:15" result == expected # negative hour rolls over expect - clock = create({ hours: -25 }) + clock = create { hours: -25 } result = clock |> to_str expected = "23:00" result == expected # negative hour rolls over continuously expect - clock = create({ hours: -91 }) + clock = create { hours: -91 } result = clock |> to_str expected = "05:00" result == expected # negative minutes expect - clock = create({ hours: 1, minutes: -40 }) + clock = create { hours: 1, minutes: -40 } result = clock |> to_str expected = "00:20" result == expected # negative minutes roll over expect - clock = create({ hours: 1, minutes: -160 }) + clock = create { hours: 1, minutes: -160 } result = clock |> to_str expected = "22:20" result == expected # negative minutes roll over continuously expect - clock = create({ hours: 1, minutes: -4820 }) + clock = create { hours: 1, minutes: -4820 } result = clock |> to_str expected = "16:40" result == expected # negative sixty minutes is previous hour expect - clock = create({ hours: 2, minutes: -60 }) + clock = create { hours: 2, minutes: -60 } result = clock |> to_str expected = "01:00" result == expected # negative hour and minutes both roll over expect - clock = create({ hours: -25, minutes: -160 }) + clock = create { hours: -25, minutes: -160 } result = clock |> to_str expected = "20:20" result == expected # negative hour and minutes both roll over continuously expect - clock = create({ hours: -121, minutes: -5810 }) + clock = create { hours: -121, minutes: -5810 } result = clock |> to_str expected = "22:10" result == expected @@ -162,57 +162,57 @@ expect # add minutes expect - clock = create({ hours: 10 }) - result = clock |> add({ minutes: 3 }) |> to_str + clock = create { hours: 10 } + result = clock |> add { minutes: 3 } |> to_str expected = "10:03" result == expected # add no minutes expect - clock = create({ hours: 6, minutes: 41 }) - result = clock |> add({ minutes: 0 }) |> to_str + clock = create { hours: 6, minutes: 41 } + result = clock |> add { minutes: 0 } |> to_str expected = "06:41" result == expected # add to next hour expect - clock = create({ minutes: 45 }) - result = clock |> add({ minutes: 40 }) |> to_str + clock = create { minutes: 45 } + result = clock |> add { minutes: 40 } |> to_str expected = "01:25" result == expected # add more than one hour expect - clock = create({ hours: 10 }) - result = clock |> add({ minutes: 61 }) |> to_str + clock = create { hours: 10 } + result = clock |> add { minutes: 61 } |> to_str expected = "11:01" result == expected # add more than two hours with carry expect - clock = create({ minutes: 45 }) - result = clock |> add({ minutes: 160 }) |> to_str + clock = create { minutes: 45 } + result = clock |> add { minutes: 160 } |> to_str expected = "03:25" result == expected # add across midnight expect - clock = create({ hours: 23, minutes: 59 }) - result = clock |> add({ minutes: 2 }) |> to_str + clock = create { hours: 23, minutes: 59 } + result = clock |> add { minutes: 2 } |> to_str expected = "00:01" result == expected # add more than one day (1500 min = 25 hrs) expect - clock = create({ hours: 5, minutes: 32 }) - result = clock |> add({ minutes: 1500 }) |> to_str + clock = create { hours: 5, minutes: 32 } + result = clock |> add { minutes: 1500 } |> to_str expected = "06:32" result == expected # add more than two days expect - clock = create({ hours: 1, minutes: 1 }) - result = clock |> add({ minutes: 3500 }) |> to_str + clock = create { hours: 1, minutes: 1 } + result = clock |> add { minutes: 3500 } |> to_str expected = "11:21" result == expected @@ -222,57 +222,57 @@ expect # subtract minutes expect - clock = create({ hours: 10, minutes: 3 }) - result = clock |> subtract({ minutes: 3 }) |> to_str + clock = create { hours: 10, minutes: 3 } + result = clock |> subtract { minutes: 3 } |> to_str expected = "10:00" result == expected # subtract to previous hour expect - clock = create({ hours: 10, minutes: 3 }) - result = clock |> subtract({ minutes: 30 }) |> to_str + clock = create { hours: 10, minutes: 3 } + result = clock |> subtract { minutes: 30 } |> to_str expected = "09:33" result == expected # subtract more than an hour expect - clock = create({ hours: 10, minutes: 3 }) - result = clock |> subtract({ minutes: 70 }) |> to_str + clock = create { hours: 10, minutes: 3 } + result = clock |> subtract { minutes: 70 } |> to_str expected = "08:53" result == expected # subtract across midnight expect - clock = create({ minutes: 3 }) - result = clock |> subtract({ minutes: 4 }) |> to_str + clock = create { minutes: 3 } + result = clock |> subtract { minutes: 4 } |> to_str expected = "23:59" result == expected # subtract more than two hours expect - clock = create({}) - result = clock |> subtract({ minutes: 160 }) |> to_str + clock = create {} + result = clock |> subtract { minutes: 160 } |> to_str expected = "21:20" result == expected # subtract more than two hours with borrow expect - clock = create({ hours: 6, minutes: 15 }) - result = clock |> subtract({ minutes: 160 }) |> to_str + clock = create { hours: 6, minutes: 15 } + result = clock |> subtract { minutes: 160 } |> to_str expected = "03:35" result == expected # subtract more than one day (1500 min = 25 hrs) expect - clock = create({ hours: 5, minutes: 32 }) - result = clock |> subtract({ minutes: 1500 }) |> to_str + clock = create { hours: 5, minutes: 32 } + result = clock |> subtract { minutes: 1500 } |> to_str expected = "04:32" result == expected # subtract more than two days expect - clock = create({ hours: 2, minutes: 20 }) - result = clock |> subtract({ minutes: 3000 }) |> to_str + clock = create { hours: 2, minutes: 20 } + result = clock |> subtract { minutes: 3000 } |> to_str expected = "00:20" result == expected @@ -282,98 +282,98 @@ expect # clocks with same time expect - clock1 = create({ hours: 15, minutes: 37 }) - clock2 = create({ hours: 15, minutes: 37 }) + clock1 = create { hours: 15, minutes: 37 } + clock2 = create { hours: 15, minutes: 37 } clock1 == clock2 # clocks a minute apart expect - clock1 = create({ hours: 15, minutes: 36 }) - clock2 = create({ hours: 15, minutes: 37 }) + clock1 = create { hours: 15, minutes: 36 } + clock2 = create { hours: 15, minutes: 37 } clock1 != clock2 # clocks an hour apart expect - clock1 = create({ hours: 14, minutes: 37 }) - clock2 = create({ hours: 15, minutes: 37 }) + clock1 = create { hours: 14, minutes: 37 } + clock2 = create { hours: 15, minutes: 37 } clock1 != clock2 # clocks with hour overflow expect - clock1 = create({ hours: 10, minutes: 37 }) - clock2 = create({ hours: 34, minutes: 37 }) + clock1 = create { hours: 10, minutes: 37 } + clock2 = create { hours: 34, minutes: 37 } clock1 == clock2 # clocks with hour overflow by several days expect - clock1 = create({ hours: 3, minutes: 11 }) - clock2 = create({ hours: 99, minutes: 11 }) + clock1 = create { hours: 3, minutes: 11 } + clock2 = create { hours: 99, minutes: 11 } clock1 == clock2 # clocks with negative hour expect - clock1 = create({ hours: 22, minutes: 40 }) - clock2 = create({ hours: -2, minutes: 40 }) + clock1 = create { hours: 22, minutes: 40 } + clock2 = create { hours: -2, minutes: 40 } clock1 == clock2 # clocks with negative hour that wraps expect - clock1 = create({ hours: 17, minutes: 3 }) - clock2 = create({ hours: -31, minutes: 3 }) + clock1 = create { hours: 17, minutes: 3 } + clock2 = create { hours: -31, minutes: 3 } clock1 == clock2 # clocks with negative hour that wraps multiple times expect - clock1 = create({ hours: 13, minutes: 49 }) - clock2 = create({ hours: -83, minutes: 49 }) + clock1 = create { hours: 13, minutes: 49 } + clock2 = create { hours: -83, minutes: 49 } clock1 == clock2 # clocks with minute overflow expect - clock1 = create({ minutes: 1 }) - clock2 = create({ minutes: 1441 }) + clock1 = create { minutes: 1 } + clock2 = create { minutes: 1441 } clock1 == clock2 # clocks with minute overflow by several days expect - clock1 = create({ hours: 2, minutes: 2 }) - clock2 = create({ hours: 2, minutes: 4322 }) + clock1 = create { hours: 2, minutes: 2 } + clock2 = create { hours: 2, minutes: 4322 } clock1 == clock2 # clocks with negative minute expect - clock1 = create({ hours: 2, minutes: 40 }) - clock2 = create({ hours: 3, minutes: -20 }) + clock1 = create { hours: 2, minutes: 40 } + clock2 = create { hours: 3, minutes: -20 } clock1 == clock2 # clocks with negative minute that wraps expect - clock1 = create({ hours: 4, minutes: 10 }) - clock2 = create({ hours: 5, minutes: -1490 }) + clock1 = create { hours: 4, minutes: 10 } + clock2 = create { hours: 5, minutes: -1490 } clock1 == clock2 # clocks with negative minute that wraps multiple times expect - clock1 = create({ hours: 6, minutes: 15 }) - clock2 = create({ hours: 6, minutes: -4305 }) + clock1 = create { hours: 6, minutes: 15 } + clock2 = create { hours: 6, minutes: -4305 } clock1 == clock2 # clocks with negative hours and minutes expect - clock1 = create({ hours: 7, minutes: 32 }) - clock2 = create({ hours: -12, minutes: -268 }) + clock1 = create { hours: 7, minutes: 32 } + clock2 = create { hours: -12, minutes: -268 } clock1 == clock2 # clocks with negative hours and minutes that wrap expect - clock1 = create({ hours: 18, minutes: 7 }) - clock2 = create({ hours: -54, minutes: -11513 }) + clock1 = create { hours: 18, minutes: 7 } + clock2 = create { hours: -54, minutes: -11513 } clock1 == clock2 # full clock and zeroed clock expect - clock1 = create({ hours: 24 }) - clock2 = create({}) + clock1 = create { hours: 24 } + clock2 = create {} clock1 == clock2 ## @@ -382,43 +382,43 @@ expect # Can create a clock with max I64 values expect - clock = create({ hours: 9223372036854775807, minutes: 9223372036854775807 }) + clock = create { hours: 9223372036854775807, minutes: 9223372036854775807 } result = clock |> to_str expected = "01:07" result == expected # Can create a clock with min I64 values expect - clock = create({ hours: -9223372036854775808, minutes: -9223372036854775808 }) + clock = create { hours: -9223372036854775808, minutes: -9223372036854775808 } result = clock |> to_str expected = "21:52" result == expected # Can add max I64 values to a clock expect - clock = create({ hours: 23, minutes: 59 }) - result = clock |> add({ minutes: 9223372036854775807 }) |> to_str + clock = create { hours: 23, minutes: 59 } + result = clock |> add { minutes: 9223372036854775807 } |> to_str expected = "18:06" result == expected # Can add min I64 values to a clock expect - clock = create({ hours: 23, minutes: 59 }) - result = clock |> add({ minutes: -9223372036854775808 }) |> to_str + clock = create { hours: 23, minutes: 59 } + result = clock |> add { minutes: -9223372036854775808 } |> to_str expected = "05:51" result == expected # Can subtract max I64 values from a clock expect - clock = create({ hours: 23, minutes: 59 }) - result = clock |> subtract({ minutes: 9223372036854775807 }) |> to_str + clock = create { hours: 23, minutes: 59 } + result = clock |> subtract { minutes: 9223372036854775807 } |> to_str expected = "05:52" result == expected # Can subtract min I64 values from a clock expect - clock = create({ hours: 23, minutes: 59 }) - result = clock |> subtract({ minutes: -9223372036854775808 }) |> to_str + clock = create { hours: 23, minutes: 59 } + result = clock |> subtract { minutes: -9223372036854775808 } |> to_str expected = "18:07" result == expected diff --git a/exercises/practice/collatz-conjecture/collatz-conjecture-test.roc b/exercises/practice/collatz-conjecture/collatz-conjecture-test.roc index bd3feeeb..2e4b0c32 100644 --- a/exercises/practice/collatz-conjecture/collatz-conjecture-test.roc +++ b/exercises/practice/collatz-conjecture/collatz-conjecture-test.roc @@ -1,6 +1,6 @@ # These tests are auto-generated with test data from: # https://github.com/exercism/problem-specifications/tree/main/exercises/collatz-conjecture/canonical-data.json -# File last updated on 2025-01-04 +# File last updated on 2025-07-26 app [main!] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.19.0/Hj-J_zxz7V9YurCSTFcFdu6cQJie4guzsPMUi5kBYUk.tar.br", } @@ -8,32 +8,32 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line!("") + Stdout.line! "" import CollatzConjecture exposing [steps] # zero steps for one expect - result = steps(1) - result == Ok(0) + result = steps 1 + result == Ok 0 # divide if even expect - result = steps(16) - result == Ok(4) + result = steps 16 + result == Ok 4 # even and odd steps expect - result = steps(12) - result == Ok(9) + result = steps 12 + result == Ok 9 # large number of even and odd steps expect - result = steps(1000000) - result == Ok(152) + result = steps 1000000 + result == Ok 152 # zero is an error expect - result = steps(0) - Result.is_err(result) + result = steps 0 + Result.is_err result diff --git a/exercises/practice/complex-numbers/complex-numbers-test.roc b/exercises/practice/complex-numbers/complex-numbers-test.roc index 8c605229..9d818e03 100644 --- a/exercises/practice/complex-numbers/complex-numbers-test.roc +++ b/exercises/practice/complex-numbers/complex-numbers-test.roc @@ -1,6 +1,6 @@ # These tests are auto-generated with test data from: # https://github.com/exercism/problem-specifications/tree/main/exercises/complex-numbers/canonical-data.json -# File last updated on 2025-01-04 +# File last updated on 2025-07-26 app [main!] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.19.0/Hj-J_zxz7V9YurCSTFcFdu6cQJie4guzsPMUi5kBYUk.tar.br", } @@ -8,12 +8,12 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line!("") + Stdout.line! "" import ComplexNumbers exposing [real, imaginary, add, sub, mul, div, conjugate, abs, exp] is_approx_eq = |z1, z2| - z1.re |> Num.is_approx_eq(z2.re, {}) and z1.im |> Num.is_approx_eq(z2.im, {}) + z1.re |> Num.is_approx_eq z2.re {} and z1.im |> Num.is_approx_eq z2.im {} ### ### Real part @@ -22,20 +22,20 @@ is_approx_eq = |z1, z2| # Real part of a purely real number expect z = { re: 1, im: 0 } - result = real(z) - result |> Num.is_approx_eq(1, {}) + result = real z + result |> Num.is_approx_eq 1 {} # Real part of a purely imaginary number expect z = { re: 0, im: 1 } - result = real(z) - result |> Num.is_approx_eq(0, {}) + result = real z + result |> Num.is_approx_eq 0 {} # Real part of a number with real and imaginary part expect z = { re: 1, im: 2 } - result = real(z) - result |> Num.is_approx_eq(1, {}) + result = real z + result |> Num.is_approx_eq 1 {} ### ### Imaginary part @@ -44,20 +44,20 @@ expect # Imaginary part of a purely real number expect z = { re: 1, im: 0 } - result = imaginary(z) - result |> Num.is_approx_eq(0, {}) + result = imaginary z + result |> Num.is_approx_eq 0 {} # Imaginary part of a purely imaginary number expect z = { re: 0, im: 1 } - result = imaginary(z) - result |> Num.is_approx_eq(1, {}) + result = imaginary z + result |> Num.is_approx_eq 1 {} # Imaginary part of a number with real and imaginary part expect z = { re: 1, im: 2 } - result = imaginary(z) - result |> Num.is_approx_eq(2, {}) + result = imaginary z + result |> Num.is_approx_eq 2 {} ### ### Imaginary unit @@ -73,25 +73,25 @@ expect expect z1 = { re: 1, im: 0 } z2 = { re: 2, im: 0 } - result = z1 |> add(z2) + result = z1 |> add z2 expected = { re: 3, im: 0 } - result |> is_approx_eq(expected) + result |> is_approx_eq expected # Add purely imaginary numbers expect z1 = { re: 0, im: 1 } z2 = { re: 0, im: 2 } - result = z1 |> add(z2) + result = z1 |> add z2 expected = { re: 0, im: 3 } - result |> is_approx_eq(expected) + result |> is_approx_eq expected # Add numbers with real and imaginary part expect z1 = { re: 1, im: 2 } z2 = { re: 3, im: 4 } - result = z1 |> add(z2) + result = z1 |> add z2 expected = { re: 4, im: 6 } - result |> is_approx_eq(expected) + result |> is_approx_eq expected ## Subtraction @@ -99,25 +99,25 @@ expect expect z1 = { re: 1, im: 0 } z2 = { re: 2, im: 0 } - result = z1 |> sub(z2) + result = z1 |> sub z2 expected = { re: -1, im: 0 } - result |> is_approx_eq(expected) + result |> is_approx_eq expected # Subtract purely imaginary numbers expect z1 = { re: 0, im: 1 } z2 = { re: 0, im: 2 } - result = z1 |> sub(z2) + result = z1 |> sub z2 expected = { re: 0, im: -1 } - result |> is_approx_eq(expected) + result |> is_approx_eq expected # Subtract numbers with real and imaginary part expect z1 = { re: 1, im: 2 } z2 = { re: 3, im: 4 } - result = z1 |> sub(z2) + result = z1 |> sub z2 expected = { re: -2, im: -2 } - result |> is_approx_eq(expected) + result |> is_approx_eq expected ## Multiplication @@ -125,25 +125,25 @@ expect expect z1 = { re: 1, im: 0 } z2 = { re: 2, im: 0 } - result = z1 |> mul(z2) + result = z1 |> mul z2 expected = { re: 2, im: 0 } - result |> is_approx_eq(expected) + result |> is_approx_eq expected # Multiply purely imaginary numbers expect z1 = { re: 0, im: 1 } z2 = { re: 0, im: 2 } - result = z1 |> mul(z2) + result = z1 |> mul z2 expected = { re: -2, im: 0 } - result |> is_approx_eq(expected) + result |> is_approx_eq expected # Multiply numbers with real and imaginary part expect z1 = { re: 1, im: 2 } z2 = { re: 3, im: 4 } - result = z1 |> mul(z2) + result = z1 |> mul z2 expected = { re: -5, im: 10 } - result |> is_approx_eq(expected) + result |> is_approx_eq expected ## Division @@ -151,25 +151,25 @@ expect expect z1 = { re: 1, im: 0 } z2 = { re: 2, im: 0 } - result = z1 |> div(z2) + result = z1 |> div z2 expected = { re: 0.5, im: 0 } - result |> is_approx_eq(expected) + result |> is_approx_eq expected # Divide purely imaginary numbers expect z1 = { re: 0, im: 1 } z2 = { re: 0, im: 2 } - result = z1 |> div(z2) + result = z1 |> div z2 expected = { re: 0.5, im: 0 } - result |> is_approx_eq(expected) + result |> is_approx_eq expected # Divide numbers with real and imaginary part expect z1 = { re: 1, im: 2 } z2 = { re: 3, im: 4 } - result = z1 |> div(z2) + result = z1 |> div z2 expected = { re: 0.44, im: 0.08 } - result |> is_approx_eq(expected) + result |> is_approx_eq expected ### ### Absolute value @@ -178,32 +178,32 @@ expect # Absolute value of a positive purely real number expect z = { re: 5, im: 0 } - result = abs(z) - result |> Num.is_approx_eq(5, {}) + result = abs z + result |> Num.is_approx_eq 5 {} # Absolute value of a negative purely real number expect z = { re: -5, im: 0 } - result = abs(z) - result |> Num.is_approx_eq(5, {}) + result = abs z + result |> Num.is_approx_eq 5 {} # Absolute value of a purely imaginary number with positive imaginary part expect z = { re: 0, im: 5 } - result = abs(z) - result |> Num.is_approx_eq(5, {}) + result = abs z + result |> Num.is_approx_eq 5 {} # Absolute value of a purely imaginary number with negative imaginary part expect z = { re: 0, im: -5 } - result = abs(z) - result |> Num.is_approx_eq(5, {}) + result = abs z + result |> Num.is_approx_eq 5 {} # Absolute value of a number with real and imaginary part expect z = { re: 3, im: 4 } - result = abs(z) - result |> Num.is_approx_eq(5, {}) + result = abs z + result |> Num.is_approx_eq 5 {} ### ### Complex conjugate @@ -212,23 +212,23 @@ expect # Conjugate a purely real number expect z = { re: 5, im: 0 } - result = conjugate(z) + result = conjugate z expected = { re: 5, im: 0 } - result |> is_approx_eq(expected) + result |> is_approx_eq expected # Conjugate a purely imaginary number expect z = { re: 0, im: 5 } - result = conjugate(z) + result = conjugate z expected = { re: 0, im: -5 } - result |> is_approx_eq(expected) + result |> is_approx_eq expected # Conjugate a number with real and imaginary part expect z = { re: 1, im: 1 } - result = conjugate(z) + result = conjugate z expected = { re: 1, im: -1 } - result |> is_approx_eq(expected) + result |> is_approx_eq expected ### ### Complex exponential function @@ -237,37 +237,37 @@ expect # Euler's identity/formula expect z = { re: 0, im: Num.pi } - result = exp(z) + result = exp z expected = { re: -1, im: 0 } - result |> is_approx_eq(expected) + result |> is_approx_eq expected # Exponential of 0 expect z = { re: 0, im: 0 } - result = exp(z) + result = exp z expected = { re: 1, im: 0 } - result |> is_approx_eq(expected) + result |> is_approx_eq expected # Exponential of a purely real number expect z = { re: 1, im: 0 } - result = exp(z) + result = exp z expected = { re: Num.e, im: 0 } - result |> is_approx_eq(expected) + result |> is_approx_eq expected # Exponential of a number with real and imaginary part expect - z = { re: Num.log(2f64), im: Num.pi } - result = exp(z) + z = { re: Num.log 2f64, im: Num.pi } + result = exp z expected = { re: -2, im: 0 } - result |> is_approx_eq(expected) + result |> is_approx_eq expected # Exponential resulting in a number with real and imaginary part expect - z = { re: Num.log(2f64) / 2, im: Num.pi / 4 } - result = exp(z) + z = { re: Num.log 2f64 / 2, im: Num.pi / 4 } + result = exp z expected = { re: 1, im: 1 } - result |> is_approx_eq(expected) + result |> is_approx_eq expected ### ### Operations between real numbers and complex numbers @@ -277,63 +277,63 @@ expect expect z1 = { re: 1, im: 2 } z2 = { re: 5, im: 0 } - result = z1 |> add(z2) + result = z1 |> add z2 expected = { re: 6, im: 2 } - result |> is_approx_eq(expected) + result |> is_approx_eq expected # Add complex number to real number expect z1 = { re: 5, im: 0 } z2 = { re: 1, im: 2 } - result = z1 |> add(z2) + result = z1 |> add z2 expected = { re: 6, im: 2 } - result |> is_approx_eq(expected) + result |> is_approx_eq expected # Subtract real number from complex number expect z1 = { re: 5, im: 7 } z2 = { re: 4, im: 0 } - result = z1 |> sub(z2) + result = z1 |> sub z2 expected = { re: 1, im: 7 } - result |> is_approx_eq(expected) + result |> is_approx_eq expected # Subtract complex number from real number expect z1 = { re: 4, im: 0 } z2 = { re: 5, im: 7 } - result = z1 |> sub(z2) + result = z1 |> sub z2 expected = { re: -1, im: -7 } - result |> is_approx_eq(expected) + result |> is_approx_eq expected # Multiply complex number by real number expect z1 = { re: 2, im: 5 } z2 = { re: 5, im: 0 } - result = z1 |> mul(z2) + result = z1 |> mul z2 expected = { re: 10, im: 25 } - result |> is_approx_eq(expected) + result |> is_approx_eq expected # Multiply real number by complex number expect z1 = { re: 5, im: 0 } z2 = { re: 2, im: 5 } - result = z1 |> mul(z2) + result = z1 |> mul z2 expected = { re: 10, im: 25 } - result |> is_approx_eq(expected) + result |> is_approx_eq expected # Divide complex number by real number expect z1 = { re: 10, im: 100 } z2 = { re: 10, im: 0 } - result = z1 |> div(z2) + result = z1 |> div z2 expected = { re: 1, im: 10 } - result |> is_approx_eq(expected) + result |> is_approx_eq expected # Divide real number by complex number expect z1 = { re: 5, im: 0 } z2 = { re: 1, im: 1 } - result = z1 |> div(z2) + result = z1 |> div z2 expected = { re: 2.5, im: -2.5 } - result |> is_approx_eq(expected) + result |> is_approx_eq expected diff --git a/exercises/practice/connect/connect-test.roc b/exercises/practice/connect/connect-test.roc index 37e22fad..bfa91d0c 100644 --- a/exercises/practice/connect/connect-test.roc +++ b/exercises/practice/connect/connect-test.roc @@ -1,6 +1,6 @@ # These tests are auto-generated with test data from: # https://github.com/exercism/problem-specifications/tree/main/exercises/connect/canonical-data.json -# File last updated on 2025-01-04 +# File last updated on 2025-07-26 app [main!] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.19.0/Hj-J_zxz7V9YurCSTFcFdu6cQJie4guzsPMUi5kBYUk.tar.br", } @@ -8,7 +8,7 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line!("") + Stdout.line! "" import Connect exposing [winner] @@ -23,19 +23,19 @@ expect . . . . . """ result = board |> winner - result == Err(NotFinished) + result == Err NotFinished # X can win on a 1x1 board expect board = "X" result = board |> winner - result == Ok(PlayerX) + result == Ok PlayerX # O can win on a 1x1 board expect board = "O" result = board |> winner - result == Ok(PlayerO) + result == Ok PlayerO # only edges does not make a winner expect @@ -47,7 +47,7 @@ expect X O O O """ result = board |> winner - result == Err(NotFinished) + result == Err NotFinished # illegal diagonal does not make a winner expect @@ -60,7 +60,7 @@ expect X X O O """ result = board |> winner - result == Err(NotFinished) + result == Err NotFinished # nobody wins crossing adjacent angles expect @@ -73,7 +73,7 @@ expect . . O . """ result = board |> winner - result == Err(NotFinished) + result == Err NotFinished # X wins crossing from left to right expect @@ -86,7 +86,7 @@ expect . O X . """ result = board |> winner - result == Ok(PlayerX) + result == Ok PlayerX # O wins crossing from top to bottom expect @@ -99,7 +99,7 @@ expect . O X . """ result = board |> winner - result == Ok(PlayerO) + result == Ok PlayerO # X wins using a convoluted path expect @@ -112,7 +112,7 @@ expect O O O O O """ result = board |> winner - result == Ok(PlayerX) + result == Ok PlayerX # X wins using a spiral path expect @@ -129,5 +129,5 @@ expect X X X X X X X X O """ result = board |> winner - result == Ok(PlayerX) + result == Ok PlayerX diff --git a/exercises/practice/crypto-square/crypto-square-test.roc b/exercises/practice/crypto-square/crypto-square-test.roc index 56a41d08..e413450a 100644 --- a/exercises/practice/crypto-square/crypto-square-test.roc +++ b/exercises/practice/crypto-square/crypto-square-test.roc @@ -1,6 +1,6 @@ # These tests are auto-generated with test data from: # https://github.com/exercism/problem-specifications/tree/main/exercises/crypto-square/canonical-data.json -# File last updated on 2025-01-04 +# File last updated on 2025-07-26 app [main!] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.19.0/Hj-J_zxz7V9YurCSTFcFdu6cQJie4guzsPMUi5kBYUk.tar.br", } @@ -8,63 +8,63 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line!("") + Stdout.line! "" import CryptoSquare exposing [ciphertext] # empty plaintext results in an empty ciphertext expect text = "" - result = ciphertext(text) - expected = Ok("") + result = ciphertext text + expected = Ok "" result == expected # normalization results in empty plaintext expect text = "... --- ..." - result = ciphertext(text) - expected = Ok("") + result = ciphertext text + expected = Ok "" result == expected # Lowercase expect text = "A" - result = ciphertext(text) - expected = Ok("a") + result = ciphertext text + expected = Ok "a" result == expected # Remove spaces expect text = " b " - result = ciphertext(text) - expected = Ok("b") + result = ciphertext text + expected = Ok "b" result == expected # Remove punctuation expect text = "@1,%!" - result = ciphertext(text) - expected = Ok("1") + result = ciphertext text + expected = Ok "1" result == expected # 9 character plaintext results in 3 chunks of 3 characters expect text = "This is fun!" - result = ciphertext(text) - expected = Ok("tsf hiu isn") + result = ciphertext text + expected = Ok "tsf hiu isn" result == expected # 8 character plaintext results in 3 chunks, the last one with a trailing space expect text = "Chill out." - result = ciphertext(text) - expected = Ok("clu hlt io ") + result = ciphertext text + expected = Ok "clu hlt io " result == expected -# 54 character plaintext results in 7 chunks, the last two with trailing spaces +# 54 character plaintext results in 8 chunks, the last two with trailing spaces expect text = "If man was meant to stay on the ground, god would have given us roots." - result = ciphertext(text) - expected = Ok("imtgdvs fearwer mayoogo anouuio ntnnlvt wttddes aohghn sseoau ") + result = ciphertext text + expected = Ok "imtgdvs fearwer mayoogo anouuio ntnnlvt wttddes aohghn sseoau " result == expected diff --git a/exercises/practice/custom-set/custom-set-test.roc b/exercises/practice/custom-set/custom-set-test.roc index f62e0f18..a96d0973 100644 --- a/exercises/practice/custom-set/custom-set-test.roc +++ b/exercises/practice/custom-set/custom-set-test.roc @@ -1,6 +1,6 @@ # These tests are auto-generated with test data from: # https://github.com/exercism/problem-specifications/tree/main/exercises/custom-set/canonical-data.json -# File last updated on 2025-01-04 +# File last updated on 2025-07-26 app [main!] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.19.0/Hj-J_zxz7V9YurCSTFcFdu6cQJie4guzsPMUi5kBYUk.tar.br", } @@ -8,7 +8,7 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line!("") + Stdout.line! "" import CustomSet exposing [ contains, @@ -31,7 +31,7 @@ import CustomSet exposing [ # sets with no elements are empty expect - set = from_list([]) + set = from_list [] result = set |> is_empty expected = Bool.true result == expected @@ -39,7 +39,7 @@ expect # sets with elements are not empty expect - set = from_list([1]) + set = from_list [1] result = set |> is_empty expected = Bool.false result == expected @@ -51,24 +51,24 @@ expect # nothing is contained in an empty set expect - set = from_list([]) - result = set |> contains(1) + set = from_list [] + result = set |> contains 1 expected = Bool.false result == expected # when the element is in the set expect - set = from_list([1, 2, 3]) - result = set |> contains(1) + set = from_list [1, 2, 3] + result = set |> contains 1 expected = Bool.true result == expected # when the element is not in the set expect - set = from_list([1, 2, 3]) - result = set |> contains(4) + set = from_list [1, 2, 3] + result = set |> contains 4 expected = Bool.false result == expected @@ -79,54 +79,54 @@ expect # empty set is a subset of another empty set expect - set1 = from_list([]) - set2 = from_list([]) - result = set1 |> is_subset_of(set2) + set1 = from_list [] + set2 = from_list [] + result = set1 |> is_subset_of set2 expected = Bool.true result == expected # empty set is a subset of non-empty set expect - set1 = from_list([]) - set2 = from_list([1]) - result = set1 |> is_subset_of(set2) + set1 = from_list [] + set2 = from_list [1] + result = set1 |> is_subset_of set2 expected = Bool.true result == expected # non-empty set is not a subset of empty set expect - set1 = from_list([1]) - set2 = from_list([]) - result = set1 |> is_subset_of(set2) + set1 = from_list [1] + set2 = from_list [] + result = set1 |> is_subset_of set2 expected = Bool.false result == expected # set is a subset of set with exact same elements expect - set1 = from_list([1, 2, 3]) - set2 = from_list([1, 2, 3]) - result = set1 |> is_subset_of(set2) + set1 = from_list [1, 2, 3] + set2 = from_list [1, 2, 3] + result = set1 |> is_subset_of set2 expected = Bool.true result == expected # set is a subset of larger set with same elements expect - set1 = from_list([1, 2, 3]) - set2 = from_list([4, 1, 2, 3]) - result = set1 |> is_subset_of(set2) + set1 = from_list [1, 2, 3] + set2 = from_list [4, 1, 2, 3] + result = set1 |> is_subset_of set2 expected = Bool.true result == expected # set is not a subset of set that does not contain its elements expect - set1 = from_list([1, 2, 3]) - set2 = from_list([4, 1, 3]) - result = set1 |> is_subset_of(set2) + set1 = from_list [1, 2, 3] + set2 = from_list [4, 1, 3] + result = set1 |> is_subset_of set2 expected = Bool.false result == expected @@ -137,45 +137,45 @@ expect # the empty set is disjoint with itself expect - set1 = from_list([]) - set2 = from_list([]) - result = set1 |> is_disjoint_with(set2) + set1 = from_list [] + set2 = from_list [] + result = set1 |> is_disjoint_with set2 expected = Bool.true result == expected # empty set is disjoint with non-empty set expect - set1 = from_list([]) - set2 = from_list([1]) - result = set1 |> is_disjoint_with(set2) + set1 = from_list [] + set2 = from_list [1] + result = set1 |> is_disjoint_with set2 expected = Bool.true result == expected # non-empty set is disjoint with empty set expect - set1 = from_list([1]) - set2 = from_list([]) - result = set1 |> is_disjoint_with(set2) + set1 = from_list [1] + set2 = from_list [] + result = set1 |> is_disjoint_with set2 expected = Bool.true result == expected # sets are not disjoint if they share an element expect - set1 = from_list([1, 2]) - set2 = from_list([2, 3]) - result = set1 |> is_disjoint_with(set2) + set1 = from_list [1, 2] + set2 = from_list [2, 3] + result = set1 |> is_disjoint_with set2 expected = Bool.false result == expected # sets are disjoint if they share no elements expect - set1 = from_list([1, 2]) - set2 = from_list([3, 4]) - result = set1 |> is_disjoint_with(set2) + set1 = from_list [1, 2] + set2 = from_list [3, 4] + result = set1 |> is_disjoint_with set2 expected = Bool.true result == expected @@ -186,63 +186,63 @@ expect # empty sets are equal expect - set1 = from_list([]) - set2 = from_list([]) - result = set1 |> is_eq(set2) + set1 = from_list [] + set2 = from_list [] + result = set1 |> is_eq set2 expected = Bool.true result == expected # empty set is not equal to non-empty set expect - set1 = from_list([]) - set2 = from_list([1, 2, 3]) - result = set1 |> is_eq(set2) + set1 = from_list [] + set2 = from_list [1, 2, 3] + result = set1 |> is_eq set2 expected = Bool.false result == expected # non-empty set is not equal to empty set expect - set1 = from_list([1, 2, 3]) - set2 = from_list([]) - result = set1 |> is_eq(set2) + set1 = from_list [1, 2, 3] + set2 = from_list [] + result = set1 |> is_eq set2 expected = Bool.false result == expected # sets with the same elements are equal expect - set1 = from_list([1, 2]) - set2 = from_list([2, 1]) - result = set1 |> is_eq(set2) + set1 = from_list [1, 2] + set2 = from_list [2, 1] + result = set1 |> is_eq set2 expected = Bool.true result == expected # sets with different elements are not equal expect - set1 = from_list([1, 2, 3]) - set2 = from_list([1, 2, 4]) - result = set1 |> is_eq(set2) + set1 = from_list [1, 2, 3] + set2 = from_list [1, 2, 4] + result = set1 |> is_eq set2 expected = Bool.false result == expected # set is not equal to larger set with same elements expect - set1 = from_list([1, 2, 3]) - set2 = from_list([1, 2, 3, 4]) - result = set1 |> is_eq(set2) + set1 = from_list [1, 2, 3] + set2 = from_list [1, 2, 3, 4] + result = set1 |> is_eq set2 expected = Bool.false result == expected # set is equal to a set constructed from an array with duplicates expect - set1 = from_list([1]) - set2 = from_list([1, 1]) - result = set1 |> is_eq(set2) + set1 = from_list [1] + set2 = from_list [1, 1] + result = set1 |> is_eq set2 expected = Bool.true result == expected @@ -253,26 +253,26 @@ expect # add to empty set expect - set = from_list([]) - result = set |> insert(3) + set = from_list [] + result = set |> insert 3 expected = [3] |> from_list - result |> is_eq(expected) + result |> is_eq expected # add to non-empty set expect - set = from_list([1, 2, 4]) - result = set |> insert(3) + set = from_list [1, 2, 4] + result = set |> insert 3 expected = [1, 2, 3, 4] |> from_list - result |> is_eq(expected) + result |> is_eq expected # adding an existing element does not change the set expect - set = from_list([1, 2, 3]) - result = set |> insert(3) + set = from_list [1, 2, 3] + result = set |> insert 3 expected = [1, 2, 3] |> from_list - result |> is_eq(expected) + result |> is_eq expected ## ## Intersection returns a set of all shared elements @@ -281,47 +281,47 @@ expect # intersection of two empty sets is an empty set expect - set1 = from_list([]) - set2 = from_list([]) - result = set1 |> intersection(set2) + set1 = from_list [] + set2 = from_list [] + result = set1 |> intersection set2 expected = [] |> from_list - result |> is_eq(expected) + result |> is_eq expected # intersection of an empty set and non-empty set is an empty set expect - set1 = from_list([]) - set2 = from_list([3, 2, 5]) - result = set1 |> intersection(set2) + set1 = from_list [] + set2 = from_list [3, 2, 5] + result = set1 |> intersection set2 expected = [] |> from_list - result |> is_eq(expected) + result |> is_eq expected # intersection of a non-empty set and an empty set is an empty set expect - set1 = from_list([1, 2, 3, 4]) - set2 = from_list([]) - result = set1 |> intersection(set2) + set1 = from_list [1, 2, 3, 4] + set2 = from_list [] + result = set1 |> intersection set2 expected = [] |> from_list - result |> is_eq(expected) + result |> is_eq expected # intersection of two sets with no shared elements is an empty set expect - set1 = from_list([1, 2, 3]) - set2 = from_list([4, 5, 6]) - result = set1 |> intersection(set2) + set1 = from_list [1, 2, 3] + set2 = from_list [4, 5, 6] + result = set1 |> intersection set2 expected = [] |> from_list - result |> is_eq(expected) + result |> is_eq expected # intersection of two sets with shared elements is a set of the shared elements expect - set1 = from_list([1, 2, 3, 4]) - set2 = from_list([3, 2, 5]) - result = set1 |> intersection(set2) + set1 = from_list [1, 2, 3, 4] + set2 = from_list [3, 2, 5] + result = set1 |> intersection set2 expected = [2, 3] |> from_list - result |> is_eq(expected) + result |> is_eq expected ## ## Difference (or Complement) of a set is a set of all elements that are only in the first set @@ -330,47 +330,47 @@ expect # difference of two empty sets is an empty set expect - set1 = from_list([]) - set2 = from_list([]) - result = set1 |> difference(set2) + set1 = from_list [] + set2 = from_list [] + result = set1 |> difference set2 expected = [] |> from_list - result |> is_eq(expected) + result |> is_eq expected # difference of empty set and non-empty set is an empty set expect - set1 = from_list([]) - set2 = from_list([3, 2, 5]) - result = set1 |> difference(set2) + set1 = from_list [] + set2 = from_list [3, 2, 5] + result = set1 |> difference set2 expected = [] |> from_list - result |> is_eq(expected) + result |> is_eq expected # difference of a non-empty set and an empty set is the non-empty set expect - set1 = from_list([1, 2, 3, 4]) - set2 = from_list([]) - result = set1 |> difference(set2) + set1 = from_list [1, 2, 3, 4] + set2 = from_list [] + result = set1 |> difference set2 expected = [1, 2, 3, 4] |> from_list - result |> is_eq(expected) + result |> is_eq expected # difference of two non-empty sets is a set of elements that are only in the first set expect - set1 = from_list([3, 2, 1]) - set2 = from_list([2, 4]) - result = set1 |> difference(set2) + set1 = from_list [3, 2, 1] + set2 = from_list [2, 4] + result = set1 |> difference set2 expected = [1, 3] |> from_list - result |> is_eq(expected) + result |> is_eq expected # difference removes all duplicates in the first set expect - set1 = from_list([1, 1]) - set2 = from_list([1]) - result = set1 |> difference(set2) + set1 = from_list [1, 1] + set2 = from_list [1] + result = set1 |> difference set2 expected = [] |> from_list - result |> is_eq(expected) + result |> is_eq expected ## ## Union returns a set of all elements in either set @@ -379,38 +379,38 @@ expect # union of empty sets is an empty set expect - set1 = from_list([]) - set2 = from_list([]) - result = set1 |> union(set2) + set1 = from_list [] + set2 = from_list [] + result = set1 |> union set2 expected = [] |> from_list - result |> is_eq(expected) + result |> is_eq expected # union of an empty set and non-empty set is the non-empty set expect - set1 = from_list([]) - set2 = from_list([2]) - result = set1 |> union(set2) + set1 = from_list [] + set2 = from_list [2] + result = set1 |> union set2 expected = [2] |> from_list - result |> is_eq(expected) + result |> is_eq expected # union of a non-empty set and empty set is the non-empty set expect - set1 = from_list([1, 3]) - set2 = from_list([]) - result = set1 |> union(set2) + set1 = from_list [1, 3] + set2 = from_list [] + result = set1 |> union set2 expected = [1, 3] |> from_list - result |> is_eq(expected) + result |> is_eq expected # union of non-empty sets contains all unique elements expect - set1 = from_list([1, 3]) - set2 = from_list([2, 3]) - result = set1 |> union(set2) + set1 = from_list [1, 3] + set2 = from_list [2, 3] + result = set1 |> union set2 expected = [3, 2, 1] |> from_list - result |> is_eq(expected) + result |> is_eq expected ## ## A set can be converted to a list of items @@ -418,21 +418,21 @@ expect # an empty set has an empty list of items expect - set = from_list([]) + set = from_list [] result = set |> to_list |> List.sort_asc expected = [] result == expected # a set can provide the list of its items expect - set = from_list([1, 2, 3, 4]) + set = from_list [1, 2, 3, 4] result = set |> to_list |> List.sort_asc expected = [1, 2, 3, 4] result == expected # duplicate items must be removed expect - set = from_list([1, 2, 2, 3, 3, 3, 4, 4, 4, 4]) + set = from_list [1, 2, 2, 3, 3, 3, 4, 4, 4, 4] result = set |> to_list |> List.sort_asc expected = [1, 2, 3, 4] result == expected diff --git a/exercises/practice/darts/darts-test.roc b/exercises/practice/darts/darts-test.roc index ff605258..7751045a 100644 --- a/exercises/practice/darts/darts-test.roc +++ b/exercises/practice/darts/darts-test.roc @@ -1,6 +1,6 @@ # These tests are auto-generated with test data from: # https://github.com/exercism/problem-specifications/tree/main/exercises/darts/canonical-data.json -# File last updated on 2025-01-04 +# File last updated on 2025-07-26 app [main!] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.19.0/Hj-J_zxz7V9YurCSTFcFdu6cQJie4guzsPMUi5kBYUk.tar.br", } @@ -8,72 +8,72 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line!("") + Stdout.line! "" import Darts exposing [score] # Missed target expect - result = score(-9.0f64, 9.0f64) + result = score -9.0f64 9.0f64 result == 0 # On the outer circle expect - result = score(0.0f64, 10.0f64) + result = score 0.0f64 10.0f64 result == 1 # On the middle circle expect - result = score(-5.0f64, 0.0f64) + result = score -5.0f64 0.0f64 result == 5 # On the inner circle expect - result = score(0.0f64, -1.0f64) + result = score 0.0f64 -1.0f64 result == 10 # Exactly on center expect - result = score(0.0f64, 0.0f64) + result = score 0.0f64 0.0f64 result == 10 # Near the center expect - result = score(-0.1f64, -0.1f64) + result = score -0.1f64 -0.1f64 result == 10 # Just within the inner circle expect - result = score(0.7f64, 0.7f64) + result = score 0.7f64 0.7f64 result == 10 # Just outside the inner circle expect - result = score(0.8f64, -0.8f64) + result = score 0.8f64 -0.8f64 result == 5 # Just within the middle circle expect - result = score(-3.5f64, 3.5f64) + result = score -3.5f64 3.5f64 result == 5 # Just outside the middle circle expect - result = score(-3.6f64, -3.6f64) + result = score -3.6f64 -3.6f64 result == 1 # Just within the outer circle expect - result = score(-7.0f64, 7.0f64) + result = score -7.0f64 7.0f64 result == 1 # Just outside the outer circle expect - result = score(7.1f64, -7.1f64) + result = score 7.1f64 -7.1f64 result == 0 # Asymmetric position between the inner and middle circles expect - result = score(0.5f64, -4.0f64) + result = score 0.5f64 -4.0f64 result == 5 diff --git a/exercises/practice/diamond/diamond-test.roc b/exercises/practice/diamond/diamond-test.roc index fbbaf97f..87ae32a1 100644 --- a/exercises/practice/diamond/diamond-test.roc +++ b/exercises/practice/diamond/diamond-test.roc @@ -1,6 +1,6 @@ # These tests are auto-generated with test data from: # https://github.com/exercism/problem-specifications/tree/main/exercises/diamond/canonical-data.json -# File last updated on 2025-01-04 +# File last updated on 2025-07-26 app [main!] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.19.0/Hj-J_zxz7V9YurCSTFcFdu6cQJie4guzsPMUi5kBYUk.tar.br", } @@ -8,31 +8,31 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line!("") + Stdout.line! "" import Diamond exposing [diamond] # Degenerate case with a single 'A' row expect - result = diamond('A') - expected = "A" |> Str.replace_each("·", " ") + result = diamond 'A' + expected = "A" |> Str.replace_each "·" " " result == expected # Degenerate case with no row containing 3 distinct groups of spaces expect - result = diamond('B') + result = diamond 'B' expected = """ ·A· B·B ·A· """ - |> Str.replace_each("·", " ") + |> Str.replace_each "·" " " result == expected # Smallest non-degenerate case with odd diamond side length expect - result = diamond('C') + result = diamond 'C' expected = """ ··A·· @@ -41,12 +41,12 @@ expect ·B·B· ··A·· """ - |> Str.replace_each("·", " ") + |> Str.replace_each "·" " " result == expected # Smallest non-degenerate case with even diamond side length expect - result = diamond('D') + result = diamond 'D' expected = """ ···A··· @@ -57,12 +57,12 @@ expect ··B·B·· ···A··· """ - |> Str.replace_each("·", " ") + |> Str.replace_each "·" " " result == expected # Largest possible diamond expect - result = diamond('Z') + result = diamond 'Z' expected = """ ·························A························· @@ -117,6 +117,6 @@ expect ························B·B························ ·························A························· """ - |> Str.replace_each("·", " ") + |> Str.replace_each "·" " " result == expected diff --git a/exercises/practice/difference-of-squares/difference-of-squares-test.roc b/exercises/practice/difference-of-squares/difference-of-squares-test.roc index 94d4e6f6..d46c00e6 100644 --- a/exercises/practice/difference-of-squares/difference-of-squares-test.roc +++ b/exercises/practice/difference-of-squares/difference-of-squares-test.roc @@ -1,6 +1,6 @@ # These tests are auto-generated with test data from: # https://github.com/exercism/problem-specifications/tree/main/exercises/difference-of-squares/canonical-data.json -# File last updated on 2025-01-04 +# File last updated on 2025-07-26 app [main!] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.19.0/Hj-J_zxz7V9YurCSTFcFdu6cQJie4guzsPMUi5kBYUk.tar.br", } @@ -8,7 +8,7 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line!("") + Stdout.line! "" import DifferenceOfSquares exposing [square_of_sum, sum_of_squares, difference_of_squares] @@ -18,17 +18,17 @@ import DifferenceOfSquares exposing [square_of_sum, sum_of_squares, difference_o # square of sum 1 expect - result = square_of_sum(1) + result = square_of_sum 1 result == 1 # square of sum 5 expect - result = square_of_sum(5) + result = square_of_sum 5 result == 225 # square of sum 100 expect - result = square_of_sum(100) + result = square_of_sum 100 result == 25502500 ## @@ -37,17 +37,17 @@ expect # sum of squares 1 expect - result = sum_of_squares(1) + result = sum_of_squares 1 result == 1 # sum of squares 5 expect - result = sum_of_squares(5) + result = sum_of_squares 5 result == 55 # sum of squares 100 expect - result = sum_of_squares(100) + result = sum_of_squares 100 result == 338350 ## @@ -56,16 +56,16 @@ expect # difference of squares 1 expect - result = difference_of_squares(1) + result = difference_of_squares 1 result == 0 # difference of squares 5 expect - result = difference_of_squares(5) + result = difference_of_squares 5 result == 170 # difference of squares 100 expect - result = difference_of_squares(100) + result = difference_of_squares 100 result == 25164150 diff --git a/exercises/practice/dominoes/dominoes-test.roc b/exercises/practice/dominoes/dominoes-test.roc index 8db193a5..36a4056c 100644 --- a/exercises/practice/dominoes/dominoes-test.roc +++ b/exercises/practice/dominoes/dominoes-test.roc @@ -1,6 +1,6 @@ # These tests are auto-generated with test data from: # https://github.com/exercism/problem-specifications/tree/main/exercises/dominoes/canonical-data.json -# File last updated on 2025-01-04 +# File last updated on 2025-07-26 app [main!] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.19.0/Hj-J_zxz7V9YurCSTFcFdu6cQJie4guzsPMUi5kBYUk.tar.br", } @@ -8,7 +8,7 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line!("") + Stdout.line! "" import Dominoes exposing [find_chain] @@ -18,100 +18,95 @@ Domino : (U8, U8) canonicalize : List Domino -> List Domino canonicalize = |dominoes| dominoes - |> List.map( - |domino| - if domino.0 > domino.1 then (domino.1, domino.0) else domino, - ) + |> List.map |domino| + if domino.0 > domino.1 then (domino.1, domino.0) else domino ## Ensure that the given result is Ok and is a valid chain for the ## given list of dominoes is_valid_chain_for : Result (List Domino) _, List Domino -> Bool -is_valid_chain_for = |maybe_chain, dominoes| - when maybe_chain is - Err(_) -> Bool.false - Ok(chain) -> - if Set.from_list(canonicalize(chain)) == Set.from_list(canonicalize(dominoes)) then +is_valid_chain_for = |maybeChain, dominoes| + when maybeChain is + Err _ -> Bool.false + Ok chain -> + if Set.from_list (canonicalize chain) == Set.from_list (canonicalize dominoes) then when chain is [] -> Bool.true [.., last] -> chain - |> List.walk_until( - Ok(last), - |state, domino| - when state is - Err(InvalidChain) -> crash("Unreachable") - Ok(previous) -> - if previous.1 == domino.0 then - Continue(Ok(domino)) - else - Break(Err(InvalidChain)), - ) + |> List.walk_until (Ok last) |state, domino| + when state is + Err InvalidChain -> crash "Unreachable" + Ok previous -> + if previous.1 == domino.0 then + Continue (Ok domino) + else + Break (Err InvalidChain) |> Result.is_ok else Bool.false # empty input = empty output expect - result = find_chain([]) - result |> is_valid_chain_for([]) + result = find_chain [] + result |> is_valid_chain_for [] # singleton input = singleton output expect - result = find_chain([(1, 1)]) - result |> is_valid_chain_for([(1, 1)]) + result = find_chain [(1, 1)] + result |> is_valid_chain_for [(1, 1)] # singleton that can't be chained expect - result = find_chain([(1, 2)]) + result = find_chain [(1, 2)] result |> Result.is_err # three elements expect - result = find_chain([(1, 2), (3, 1), (2, 3)]) - result |> is_valid_chain_for([(1, 2), (3, 1), (2, 3)]) + result = find_chain [(1, 2), (3, 1), (2, 3)] + result |> is_valid_chain_for [(1, 2), (3, 1), (2, 3)] # can reverse dominoes expect - result = find_chain([(1, 2), (1, 3), (2, 3)]) - result |> is_valid_chain_for([(1, 2), (1, 3), (2, 3)]) + result = find_chain [(1, 2), (1, 3), (2, 3)] + result |> is_valid_chain_for [(1, 2), (1, 3), (2, 3)] # can't be chained expect - result = find_chain([(1, 2), (4, 1), (2, 3)]) + result = find_chain [(1, 2), (4, 1), (2, 3)] result |> Result.is_err # disconnected - simple expect - result = find_chain([(1, 1), (2, 2)]) + result = find_chain [(1, 1), (2, 2)] result |> Result.is_err # disconnected - double loop expect - result = find_chain([(1, 2), (2, 1), (3, 4), (4, 3)]) + result = find_chain [(1, 2), (2, 1), (3, 4), (4, 3)] result |> Result.is_err # disconnected - single isolated expect - result = find_chain([(1, 2), (2, 3), (3, 1), (4, 4)]) + result = find_chain [(1, 2), (2, 3), (3, 1), (4, 4)] result |> Result.is_err # need backtrack expect - result = find_chain([(1, 2), (2, 3), (3, 1), (2, 4), (2, 4)]) - result |> is_valid_chain_for([(1, 2), (2, 3), (3, 1), (2, 4), (2, 4)]) + result = find_chain [(1, 2), (2, 3), (3, 1), (2, 4), (2, 4)] + result |> is_valid_chain_for [(1, 2), (2, 3), (3, 1), (2, 4), (2, 4)] # separate loops expect - result = find_chain([(1, 2), (2, 3), (3, 1), (1, 1), (2, 2), (3, 3)]) - result |> is_valid_chain_for([(1, 2), (2, 3), (3, 1), (1, 1), (2, 2), (3, 3)]) + result = find_chain [(1, 2), (2, 3), (3, 1), (1, 1), (2, 2), (3, 3)] + result |> is_valid_chain_for [(1, 2), (2, 3), (3, 1), (1, 1), (2, 2), (3, 3)] # nine elements expect - result = find_chain([(1, 2), (5, 3), (3, 1), (1, 2), (2, 4), (1, 6), (2, 3), (3, 4), (5, 6)]) - result |> is_valid_chain_for([(1, 2), (5, 3), (3, 1), (1, 2), (2, 4), (1, 6), (2, 3), (3, 4), (5, 6)]) + result = find_chain [(1, 2), (5, 3), (3, 1), (1, 2), (2, 4), (1, 6), (2, 3), (3, 4), (5, 6)] + result |> is_valid_chain_for [(1, 2), (5, 3), (3, 1), (1, 2), (2, 4), (1, 6), (2, 3), (3, 4), (5, 6)] # separate three-domino loops expect - result = find_chain([(1, 2), (2, 3), (3, 1), (4, 5), (5, 6), (6, 4)]) + result = find_chain [(1, 2), (2, 3), (3, 1), (4, 5), (5, 6), (6, 4)] result |> Result.is_err diff --git a/exercises/practice/eliuds-eggs/eliuds-eggs-test.roc b/exercises/practice/eliuds-eggs/eliuds-eggs-test.roc index a72a0a4b..733c66be 100644 --- a/exercises/practice/eliuds-eggs/eliuds-eggs-test.roc +++ b/exercises/practice/eliuds-eggs/eliuds-eggs-test.roc @@ -1,6 +1,6 @@ # These tests are auto-generated with test data from: # https://github.com/exercism/problem-specifications/tree/main/exercises/eliuds-eggs/canonical-data.json -# File last updated on 2025-01-04 +# File last updated on 2025-07-26 app [main!] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.19.0/Hj-J_zxz7V9YurCSTFcFdu6cQJie4guzsPMUi5kBYUk.tar.br", } @@ -8,27 +8,27 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line!("") + Stdout.line! "" import EliudsEggs exposing [egg_count] # 0 eggs expect - result = egg_count(0) + result = egg_count 0 result == 0 # 1 egg expect - result = egg_count(16) + result = egg_count 16 result == 1 # 4 eggs expect - result = egg_count(89) + result = egg_count 89 result == 4 # 13 eggs expect - result = egg_count(2000000000) + result = egg_count 2000000000 result == 13 diff --git a/exercises/practice/etl/etl-test.roc b/exercises/practice/etl/etl-test.roc index 4729b210..c14f4bf7 100644 --- a/exercises/practice/etl/etl-test.roc +++ b/exercises/practice/etl/etl-test.roc @@ -1,6 +1,6 @@ # These tests are auto-generated with test data from: # https://github.com/exercism/problem-specifications/tree/main/exercises/etl/canonical-data.json -# File last updated on 2025-01-04 +# File last updated on 2025-07-26 app [main!] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.19.0/Hj-J_zxz7V9YurCSTFcFdu6cQJie4guzsPMUi5kBYUk.tar.br", } @@ -8,110 +8,94 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line!("") + Stdout.line! "" import Etl exposing [transform] # single letter expect legacy = - Dict.from_list( - [ - (1, ['A']), - ], - ) + Dict.from_list [ + (1, ['A']), + ] expected = - Dict.from_list( - [ - ('a', 1), - ], - ) - transform(legacy) == expected + Dict.from_list [ + ('a', 1), + ] + transform legacy == expected # single score with multiple letters expect legacy = - Dict.from_list( - [ - (1, ['A', 'E', 'I', 'O', 'U']), - ], - ) + Dict.from_list [ + (1, ['A', 'E', 'I', 'O', 'U']), + ] expected = - Dict.from_list( - [ - ('a', 1), - ('e', 1), - ('i', 1), - ('o', 1), - ('u', 1), - ], - ) - transform(legacy) == expected + Dict.from_list [ + ('a', 1), + ('e', 1), + ('i', 1), + ('o', 1), + ('u', 1), + ] + transform legacy == expected # multiple scores with multiple letters expect legacy = - Dict.from_list( - [ - (1, ['A', 'E']), - (2, ['D', 'G']), - ], - ) + Dict.from_list [ + (1, ['A', 'E']), + (2, ['D', 'G']), + ] expected = - Dict.from_list( - [ - ('a', 1), - ('d', 2), - ('e', 1), - ('g', 2), - ], - ) - transform(legacy) == expected + Dict.from_list [ + ('a', 1), + ('d', 2), + ('e', 1), + ('g', 2), + ] + transform legacy == expected # multiple scores with differing numbers of letters expect legacy = - Dict.from_list( - [ - (1, ['A', 'E', 'I', 'O', 'U', 'L', 'N', 'R', 'S', 'T']), - (2, ['D', 'G']), - (3, ['B', 'C', 'M', 'P']), - (4, ['F', 'H', 'V', 'W', 'Y']), - (5, ['K']), - (8, ['J', 'X']), - (10, ['Q', 'Z']), - ], - ) + Dict.from_list [ + (1, ['A', 'E', 'I', 'O', 'U', 'L', 'N', 'R', 'S', 'T']), + (2, ['D', 'G']), + (3, ['B', 'C', 'M', 'P']), + (4, ['F', 'H', 'V', 'W', 'Y']), + (5, ['K']), + (8, ['J', 'X']), + (10, ['Q', 'Z']), + ] expected = - Dict.from_list( - [ - ('a', 1), - ('b', 3), - ('c', 3), - ('d', 2), - ('e', 1), - ('f', 4), - ('g', 2), - ('h', 4), - ('i', 1), - ('j', 8), - ('k', 5), - ('l', 1), - ('m', 3), - ('n', 1), - ('o', 1), - ('p', 3), - ('q', 10), - ('r', 1), - ('s', 1), - ('t', 1), - ('u', 1), - ('v', 4), - ('w', 4), - ('x', 8), - ('y', 4), - ('z', 10), - ], - ) - transform(legacy) == expected + Dict.from_list [ + ('a', 1), + ('b', 3), + ('c', 3), + ('d', 2), + ('e', 1), + ('f', 4), + ('g', 2), + ('h', 4), + ('i', 1), + ('j', 8), + ('k', 5), + ('l', 1), + ('m', 3), + ('n', 1), + ('o', 1), + ('p', 3), + ('q', 10), + ('r', 1), + ('s', 1), + ('t', 1), + ('u', 1), + ('v', 4), + ('w', 4), + ('x', 8), + ('y', 4), + ('z', 10), + ] + transform legacy == expected diff --git a/exercises/practice/flatten-array/flatten-array-test.roc b/exercises/practice/flatten-array/flatten-array-test.roc index 44abd701..63203f75 100644 --- a/exercises/practice/flatten-array/flatten-array-test.roc +++ b/exercises/practice/flatten-array/flatten-array-test.roc @@ -1,6 +1,6 @@ # These tests are auto-generated with test data from: # https://github.com/exercism/problem-specifications/tree/main/exercises/flatten-array/canonical-data.json -# File last updated on 2025-01-04 +# File last updated on 2025-07-26 app [main!] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.19.0/Hj-J_zxz7V9YurCSTFcFdu6cQJie4guzsPMUi5kBYUk.tar.br", } @@ -8,272 +8,211 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line!("") + Stdout.line! "" import FlattenArray exposing [flatten] # empty expect - result = flatten( - NestedArray( - [ - ], - ), - ) + result = flatten + ( + NestedArray [ + ] + ) result == [] # no nesting expect - result = flatten( - NestedArray( - [ - Value(0), - Value(1), - Value(2), - ], - ), - ) + result = flatten + ( + NestedArray [ + Value 0, + Value 1, + Value 2, + ] + ) result == [0, 1, 2] # flattens a nested array expect - result = flatten( - NestedArray( - [ - NestedArray( - [ - NestedArray( - [ - ], - ), + result = flatten + ( + NestedArray [ + NestedArray [ + NestedArray [ ], - ), - ], - ), - ) + ], + ] + ) result == [] # flattens array with just integers present expect - result = flatten( - NestedArray( - [ - Value(1), - NestedArray( - [ - Value(2), - Value(3), - Value(4), - Value(5), - Value(6), - Value(7), - ], - ), - Value(8), - ], - ), - ) + result = flatten + ( + NestedArray [ + Value 1, + NestedArray [ + Value 2, + Value 3, + Value 4, + Value 5, + Value 6, + Value 7, + ], + Value 8, + ] + ) result == [1, 2, 3, 4, 5, 6, 7, 8] # 5 level nesting expect - result = flatten( - NestedArray( - [ - Value(0), - Value(2), - NestedArray( - [ - NestedArray( - [ - Value(2), - Value(3), - ], - ), - Value(8), - Value(100), - Value(4), - NestedArray( - [ - NestedArray( - [ - NestedArray( - [ - Value(50), - ], - ), - ], - ), + result = flatten + ( + NestedArray [ + Value 0, + Value 2, + NestedArray [ + NestedArray [ + Value 2, + Value 3, + ], + Value 8, + Value 100, + Value 4, + NestedArray [ + NestedArray [ + NestedArray [ + Value 50, ], - ), + ], ], - ), - Value(-2), - ], - ), - ) + ], + Value -2, + ] + ) result == [0, 2, 2, 3, 8, 100, 4, 50, -2] # 6 level nesting expect - result = flatten( - NestedArray( - [ - Value(1), - NestedArray( - [ - Value(2), - NestedArray( - [ - NestedArray( - [ - Value(3), - ], - ), - ], - ), - NestedArray( - [ - Value(4), - NestedArray( - [ - NestedArray( - [ - Value(5), - ], - ), - ], - ), + result = flatten + ( + NestedArray [ + Value 1, + NestedArray [ + Value 2, + NestedArray [ + NestedArray [ + Value 3, + ], + ], + NestedArray [ + Value 4, + NestedArray [ + NestedArray [ + Value 5, ], - ), - Value(6), - Value(7), + ], ], - ), - Value(8), - ], - ), - ) + Value 6, + Value 7, + ], + Value 8, + ] + ) result == [1, 2, 3, 4, 5, 6, 7, 8] # null values are omitted from the final result expect - result = flatten( - NestedArray( - [ - Value(1), - Value(2), + result = flatten + ( + NestedArray [ + Value 1, + Value 2, Null, - ], - ), - ) + ] + ) result == [1, 2] -# consecutive null values at the front of the list are omitted from the final result +# consecutive null values at the front of the array are omitted from the final result expect - result = flatten( - NestedArray( - [ + result = flatten + ( + NestedArray [ Null, Null, - Value(3), - ], - ), - ) + Value 3, + ] + ) result == [3] -# consecutive null values in the middle of the list are omitted from the final result +# consecutive null values in the middle of the array are omitted from the final result expect - result = flatten( - NestedArray( - [ - Value(1), + result = flatten + ( + NestedArray [ + Value 1, Null, Null, - Value(4), - ], - ), - ) + Value 4, + ] + ) result == [1, 4] -# 6 level nest list with null values +# 6 level nested array with null values expect - result = flatten( - NestedArray( - [ - Value(0), - Value(2), - NestedArray( - [ - NestedArray( - [ - Value(2), - Value(3), - ], - ), - Value(8), - NestedArray( - [ - NestedArray( - [ - Value(100), - ], - ), - ], - ), - Null, - NestedArray( - [ - NestedArray( - [ - Null, - ], - ), - ], - ), + result = flatten + ( + NestedArray [ + Value 0, + Value 2, + NestedArray [ + NestedArray [ + Value 2, + Value 3, + ], + Value 8, + NestedArray [ + NestedArray [ + Value 100, + ], + ], + Null, + NestedArray [ + NestedArray [ + Null, + ], ], - ), - Value(-2), - ], - ), - ) + ], + Value -2, + ] + ) result == [0, 2, 2, 3, 8, 100, -2] -# all values in nested list are null +# all values in nested array are null expect - result = flatten( - NestedArray( - [ + result = flatten + ( + NestedArray [ Null, - NestedArray( - [ - NestedArray( - [ - NestedArray( - [ - Null, - ], - ), - ], - ), + NestedArray [ + NestedArray [ + NestedArray [ + Null, + ], ], - ), + ], Null, Null, - NestedArray( - [ - NestedArray( - [ - Null, - Null, - ], - ), + NestedArray [ + NestedArray [ + Null, Null, ], - ), + Null, + ], Null, - ], - ), - ) + ] + ) result == [] diff --git a/exercises/practice/flower-field/flower-field-test.roc b/exercises/practice/flower-field/flower-field-test.roc index cbdf9a1f..11b01541 100644 --- a/exercises/practice/flower-field/flower-field-test.roc +++ b/exercises/practice/flower-field/flower-field-test.roc @@ -1,6 +1,6 @@ # These tests are auto-generated with test data from: # https://github.com/exercism/problem-specifications/tree/main/exercises/flower-field/canonical-data.json -# File last updated on 2025-07-02 +# File last updated on 2025-07-26 app [main!] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.19.0/Hj-J_zxz7V9YurCSTFcFdu6cQJie4guzsPMUi5kBYUk.tar.br", } diff --git a/exercises/practice/food-chain/food-chain-test.roc b/exercises/practice/food-chain/food-chain-test.roc index 0bcdbc91..489b1cd8 100644 --- a/exercises/practice/food-chain/food-chain-test.roc +++ b/exercises/practice/food-chain/food-chain-test.roc @@ -1,6 +1,6 @@ # These tests are auto-generated with test data from: # https://github.com/exercism/problem-specifications/tree/main/exercises/food-chain/canonical-data.json -# File last updated on 2025-01-04 +# File last updated on 2025-07-26 app [main!] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.19.0/Hj-J_zxz7V9YurCSTFcFdu6cQJie4guzsPMUi5kBYUk.tar.br", } @@ -8,13 +8,13 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line!("") + Stdout.line! "" import FoodChain exposing [recite] # fly expect - result = recite(1, 1) + result = recite 1 1 result == """ @@ -24,7 +24,7 @@ expect # spider expect - result = recite(2, 2) + result = recite 2 2 result == """ @@ -36,7 +36,7 @@ expect # bird expect - result = recite(3, 3) + result = recite 3 3 result == """ @@ -49,7 +49,7 @@ expect # cat expect - result = recite(4, 4) + result = recite 4 4 result == """ @@ -63,7 +63,7 @@ expect # dog expect - result = recite(5, 5) + result = recite 5 5 result == """ @@ -78,7 +78,7 @@ expect # goat expect - result = recite(6, 6) + result = recite 6 6 result == """ @@ -94,7 +94,7 @@ expect # cow expect - result = recite(7, 7) + result = recite 7 7 result == """ @@ -111,7 +111,7 @@ expect # horse expect - result = recite(8, 8) + result = recite 8 8 result == """ @@ -121,7 +121,7 @@ expect # multiple verses expect - result = recite(1, 3) + result = recite 1 3 result == """ @@ -142,7 +142,7 @@ expect # full song expect - result = recite(1, 8) + result = recite 1 8 result == """ diff --git a/exercises/practice/forth/forth-test.roc b/exercises/practice/forth/forth-test.roc index 06955aed..ff4c9c7c 100644 --- a/exercises/practice/forth/forth-test.roc +++ b/exercises/practice/forth/forth-test.roc @@ -1,6 +1,6 @@ # These tests are auto-generated with test data from: # https://github.com/exercism/problem-specifications/tree/main/exercises/forth/canonical-data.json -# File last updated on 2025-01-04 +# File last updated on 2025-07-26 app [main!] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.19.0/Hj-J_zxz7V9YurCSTFcFdu6cQJie4guzsPMUi5kBYUk.tar.br", } @@ -8,286 +8,307 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line!("") + Stdout.line! "" import Forth exposing [evaluate] # parsing and numbers: numbers just get pushed onto the stack expect - result = evaluate("1 2 3 4 5") - result == Ok([1, 2, 3, 4, 5]) + result = evaluate "1 2 3 4 5" + result == Ok [1, 2, 3, 4, 5] # parsing and numbers: pushes negative numbers onto the stack expect - result = evaluate("-1 -2 -3 -4 -5") - result == Ok([-1, -2, -3, -4, -5]) + result = evaluate "-1 -2 -3 -4 -5" + result == Ok [-1, -2, -3, -4, -5] # addition: can add two numbers expect - result = evaluate("1 2 +") - result == Ok([3]) + result = evaluate "1 2 +" + result == Ok [3] # addition: errors if there is nothing on the stack expect - result = evaluate("+") - Result.is_err(result) + result = evaluate "+" + Result.is_err result # addition: errors if there is only one value on the stack expect - result = evaluate("1 +") - Result.is_err(result) + result = evaluate "1 +" + Result.is_err result + +# addition: more than two values on the stack +expect + result = evaluate "1 2 3 +" + result == Ok [1, 5] # subtraction: can subtract two numbers expect - result = evaluate("3 4 -") - result == Ok([-1]) + result = evaluate "3 4 -" + result == Ok [-1] # subtraction: errors if there is nothing on the stack expect - result = evaluate("-") - Result.is_err(result) + result = evaluate "-" + Result.is_err result # subtraction: errors if there is only one value on the stack expect - result = evaluate("1 -") - Result.is_err(result) + result = evaluate "1 -" + Result.is_err result + +# subtraction: more than two values on the stack +expect + result = evaluate "1 12 3 -" + result == Ok [1, 9] # multiplication: can multiply two numbers expect - result = evaluate("2 4 *") - result == Ok([8]) + result = evaluate "2 4 *" + result == Ok [8] # multiplication: errors if there is nothing on the stack expect - result = evaluate("*") - Result.is_err(result) + result = evaluate "*" + Result.is_err result # multiplication: errors if there is only one value on the stack expect - result = evaluate("1 *") - Result.is_err(result) + result = evaluate "1 *" + Result.is_err result + +# multiplication: more than two values on the stack +expect + result = evaluate "1 2 3 *" + result == Ok [1, 6] # division: can divide two numbers expect - result = evaluate("12 3 /") - result == Ok([4]) + result = evaluate "12 3 /" + result == Ok [4] # division: performs integer division expect - result = evaluate("8 3 /") - result == Ok([2]) + result = evaluate "8 3 /" + result == Ok [2] # division: errors if dividing by zero expect - result = evaluate("4 0 /") - Result.is_err(result) + result = evaluate "4 0 /" + Result.is_err result # division: errors if there is nothing on the stack expect - result = evaluate("/") - Result.is_err(result) + result = evaluate "/" + Result.is_err result # division: errors if there is only one value on the stack expect - result = evaluate("1 /") - Result.is_err(result) + result = evaluate "1 /" + Result.is_err result + +# division: more than two values on the stack +expect + result = evaluate "1 12 3 /" + result == Ok [1, 4] # combined arithmetic: addition and subtraction expect - result = evaluate("1 2 + 4 -") - result == Ok([-1]) + result = evaluate "1 2 + 4 -" + result == Ok [-1] # combined arithmetic: multiplication and division expect - result = evaluate("2 4 * 3 /") - result == Ok([2]) + result = evaluate "2 4 * 3 /" + result == Ok [2] + +# combined arithmetic: multiplication and addition +expect + result = evaluate "1 3 4 * +" + result == Ok [13] + +# combined arithmetic: addition and multiplication +expect + result = evaluate "1 3 4 + *" + result == Ok [7] # dup: copies a value on the stack expect - result = evaluate("1 dup") - result == Ok([1, 1]) + result = evaluate "1 dup" + result == Ok [1, 1] # dup: copies the top value on the stack expect - result = evaluate("1 2 dup") - result == Ok([1, 2, 2]) + result = evaluate "1 2 dup" + result == Ok [1, 2, 2] # dup: errors if there is nothing on the stack expect - result = evaluate("dup") - Result.is_err(result) + result = evaluate "dup" + Result.is_err result # drop: removes the top value on the stack if it is the only one expect - result = evaluate("1 drop") - result == Ok([]) + result = evaluate "1 drop" + result == Ok [] # drop: removes the top value on the stack if it is not the only one expect - result = evaluate("1 2 drop") - result == Ok([1]) + result = evaluate "1 2 drop" + result == Ok [1] # drop: errors if there is nothing on the stack expect - result = evaluate("drop") - Result.is_err(result) + result = evaluate "drop" + Result.is_err result # swap: swaps the top two values on the stack if they are the only ones expect - result = evaluate("1 2 swap") - result == Ok([2, 1]) + result = evaluate "1 2 swap" + result == Ok [2, 1] # swap: swaps the top two values on the stack if they are not the only ones expect - result = evaluate("1 2 3 swap") - result == Ok([1, 3, 2]) + result = evaluate "1 2 3 swap" + result == Ok [1, 3, 2] # swap: errors if there is nothing on the stack expect - result = evaluate("swap") - Result.is_err(result) + result = evaluate "swap" + Result.is_err result # swap: errors if there is only one value on the stack expect - result = evaluate("1 swap") - Result.is_err(result) + result = evaluate "1 swap" + Result.is_err result # over: copies the second element if there are only two expect - result = evaluate("1 2 over") - result == Ok([1, 2, 1]) + result = evaluate "1 2 over" + result == Ok [1, 2, 1] # over: copies the second element if there are more than two expect - result = evaluate("1 2 3 over") - result == Ok([1, 2, 3, 2]) + result = evaluate "1 2 3 over" + result == Ok [1, 2, 3, 2] # over: errors if there is nothing on the stack expect - result = evaluate("over") - Result.is_err(result) + result = evaluate "over" + Result.is_err result # over: errors if there is only one value on the stack expect - result = evaluate("1 over") - Result.is_err(result) + result = evaluate "1 over" + Result.is_err result # user-defined words: can consist of built-in words expect - result = evaluate( + result = evaluate """ : dup-twice dup dup ; 1 dup-twice - """, - ) - result == Ok([1, 1, 1]) + """ + result == Ok [1, 1, 1] # user-defined words: execute in the right order expect - result = evaluate( + result = evaluate """ : countup 1 2 3 ; countup - """, - ) - result == Ok([1, 2, 3]) + """ + result == Ok [1, 2, 3] # user-defined words: can override other user-defined words expect - result = evaluate( + result = evaluate """ : foo dup ; : foo dup dup ; 1 foo - """, - ) - result == Ok([1, 1, 1]) + """ + result == Ok [1, 1, 1] # user-defined words: can override built-in words expect - result = evaluate( + result = evaluate """ : swap dup ; 1 swap - """, - ) - result == Ok([1, 1]) + """ + result == Ok [1, 1] # user-defined words: can override built-in operators expect - result = evaluate( + result = evaluate """ : + * ; 3 4 + - """, - ) - result == Ok([12]) + """ + result == Ok [12] # user-defined words: can use different words with the same name expect - result = evaluate( + result = evaluate """ : foo 5 ; : bar foo ; : foo 6 ; bar foo - """, - ) - result == Ok([5, 6]) + """ + result == Ok [5, 6] # user-defined words: can define word that uses word with the same name expect - result = evaluate( + result = evaluate """ : foo 10 ; : foo foo 1 + ; foo - """, - ) - result == Ok([11]) + """ + result == Ok [11] # user-defined words: errors if executing a non-existent word expect - result = evaluate("foo") - Result.is_err(result) + result = evaluate "foo" + Result.is_err result # case-insensitivity: DUP is case-insensitive expect - result = evaluate("1 DUP Dup dup") - result == Ok([1, 1, 1, 1]) + result = evaluate "1 DUP Dup dup" + result == Ok [1, 1, 1, 1] # case-insensitivity: DROP is case-insensitive expect - result = evaluate("1 2 3 4 DROP Drop drop") - result == Ok([1]) + result = evaluate "1 2 3 4 DROP Drop drop" + result == Ok [1] # case-insensitivity: SWAP is case-insensitive expect - result = evaluate("1 2 SWAP 3 Swap 4 swap") - result == Ok([2, 3, 4, 1]) + result = evaluate "1 2 SWAP 3 Swap 4 swap" + result == Ok [2, 3, 4, 1] # case-insensitivity: OVER is case-insensitive expect - result = evaluate("1 2 OVER Over over") - result == Ok([1, 2, 1, 2, 1]) + result = evaluate "1 2 OVER Over over" + result == Ok [1, 2, 1, 2, 1] # case-insensitivity: user-defined words are case-insensitive expect - result = evaluate( + result = evaluate """ : foo dup ; 1 FOO Foo foo - """, - ) - result == Ok([1, 1, 1, 1]) + """ + result == Ok [1, 1, 1, 1] # case-insensitivity: definitions are case-insensitive expect - result = evaluate( + result = evaluate """ : SWAP DUP Dup dup ; 1 swap - """, - ) - result == Ok([1, 1, 1, 1]) + """ + result == Ok [1, 1, 1, 1] diff --git a/exercises/practice/gigasecond/gigasecond-test.roc b/exercises/practice/gigasecond/gigasecond-test.roc index 08d4bde0..70f6e6b7 100644 --- a/exercises/practice/gigasecond/gigasecond-test.roc +++ b/exercises/practice/gigasecond/gigasecond-test.roc @@ -1,6 +1,6 @@ # These tests are auto-generated with test data from: # https://github.com/exercism/problem-specifications/tree/main/exercises/gigasecond/canonical-data.json -# File last updated on 2025-01-04 +# File last updated on 2025-07-26 app [main!] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.19.0/Hj-J_zxz7V9YurCSTFcFdu6cQJie4guzsPMUi5kBYUk.tar.br", isodate: "https://github.com/imclerran/roc-isodate/releases/download/v0.6.0/79DATSmwkFXMsS0dF7w1RTHeQCGwFNzh9zylic4Fw9w.tar.br", @@ -9,32 +9,32 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line!("") + Stdout.line! "" import Gigasecond exposing [add] # date only specification of time expect - result = add("2011-04-25") + result = add "2011-04-25" result == "2043-01-01T01:46:40" # second test for date only specification of time expect - result = add("1977-06-13") + result = add "1977-06-13" result == "2009-02-19T01:46:40" # third test for date only specification of time expect - result = add("1959-07-19") + result = add "1959-07-19" result == "1991-03-27T01:46:40" # full time specified expect - result = add("2015-01-24T22:00:00") + result = add "2015-01-24T22:00:00" result == "2046-10-02T23:46:40" # full time with day roll-over expect - result = add("2015-01-24T23:59:59") + result = add "2015-01-24T23:59:59" result == "2046-10-03T01:46:39" diff --git a/exercises/practice/go-counting/go-counting-test.roc b/exercises/practice/go-counting/go-counting-test.roc index b4244e78..0c1fd6d7 100644 --- a/exercises/practice/go-counting/go-counting-test.roc +++ b/exercises/practice/go-counting/go-counting-test.roc @@ -1,6 +1,6 @@ # These tests are auto-generated with test data from: # https://github.com/exercism/problem-specifications/tree/main/exercises/go-counting/canonical-data.json -# File last updated on 2025-01-04 +# File last updated on 2025-07-26 app [main!] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.19.0/Hj-J_zxz7V9YurCSTFcFdu6cQJie4guzsPMUi5kBYUk.tar.br", } @@ -8,7 +8,7 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line!("") + Stdout.line! "" import GoCounting exposing [territory, territories] @@ -16,14 +16,14 @@ import GoCounting exposing [territory, territories] ## comparing tags or records containing sets sometimes returns the wrong result ## depending on the internal order of the set data, so we have to unwrap the sets ## in order to compare them properly. -compare_territory = |maybe_result, maybe_expected| +compareTerritory = |maybe_result, maybe_expected| when (maybe_result, maybe_expected) is - (Ok(result), Ok(expected)) -> result.owner == expected.owner and result.territory == expected.territory + (Ok result, Ok expected) -> result.owner == expected.owner and result.territory == expected.territory _ -> Bool.false -compare_territories = |maybe_result, maybe_expected| +compareTerritories = |maybe_result, maybe_expected| when (maybe_result, maybe_expected) is - (Ok(result), Ok(expected)) -> result.black == expected.black and result.white == expected.white and result.none == expected.none + (Ok result, Ok expected) -> result.black == expected.black and result.white == expected.white and result.none == expected.none _ -> Bool.false # Black corner territory on 5x5 board @@ -36,21 +36,17 @@ expect ·W·W· ··W·· """ - |> Str.replace_each("·", " ") - result = board |> territory({ x: 0, y: 1 }) - expected = Ok( - { - owner: Black, - territory: Set.from_list( - [ - { x: 0, y: 0 }, - { x: 0, y: 1 }, - { x: 1, y: 0 }, - ], - ), - }, - ) - result |> compare_territory(expected) + |> Str.replace_each "·" " " + result = board |> territory { x: 0, y: 1 } + expected = Ok { + owner: Black, + territory: Set.from_list [ + { x: 0, y: 0 }, + { x: 0, y: 1 }, + { x: 1, y: 0 }, + ], + } + result |> compareTerritory expected # White center territory on 5x5 board expect @@ -62,19 +58,15 @@ expect ·W·W· ··W·· """ - |> Str.replace_each("·", " ") - result = board |> territory({ x: 2, y: 3 }) - expected = Ok( - { - owner: White, - territory: Set.from_list( - [ - { x: 2, y: 3 }, - ], - ), - }, - ) - result |> compare_territory(expected) + |> Str.replace_each "·" " " + result = board |> territory { x: 2, y: 3 } + expected = Ok { + owner: White, + territory: Set.from_list [ + { x: 2, y: 3 }, + ], + } + result |> compareTerritory expected # Open corner territory on 5x5 board expect @@ -86,21 +78,17 @@ expect ·W·W· ··W·· """ - |> Str.replace_each("·", " ") - result = board |> territory({ x: 1, y: 4 }) - expected = Ok( - { - owner: None, - territory: Set.from_list( - [ - { x: 0, y: 3 }, - { x: 0, y: 4 }, - { x: 1, y: 4 }, - ], - ), - }, - ) - result |> compare_territory(expected) + |> Str.replace_each "·" " " + result = board |> territory { x: 1, y: 4 } + expected = Ok { + owner: None, + territory: Set.from_list [ + { x: 0, y: 3 }, + { x: 0, y: 4 }, + { x: 1, y: 4 }, + ], + } + result |> compareTerritory expected # A stone and not a territory on 5x5 board expect @@ -112,15 +100,13 @@ expect ·W·W· ··W·· """ - |> Str.replace_each("·", " ") - result = board |> territory({ x: 1, y: 1 }) - expected = Ok( - { - owner: None, - territory: Set.empty({}), - }, - ) - result |> compare_territory(expected) + |> Str.replace_each "·" " " + result = board |> territory { x: 1, y: 1 } + expected = Ok { + owner: None, + territory: Set.empty {}, + } + result |> compareTerritory expected # Invalid because X is too high for 5x5 board expect @@ -132,8 +118,8 @@ expect ·W·W· ··W·· """ - |> Str.replace_each("·", " ") - result = board |> territory({ x: 5, y: 1 }) + |> Str.replace_each "·" " " + result = board |> territory { x: 5, y: 1 } result |> Result.is_err # Invalid because Y is too high for 5x5 board @@ -146,28 +132,24 @@ expect ·W·W· ··W·· """ - |> Str.replace_each("·", " ") - result = board |> territory({ x: 1, y: 5 }) + |> Str.replace_each "·" " " + result = board |> territory { x: 1, y: 5 } result |> Result.is_err # One territory is the whole board expect - board = "·" |> Str.replace_each("·", " ") + board = "·" |> Str.replace_each "·" " " result = board |> territories - expected = Ok( - { - black: Set.empty({}), + expected = Ok { + black: Set.empty {}, - white: Set.empty({}), + white: Set.empty {}, - none: Set.from_list( - [ - { x: 0, y: 0 }, - ], - ), - }, - ) - result |> compare_territories(expected) + none: Set.from_list [ + { x: 0, y: 0 }, + ], + } + result |> compareTerritories expected # Two territory rectangular board expect @@ -176,46 +158,36 @@ expect ·BW· ·BW· """ - |> Str.replace_each("·", " ") + |> Str.replace_each "·" " " result = board |> territories - expected = Ok( - { - black: Set.from_list( - [ - { x: 0, y: 0 }, - { x: 0, y: 1 }, - ], - ), - - white: Set.from_list( - [ - { x: 3, y: 0 }, - { x: 3, y: 1 }, - ], - ), - - none: Set.empty({}), - }, - ) - result |> compare_territories(expected) + expected = Ok { + black: Set.from_list [ + { x: 0, y: 0 }, + { x: 0, y: 1 }, + ], + + white: Set.from_list [ + { x: 3, y: 0 }, + { x: 3, y: 1 }, + ], + + none: Set.empty {}, + } + result |> compareTerritories expected # Two region rectangular board expect - board = "·B·" |> Str.replace_each("·", " ") + board = "·B·" |> Str.replace_each "·" " " result = board |> territories - expected = Ok( - { - black: Set.from_list( - [ - { x: 0, y: 0 }, - { x: 2, y: 0 }, - ], - ), - - white: Set.empty({}), - - none: Set.empty({}), - }, - ) - result |> compare_territories(expected) + expected = Ok { + black: Set.from_list [ + { x: 0, y: 0 }, + { x: 2, y: 0 }, + ], + + white: Set.empty {}, + + none: Set.empty {}, + } + result |> compareTerritories expected diff --git a/exercises/practice/grains/grains-test.roc b/exercises/practice/grains/grains-test.roc index f15a48a2..e4d816d7 100644 --- a/exercises/practice/grains/grains-test.roc +++ b/exercises/practice/grains/grains-test.roc @@ -1,6 +1,6 @@ # These tests are auto-generated with test data from: # https://github.com/exercism/problem-specifications/tree/main/exercises/grains/canonical-data.json -# File last updated on 2025-01-04 +# File last updated on 2025-07-26 app [main!] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.19.0/Hj-J_zxz7V9YurCSTFcFdu6cQJie4guzsPMUi5kBYUk.tar.br", } @@ -8,7 +8,7 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line!("") + Stdout.line! "" import Grains exposing [grains_on_square, total_grains] @@ -18,48 +18,48 @@ import Grains exposing [grains_on_square, total_grains] # grains on square 1 expect - result = grains_on_square(1) - result == Ok(1) + result = grains_on_square 1 + result == Ok 1 # grains on square 2 expect - result = grains_on_square(2) - result == Ok(2) + result = grains_on_square 2 + result == Ok 2 # grains on square 3 expect - result = grains_on_square(3) - result == Ok(4) + result = grains_on_square 3 + result == Ok 4 # grains on square 4 expect - result = grains_on_square(4) - result == Ok(8) + result = grains_on_square 4 + result == Ok 8 # grains on square 16 expect - result = grains_on_square(16) - result == Ok(32768) + result = grains_on_square 16 + result == Ok 32768 # grains on square 32 expect - result = grains_on_square(32) - result == Ok(2147483648) + result = grains_on_square 32 + result == Ok 2147483648 # grains on square 64 expect - result = grains_on_square(64) - result == Ok(9223372036854775808) + result = grains_on_square 64 + result == Ok 9223372036854775808 # square 0 is invalid expect - result = grains_on_square(0) - Result.is_err(result) + result = grains_on_square 0 + Result.is_err result # square greater than 64 is invalid expect - result = grains_on_square(65) - Result.is_err(result) + result = grains_on_square 65 + Result.is_err result ## ## returns the total number of grains on the board diff --git a/exercises/practice/grep/grep-test.roc b/exercises/practice/grep/grep-test.roc index 2f3af7ba..6c29124e 100644 --- a/exercises/practice/grep/grep-test.roc +++ b/exercises/practice/grep/grep-test.roc @@ -1,6 +1,6 @@ # These tests are auto-generated with test data from: # https://github.com/exercism/problem-specifications/tree/main/exercises/grep/canonical-data.json -# File last updated on 2025-01-04 +# File last updated on 2025-07-26 app [main!] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.19.0/Hj-J_zxz7V9YurCSTFcFdu6cQJie4guzsPMUi5kBYUk.tar.br", } @@ -8,109 +8,105 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line!("") + Stdout.line! "" import Grep exposing [grep] # Test grepping a single file - One file, one match, no flags expect - result = grep("Agamemnon", [], ["iliad.txt"]) - result == Ok("Of Atreus, Agamemnon, King of men.") + result = grep "Agamemnon" [] ["iliad.txt"] + result == Ok "Of Atreus, Agamemnon, King of men." # Test grepping a single file - One file, one match, print line numbers flag expect - result = grep("Forbidden", ["-n"], ["paradise-lost.txt"]) - result == Ok("2:Of that Forbidden Tree, whose mortal tast") + result = grep "Forbidden" ["-n"] ["paradise-lost.txt"] + result == Ok "2:Of that Forbidden Tree, whose mortal tast" # Test grepping a single file - One file, one match, case-insensitive flag expect - result = grep("FORBIDDEN", ["-i"], ["paradise-lost.txt"]) - result == Ok("Of that Forbidden Tree, whose mortal tast") + result = grep "FORBIDDEN" ["-i"] ["paradise-lost.txt"] + result == Ok "Of that Forbidden Tree, whose mortal tast" # Test grepping a single file - One file, one match, print file names flag expect - result = grep("Forbidden", ["-l"], ["paradise-lost.txt"]) - result == Ok("paradise-lost.txt") + result = grep "Forbidden" ["-l"] ["paradise-lost.txt"] + result == Ok "paradise-lost.txt" # Test grepping a single file - One file, one match, match entire lines flag expect - result = grep("With loss of Eden, till one greater Man", ["-x"], ["paradise-lost.txt"]) - result == Ok("With loss of Eden, till one greater Man") + result = grep "With loss of Eden, till one greater Man" ["-x"] ["paradise-lost.txt"] + result == Ok "With loss of Eden, till one greater Man" # Test grepping a single file - One file, one match, multiple flags expect - result = grep("OF ATREUS, Agamemnon, KIng of MEN.", ["-n", "-i", "-x"], ["iliad.txt"]) - result == Ok("9:Of Atreus, Agamemnon, King of men.") + result = grep "OF ATREUS, Agamemnon, KIng of MEN." ["-n", "-i", "-x"] ["iliad.txt"] + result == Ok "9:Of Atreus, Agamemnon, King of men." # Test grepping a single file - One file, several matches, no flags expect - result = grep("may", [], ["midsummer-night.txt"]) + result = grep "may" [] ["midsummer-night.txt"] result - == Ok( + == Ok """ Nor how it may concern my modesty, But I beseech your grace that I may know The worst that may befall me in this case, - """, - ) + """ # Test grepping a single file - One file, several matches, print line numbers flag expect - result = grep("may", ["-n"], ["midsummer-night.txt"]) + result = grep "may" ["-n"] ["midsummer-night.txt"] result - == Ok( + == Ok """ 3:Nor how it may concern my modesty, 5:But I beseech your grace that I may know 6:The worst that may befall me in this case, - """, - ) + """ # Test grepping a single file - One file, several matches, match entire lines flag expect - result = grep("may", ["-x"], ["midsummer-night.txt"]) - result == Ok("") + result = grep "may" ["-x"] ["midsummer-night.txt"] + result == Ok "" # Test grepping a single file - One file, several matches, case-insensitive flag expect - result = grep("ACHILLES", ["-i"], ["iliad.txt"]) + result = grep "ACHILLES" ["-i"] ["iliad.txt"] result - == Ok( + == Ok """ Achilles sing, O Goddess! Peleus' son; The noble Chief Achilles from the son - """, - ) + """ # Test grepping a single file - One file, several matches, inverted flag expect - result = grep("Of", ["-v"], ["paradise-lost.txt"]) + result = grep "Of" ["-v"] ["paradise-lost.txt"] result - == Ok( + == Ok """ Brought Death into the World, and all our woe, With loss of Eden, till one greater Man Restore us, and regain the blissful Seat, Sing Heav'nly Muse, that on the secret top That Shepherd, who first taught the chosen Seed - """, - ) + """ # Test grepping a single file - One file, no matches, various flags expect - result = grep("Gandalf", ["-n", "-l", "-x", "-i"], ["iliad.txt"]) - result == Ok("") + result = grep "Gandalf" ["-n", "-l", "-x", "-i"] ["iliad.txt"] + result == Ok "" # Test grepping a single file - One file, one match, file flag takes precedence over line flag expect - result = grep("ten", ["-n", "-l"], ["iliad.txt"]) - result == Ok("iliad.txt") + result = grep "ten" ["-n", "-l"] ["iliad.txt"] + result == Ok "iliad.txt" # Test grepping a single file - One file, several matches, inverted and match entire lines flags expect - result = grep("Illustrious into Ades premature,", ["-x", "-v"], ["iliad.txt"]) + result = grep "Illustrious into Ades premature," ["-x", "-v"] ["iliad.txt"] result - == Ok( + == Ok """ Achilles sing, O Goddess! Peleus' son; His wrath pernicious, who ten thousand woes @@ -120,55 +116,51 @@ expect When fierce dispute had separated once The noble Chief Achilles from the son Of Atreus, Agamemnon, King of men. - """, - ) + """ # Test grepping multiples files at once - Multiple files, one match, no flags expect - result = grep("Agamemnon", [], ["iliad.txt", "midsummer-night.txt", "paradise-lost.txt"]) - result == Ok("iliad.txt:Of Atreus, Agamemnon, King of men.") + result = grep "Agamemnon" [] ["iliad.txt", "midsummer-night.txt", "paradise-lost.txt"] + result == Ok "iliad.txt:Of Atreus, Agamemnon, King of men." # Test grepping multiples files at once - Multiple files, several matches, no flags expect - result = grep("may", [], ["iliad.txt", "midsummer-night.txt", "paradise-lost.txt"]) + result = grep "may" [] ["iliad.txt", "midsummer-night.txt", "paradise-lost.txt"] result - == Ok( + == Ok """ midsummer-night.txt:Nor how it may concern my modesty, midsummer-night.txt:But I beseech your grace that I may know midsummer-night.txt:The worst that may befall me in this case, - """, - ) + """ # Test grepping multiples files at once - Multiple files, several matches, print line numbers flag expect - result = grep("that", ["-n"], ["iliad.txt", "midsummer-night.txt", "paradise-lost.txt"]) + result = grep "that" ["-n"] ["iliad.txt", "midsummer-night.txt", "paradise-lost.txt"] result - == Ok( + == Ok """ midsummer-night.txt:5:But I beseech your grace that I may know midsummer-night.txt:6:The worst that may befall me in this case, paradise-lost.txt:2:Of that Forbidden Tree, whose mortal tast paradise-lost.txt:6:Sing Heav'nly Muse, that on the secret top - """, - ) + """ # Test grepping multiples files at once - Multiple files, one match, print file names flag expect - result = grep("who", ["-l"], ["iliad.txt", "midsummer-night.txt", "paradise-lost.txt"]) + result = grep "who" ["-l"] ["iliad.txt", "midsummer-night.txt", "paradise-lost.txt"] result - == Ok( + == Ok """ iliad.txt paradise-lost.txt - """, - ) + """ # Test grepping multiples files at once - Multiple files, several matches, case-insensitive flag expect - result = grep("TO", ["-i"], ["iliad.txt", "midsummer-night.txt", "paradise-lost.txt"]) + result = grep "TO" ["-i"] ["iliad.txt", "midsummer-night.txt", "paradise-lost.txt"] result - == Ok( + == Ok """ iliad.txt:Caused to Achaia's host, sent many a soul iliad.txt:Illustrious into Ades premature, @@ -180,52 +172,49 @@ expect paradise-lost.txt:Brought Death into the World, and all our woe, paradise-lost.txt:Restore us, and regain the blissful Seat, paradise-lost.txt:Sing Heav'nly Muse, that on the secret top - """, - ) + """ # Test grepping multiples files at once - Multiple files, several matches, inverted flag expect - result = grep("a", ["-v"], ["iliad.txt", "midsummer-night.txt", "paradise-lost.txt"]) + result = grep "a" ["-v"] ["iliad.txt", "midsummer-night.txt", "paradise-lost.txt"] result - == Ok( + == Ok """ iliad.txt:Achilles sing, O Goddess! Peleus' son; iliad.txt:The noble Chief Achilles from the son midsummer-night.txt:If I refuse to wed Demetrius. - """, - ) + """ # Test grepping multiples files at once - Multiple files, one match, match entire lines flag expect - result = grep("But I beseech your grace that I may know", ["-x"], ["iliad.txt", "midsummer-night.txt", "paradise-lost.txt"]) - result == Ok("midsummer-night.txt:But I beseech your grace that I may know") + result = grep "But I beseech your grace that I may know" ["-x"] ["iliad.txt", "midsummer-night.txt", "paradise-lost.txt"] + result == Ok "midsummer-night.txt:But I beseech your grace that I may know" # Test grepping multiples files at once - Multiple files, one match, multiple flags expect - result = grep("WITH LOSS OF EDEN, TILL ONE GREATER MAN", ["-n", "-i", "-x"], ["iliad.txt", "midsummer-night.txt", "paradise-lost.txt"]) - result == Ok("paradise-lost.txt:4:With loss of Eden, till one greater Man") + result = grep "WITH LOSS OF EDEN, TILL ONE GREATER MAN" ["-n", "-i", "-x"] ["iliad.txt", "midsummer-night.txt", "paradise-lost.txt"] + result == Ok "paradise-lost.txt:4:With loss of Eden, till one greater Man" # Test grepping multiples files at once - Multiple files, no matches, various flags expect - result = grep("Frodo", ["-n", "-l", "-x", "-i"], ["iliad.txt", "midsummer-night.txt", "paradise-lost.txt"]) - result == Ok("") + result = grep "Frodo" ["-n", "-l", "-x", "-i"] ["iliad.txt", "midsummer-night.txt", "paradise-lost.txt"] + result == Ok "" # Test grepping multiples files at once - Multiple files, several matches, file flag takes precedence over line number flag expect - result = grep("who", ["-n", "-l"], ["iliad.txt", "midsummer-night.txt", "paradise-lost.txt"]) + result = grep "who" ["-n", "-l"] ["iliad.txt", "midsummer-night.txt", "paradise-lost.txt"] result - == Ok( + == Ok """ iliad.txt paradise-lost.txt - """, - ) + """ # Test grepping multiples files at once - Multiple files, several matches, inverted and match entire lines flags expect - result = grep("Illustrious into Ades premature,", ["-x", "-v"], ["iliad.txt", "midsummer-night.txt", "paradise-lost.txt"]) + result = grep "Illustrious into Ades premature," ["-x", "-v"] ["iliad.txt", "midsummer-night.txt", "paradise-lost.txt"] result - == Ok( + == Ok """ iliad.txt:Achilles sing, O Goddess! Peleus' son; iliad.txt:His wrath pernicious, who ten thousand woes @@ -250,6 +239,5 @@ expect paradise-lost.txt:Sing Heav'nly Muse, that on the secret top paradise-lost.txt:Of Oreb, or of Sinai, didst inspire paradise-lost.txt:That Shepherd, who first taught the chosen Seed - """, - ) + """ diff --git a/exercises/practice/hamming/hamming-test.roc b/exercises/practice/hamming/hamming-test.roc index a62ea9fa..355af55b 100644 --- a/exercises/practice/hamming/hamming-test.roc +++ b/exercises/practice/hamming/hamming-test.roc @@ -1,6 +1,6 @@ # These tests are auto-generated with test data from: # https://github.com/exercism/problem-specifications/tree/main/exercises/hamming/canonical-data.json -# File last updated on 2025-01-04 +# File last updated on 2025-07-26 app [main!] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.19.0/Hj-J_zxz7V9YurCSTFcFdu6cQJie4guzsPMUi5kBYUk.tar.br", } @@ -8,52 +8,52 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line!("") + Stdout.line! "" import Hamming exposing [distance] # empty strands expect - result = distance("", "") - result == Ok(0) + result = distance "" "" + result == Ok 0 # single letter identical strands expect - result = distance("A", "A") - result == Ok(0) + result = distance "A" "A" + result == Ok 0 # single letter different strands expect - result = distance("G", "T") - result == Ok(1) + result = distance "G" "T" + result == Ok 1 # long identical strands expect - result = distance("GGACTGAAATCTG", "GGACTGAAATCTG") - result == Ok(0) + result = distance "GGACTGAAATCTG" "GGACTGAAATCTG" + result == Ok 0 # long different strands expect - result = distance("GGACGGATTCTG", "AGGACGGATTCT") - result == Ok(9) + result = distance "GGACGGATTCTG" "AGGACGGATTCT" + result == Ok 9 # disallow first strand longer expect - result = distance("AATG", "AAA") - Result.is_err(result) + result = distance "AATG" "AAA" + Result.is_err result # disallow second strand longer expect - result = distance("ATA", "AGTG") - Result.is_err(result) + result = distance "ATA" "AGTG" + Result.is_err result # disallow empty first strand expect - result = distance("", "G") - Result.is_err(result) + result = distance "" "G" + Result.is_err result # disallow empty second strand expect - result = distance("G", "") - Result.is_err(result) + result = distance "G" "" + Result.is_err result diff --git a/exercises/practice/hello-world/hello-world-test.roc b/exercises/practice/hello-world/hello-world-test.roc index 177cefae..81203450 100644 --- a/exercises/practice/hello-world/hello-world-test.roc +++ b/exercises/practice/hello-world/hello-world-test.roc @@ -1,6 +1,6 @@ # These tests are auto-generated with test data from: # https://github.com/exercism/problem-specifications/tree/main/exercises/hello-world/canonical-data.json -# File last updated on 2025-01-04 +# File last updated on 2025-07-26 app [main!] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.19.0/Hj-J_zxz7V9YurCSTFcFdu6cQJie4guzsPMUi5kBYUk.tar.br", } @@ -8,7 +8,7 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line!("") + Stdout.line! "" import HelloWorld exposing [hello] diff --git a/exercises/practice/high-scores/high-scores-test.roc b/exercises/practice/high-scores/high-scores-test.roc index ae71026c..b08850ac 100644 --- a/exercises/practice/high-scores/high-scores-test.roc +++ b/exercises/practice/high-scores/high-scores-test.roc @@ -1,6 +1,6 @@ # These tests are auto-generated with test data from: # https://github.com/exercism/problem-specifications/tree/main/exercises/high-scores/canonical-data.json -# File last updated on 2025-01-04 +# File last updated on 2025-07-26 app [main!] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.19.0/Hj-J_zxz7V9YurCSTFcFdu6cQJie4guzsPMUi5kBYUk.tar.br", } @@ -8,43 +8,43 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line!("") + Stdout.line! "" import HighScores exposing [latest, personal_best, personal_top_three] ## Latest score expect - result = latest([100, 0, 90, 30]) - result == Ok(30) + result = latest [100, 0, 90, 30] + result == Ok 30 ## Personal best expect - result = personal_best([40, 100, 70]) - result == Ok(100) + result = personal_best [40, 100, 70] + result == Ok 100 ## Top 3 scores # Personal top three from a list of scores expect - result = personal_top_three([10, 30, 90, 30, 100, 20, 10, 0, 30, 40, 40, 70, 70]) + result = personal_top_three [10, 30, 90, 30, 100, 20, 10, 0, 30, 40, 40, 70, 70] result == [100, 90, 70] # Personal top highest to lowest expect - result = personal_top_three([20, 10, 30]) + result = personal_top_three [20, 10, 30] result == [30, 20, 10] # Personal top when there is a tie expect - result = personal_top_three([40, 20, 40, 30]) + result = personal_top_three [40, 20, 40, 30] result == [40, 40, 30] # Personal top when there are less than 3 expect - result = personal_top_three([30, 70]) + result = personal_top_three [30, 70] result == [70, 30] # Personal top when there is only one expect - result = personal_top_three([40]) + result = personal_top_three [40] result == [40] diff --git a/exercises/practice/house/house-test.roc b/exercises/practice/house/house-test.roc index 84381fee..87852c8a 100644 --- a/exercises/practice/house/house-test.roc +++ b/exercises/practice/house/house-test.roc @@ -1,6 +1,6 @@ # These tests are auto-generated with test data from: # https://github.com/exercism/problem-specifications/tree/main/exercises/house/canonical-data.json -# File last updated on 2025-01-04 +# File last updated on 2025-07-26 app [main!] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.19.0/Hj-J_zxz7V9YurCSTFcFdu6cQJie4guzsPMUi5kBYUk.tar.br", } @@ -8,77 +8,77 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line!("") + Stdout.line! "" import House exposing [recite] # verse one - the house that jack built expect - result = recite(1, 1) + result = recite 1 1 result == "This is the house that Jack built." # verse two - the malt that lay expect - result = recite(2, 2) + result = recite 2 2 result == "This is the malt that lay in the house that Jack built." # verse three - the rat that ate expect - result = recite(3, 3) + result = recite 3 3 result == "This is the rat that ate the malt that lay in the house that Jack built." # verse four - the cat that killed expect - result = recite(4, 4) + result = recite 4 4 result == "This is the cat that killed the rat that ate the malt that lay in the house that Jack built." # verse five - the dog that worried expect - result = recite(5, 5) + result = recite 5 5 result == "This is the dog that worried the cat that killed the rat that ate the malt that lay in the house that Jack built." # verse six - the cow with the crumpled horn expect - result = recite(6, 6) + result = recite 6 6 result == "This is the cow with the crumpled horn that tossed the dog that worried the cat that killed the rat that ate the malt that lay in the house that Jack built." # verse seven - the maiden all forlorn expect - result = recite(7, 7) + result = recite 7 7 result == "This is the maiden all forlorn that milked the cow with the crumpled horn that tossed the dog that worried the cat that killed the rat that ate the malt that lay in the house that Jack built." # verse eight - the man all tattered and torn expect - result = recite(8, 8) + result = recite 8 8 result == "This is the man all tattered and torn that kissed the maiden all forlorn that milked the cow with the crumpled horn that tossed the dog that worried the cat that killed the rat that ate the malt that lay in the house that Jack built." # verse nine - the priest all shaven and shorn expect - result = recite(9, 9) + result = recite 9 9 result == "This is the priest all shaven and shorn that married the man all tattered and torn that kissed the maiden all forlorn that milked the cow with the crumpled horn that tossed the dog that worried the cat that killed the rat that ate the malt that lay in the house that Jack built." # verse 10 - the rooster that crowed in the morn expect - result = recite(10, 10) + result = recite 10 10 result == "This is the rooster that crowed in the morn that woke the priest all shaven and shorn that married the man all tattered and torn that kissed the maiden all forlorn that milked the cow with the crumpled horn that tossed the dog that worried the cat that killed the rat that ate the malt that lay in the house that Jack built." # verse 11 - the farmer sowing his corn expect - result = recite(11, 11) + result = recite 11 11 result == "This is the farmer sowing his corn that kept the rooster that crowed in the morn that woke the priest all shaven and shorn that married the man all tattered and torn that kissed the maiden all forlorn that milked the cow with the crumpled horn that tossed the dog that worried the cat that killed the rat that ate the malt that lay in the house that Jack built." # verse 12 - the horse and the hound and the horn expect - result = recite(12, 12) + result = recite 12 12 result == "This is the horse and the hound and the horn that belonged to the farmer sowing his corn that kept the rooster that crowed in the morn that woke the priest all shaven and shorn that married the man all tattered and torn that kissed the maiden all forlorn that milked the cow with the crumpled horn that tossed the dog that worried the cat that killed the rat that ate the malt that lay in the house that Jack built." # multiple verses expect - result = recite(4, 8) + result = recite 4 8 result == "This is the cat that killed the rat that ate the malt that lay in the house that Jack built.\nThis is the dog that worried the cat that killed the rat that ate the malt that lay in the house that Jack built.\nThis is the cow with the crumpled horn that tossed the dog that worried the cat that killed the rat that ate the malt that lay in the house that Jack built.\nThis is the maiden all forlorn that milked the cow with the crumpled horn that tossed the dog that worried the cat that killed the rat that ate the malt that lay in the house that Jack built.\nThis is the man all tattered and torn that kissed the maiden all forlorn that milked the cow with the crumpled horn that tossed the dog that worried the cat that killed the rat that ate the malt that lay in the house that Jack built." # full rhyme expect - result = recite(1, 12) + result = recite 1 12 result == "This is the house that Jack built.\nThis is the malt that lay in the house that Jack built.\nThis is the rat that ate the malt that lay in the house that Jack built.\nThis is the cat that killed the rat that ate the malt that lay in the house that Jack built.\nThis is the dog that worried the cat that killed the rat that ate the malt that lay in the house that Jack built.\nThis is the cow with the crumpled horn that tossed the dog that worried the cat that killed the rat that ate the malt that lay in the house that Jack built.\nThis is the maiden all forlorn that milked the cow with the crumpled horn that tossed the dog that worried the cat that killed the rat that ate the malt that lay in the house that Jack built.\nThis is the man all tattered and torn that kissed the maiden all forlorn that milked the cow with the crumpled horn that tossed the dog that worried the cat that killed the rat that ate the malt that lay in the house that Jack built.\nThis is the priest all shaven and shorn that married the man all tattered and torn that kissed the maiden all forlorn that milked the cow with the crumpled horn that tossed the dog that worried the cat that killed the rat that ate the malt that lay in the house that Jack built.\nThis is the rooster that crowed in the morn that woke the priest all shaven and shorn that married the man all tattered and torn that kissed the maiden all forlorn that milked the cow with the crumpled horn that tossed the dog that worried the cat that killed the rat that ate the malt that lay in the house that Jack built.\nThis is the farmer sowing his corn that kept the rooster that crowed in the morn that woke the priest all shaven and shorn that married the man all tattered and torn that kissed the maiden all forlorn that milked the cow with the crumpled horn that tossed the dog that worried the cat that killed the rat that ate the malt that lay in the house that Jack built.\nThis is the horse and the hound and the horn that belonged to the farmer sowing his corn that kept the rooster that crowed in the morn that woke the priest all shaven and shorn that married the man all tattered and torn that kissed the maiden all forlorn that milked the cow with the crumpled horn that tossed the dog that worried the cat that killed the rat that ate the malt that lay in the house that Jack built." diff --git a/exercises/practice/isbn-verifier/isbn-verifier-test.roc b/exercises/practice/isbn-verifier/isbn-verifier-test.roc index 862cb5a5..b12e3a7c 100644 --- a/exercises/practice/isbn-verifier/isbn-verifier-test.roc +++ b/exercises/practice/isbn-verifier/isbn-verifier-test.roc @@ -1,6 +1,6 @@ # These tests are auto-generated with test data from: # https://github.com/exercism/problem-specifications/tree/main/exercises/isbn-verifier/canonical-data.json -# File last updated on 2025-01-04 +# File last updated on 2025-07-26 app [main!] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.19.0/Hj-J_zxz7V9YurCSTFcFdu6cQJie4guzsPMUi5kBYUk.tar.br", } @@ -8,102 +8,102 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line!("") + Stdout.line! "" import IsbnVerifier exposing [is_valid] # valid isbn expect - result = is_valid("3-598-21508-8") + result = is_valid "3-598-21508-8" result == Bool.true # invalid isbn check digit expect - result = is_valid("3-598-21508-9") + result = is_valid "3-598-21508-9" result == Bool.false # valid isbn with a check digit of 10 expect - result = is_valid("3-598-21507-X") + result = is_valid "3-598-21507-X" result == Bool.true # check digit is a character other than X expect - result = is_valid("3-598-21507-A") + result = is_valid "3-598-21507-A" result == Bool.false # invalid check digit in isbn is not treated as zero expect - result = is_valid("4-598-21507-B") + result = is_valid "4-598-21507-B" result == Bool.false # invalid character in isbn is not treated as zero expect - result = is_valid("3-598-P1581-X") + result = is_valid "3-598-P1581-X" result == Bool.false # X is only valid as a check digit expect - result = is_valid("3-598-2X507-9") + result = is_valid "3-598-2X507-9" result == Bool.false # valid isbn without separating dashes expect - result = is_valid("3598215088") + result = is_valid "3598215088" result == Bool.true # isbn without separating dashes and X as check digit expect - result = is_valid("359821507X") + result = is_valid "359821507X" result == Bool.true # isbn without check digit and dashes expect - result = is_valid("359821507") + result = is_valid "359821507" result == Bool.false # too long isbn and no dashes expect - result = is_valid("3598215078X") + result = is_valid "3598215078X" result == Bool.false # too short isbn expect - result = is_valid("00") + result = is_valid "00" result == Bool.false # isbn without check digit expect - result = is_valid("3-598-21507") + result = is_valid "3-598-21507" result == Bool.false # check digit of X should not be used for 0 expect - result = is_valid("3-598-21515-X") + result = is_valid "3-598-21515-X" result == Bool.false # empty isbn expect - result = is_valid("") + result = is_valid "" result == Bool.false # input is 9 characters expect - result = is_valid("134456729") + result = is_valid "134456729" result == Bool.false # invalid characters are not ignored after checking length expect - result = is_valid("3132P34035") + result = is_valid "3132P34035" result == Bool.false # invalid characters are not ignored before checking length expect - result = is_valid("3598P215088") + result = is_valid "3598P215088" result == Bool.false # input is too long but contains a valid isbn expect - result = is_valid("98245726788") + result = is_valid "98245726788" result == Bool.false diff --git a/exercises/practice/isogram/isogram-test.roc b/exercises/practice/isogram/isogram-test.roc index 0e97b224..6d99aaf6 100644 --- a/exercises/practice/isogram/isogram-test.roc +++ b/exercises/practice/isogram/isogram-test.roc @@ -1,6 +1,6 @@ # These tests are auto-generated with test data from: # https://github.com/exercism/problem-specifications/tree/main/exercises/isogram/canonical-data.json -# File last updated on 2025-01-04 +# File last updated on 2025-07-26 app [main!] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.19.0/Hj-J_zxz7V9YurCSTFcFdu6cQJie4guzsPMUi5kBYUk.tar.br", } @@ -8,77 +8,77 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line!("") + Stdout.line! "" import Isogram exposing [is_isogram] # empty string expect - result = is_isogram("") + result = is_isogram "" result == Bool.true # isogram with only lower case characters expect - result = is_isogram("isogram") + result = is_isogram "isogram" result == Bool.true # word with one duplicated character expect - result = is_isogram("eleven") + result = is_isogram "eleven" result == Bool.false # word with one duplicated character from the end of the alphabet expect - result = is_isogram("zzyzx") + result = is_isogram "zzyzx" result == Bool.false # longest reported english isogram expect - result = is_isogram("subdermatoglyphic") + result = is_isogram "subdermatoglyphic" result == Bool.true # word with duplicated character in mixed case expect - result = is_isogram("Alphabet") + result = is_isogram "Alphabet" result == Bool.false # word with duplicated character in mixed case, lowercase first expect - result = is_isogram("alphAbet") + result = is_isogram "alphAbet" result == Bool.false # hypothetical isogrammic word with hyphen expect - result = is_isogram("thumbscrew-japingly") + result = is_isogram "thumbscrew-japingly" result == Bool.true # hypothetical word with duplicated character following hyphen expect - result = is_isogram("thumbscrew-jappingly") + result = is_isogram "thumbscrew-jappingly" result == Bool.false # isogram with duplicated hyphen expect - result = is_isogram("six-year-old") + result = is_isogram "six-year-old" result == Bool.true # made-up name that is an isogram expect - result = is_isogram("Emily Jung Schwartzkopf") + result = is_isogram "Emily Jung Schwartzkopf" result == Bool.true # duplicated character in the middle expect - result = is_isogram("accentor") + result = is_isogram "accentor" result == Bool.false # same first and last characters expect - result = is_isogram("angola") + result = is_isogram "angola" result == Bool.false # word with duplicated character and with two hyphens expect - result = is_isogram("up-to-date") + result = is_isogram "up-to-date" result == Bool.false diff --git a/exercises/practice/killer-sudoku-helper/killer-sudoku-helper-test.roc b/exercises/practice/killer-sudoku-helper/killer-sudoku-helper-test.roc index 995e5618..dfd13835 100644 --- a/exercises/practice/killer-sudoku-helper/killer-sudoku-helper-test.roc +++ b/exercises/practice/killer-sudoku-helper/killer-sudoku-helper-test.roc @@ -1,6 +1,6 @@ # These tests are auto-generated with test data from: # https://github.com/exercism/problem-specifications/tree/main/exercises/killer-sudoku-helper/canonical-data.json -# File last updated on 2025-01-04 +# File last updated on 2025-07-26 app [main!] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.19.0/Hj-J_zxz7V9YurCSTFcFdu6cQJie4guzsPMUi5kBYUk.tar.br", } @@ -8,73 +8,73 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line!("") + Stdout.line! "" import KillerSudokuHelper exposing [combinations] ## Trivial 1-digit cages # 1 expect - result = combinations({ sum: 1, size: 1 }) + result = combinations { sum: 1, size: 1 } result == [[1]] # 2 expect - result = combinations({ sum: 2, size: 1 }) + result = combinations { sum: 2, size: 1 } result == [[2]] # 3 expect - result = combinations({ sum: 3, size: 1 }) + result = combinations { sum: 3, size: 1 } result == [[3]] # 4 expect - result = combinations({ sum: 4, size: 1 }) + result = combinations { sum: 4, size: 1 } result == [[4]] # 5 expect - result = combinations({ sum: 5, size: 1 }) + result = combinations { sum: 5, size: 1 } result == [[5]] # 6 expect - result = combinations({ sum: 6, size: 1 }) + result = combinations { sum: 6, size: 1 } result == [[6]] # 7 expect - result = combinations({ sum: 7, size: 1 }) + result = combinations { sum: 7, size: 1 } result == [[7]] # 8 expect - result = combinations({ sum: 8, size: 1 }) + result = combinations { sum: 8, size: 1 } result == [[8]] # 9 expect - result = combinations({ sum: 9, size: 1 }) + result = combinations { sum: 9, size: 1 } result == [[9]] ## Cage with sum 45 contains all digits 1:9 expect - result = combinations({ sum: 45, size: 9 }) + result = combinations { sum: 45, size: 9 } result == [[1, 2, 3, 4, 5, 6, 7, 8, 9]] ## Cage with only 1 possible combination expect - result = combinations({ sum: 7, size: 3 }) + result = combinations { sum: 7, size: 3 } result == [[1, 2, 4]] ## Cage with several combinations expect - result = combinations({ sum: 10, size: 2 }) + result = combinations { sum: 10, size: 2 } result == [[1, 9], [2, 8], [3, 7], [4, 6]] ## Cage with several combinations that is restricted expect - result = combinations({ sum: 10, size: 2, exclude: [1, 4] }) + result = combinations { sum: 10, size: 2, exclude: [1, 4] } result == [[2, 8], [3, 7]] diff --git a/exercises/practice/kindergarten-garden/kindergarten-garden-test.roc b/exercises/practice/kindergarten-garden/kindergarten-garden-test.roc index 47611dce..27d3e261 100644 --- a/exercises/practice/kindergarten-garden/kindergarten-garden-test.roc +++ b/exercises/practice/kindergarten-garden/kindergarten-garden-test.roc @@ -1,6 +1,6 @@ # These tests are auto-generated with test data from: # https://github.com/exercism/problem-specifications/tree/main/exercises/kindergarten-garden/canonical-data.json -# File last updated on 2025-01-04 +# File last updated on 2025-07-26 app [main!] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.19.0/Hj-J_zxz7V9YurCSTFcFdu6cQJie4guzsPMUi5kBYUk.tar.br", } @@ -8,7 +8,7 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line!("") + Stdout.line! "" import KindergartenGarden exposing [plants] @@ -23,8 +23,8 @@ expect RC GG """ - result = diagram |> plants(Alice) - result == Ok([Radishes, Clover, Grass, Grass]) + result = diagram |> plants Alice + result == Ok [Radishes, Clover, Grass, Grass] # different garden with single student expect @@ -33,8 +33,8 @@ expect VC RC """ - result = diagram |> plants(Alice) - result == Ok([Violets, Clover, Radishes, Clover]) + result = diagram |> plants Alice + result == Ok [Violets, Clover, Radishes, Clover] # garden with two students expect @@ -43,8 +43,8 @@ expect VVCG VVRC """ - result = diagram |> plants(Bob) - result == Ok([Clover, Grass, Radishes, Clover]) + result = diagram |> plants Bob + result == Ok [Clover, Grass, Radishes, Clover] ## multiple students for the same garden with three students @@ -55,8 +55,8 @@ expect VVCCGG VVCCGG """ - result = diagram |> plants(Bob) - result == Ok([Clover, Clover, Clover, Clover]) + result = diagram |> plants Bob + result == Ok [Clover, Clover, Clover, Clover] # third student's garden expect @@ -65,8 +65,8 @@ expect VVCCGG VVCCGG """ - result = diagram |> plants(Charlie) - result == Ok([Grass, Grass, Grass, Grass]) + result = diagram |> plants Charlie + result == Ok [Grass, Grass, Grass, Grass] ### ### full garden @@ -79,8 +79,8 @@ expect VRCGVVRVCGGCCGVRGCVCGCGV VRCCCGCRRGVCGCRVVCVGCGCV """ - result = diagram |> plants(Alice) - result == Ok([Violets, Radishes, Violets, Radishes]) + result = diagram |> plants Alice + result == Ok [Violets, Radishes, Violets, Radishes] # for Bob, second student's garden expect @@ -89,8 +89,8 @@ expect VRCGVVRVCGGCCGVRGCVCGCGV VRCCCGCRRGVCGCRVVCVGCGCV """ - result = diagram |> plants(Bob) - result == Ok([Clover, Grass, Clover, Clover]) + result = diagram |> plants Bob + result == Ok [Clover, Grass, Clover, Clover] # for Charlie expect @@ -99,8 +99,8 @@ expect VRCGVVRVCGGCCGVRGCVCGCGV VRCCCGCRRGVCGCRVVCVGCGCV """ - result = diagram |> plants(Charlie) - result == Ok([Violets, Violets, Clover, Grass]) + result = diagram |> plants Charlie + result == Ok [Violets, Violets, Clover, Grass] # for David expect @@ -109,8 +109,8 @@ expect VRCGVVRVCGGCCGVRGCVCGCGV VRCCCGCRRGVCGCRVVCVGCGCV """ - result = diagram |> plants(David) - result == Ok([Radishes, Violets, Clover, Radishes]) + result = diagram |> plants David + result == Ok [Radishes, Violets, Clover, Radishes] # for Eve expect @@ -119,8 +119,8 @@ expect VRCGVVRVCGGCCGVRGCVCGCGV VRCCCGCRRGVCGCRVVCVGCGCV """ - result = diagram |> plants(Eve) - result == Ok([Clover, Grass, Radishes, Grass]) + result = diagram |> plants Eve + result == Ok [Clover, Grass, Radishes, Grass] # for Fred expect @@ -129,8 +129,8 @@ expect VRCGVVRVCGGCCGVRGCVCGCGV VRCCCGCRRGVCGCRVVCVGCGCV """ - result = diagram |> plants(Fred) - result == Ok([Grass, Clover, Violets, Clover]) + result = diagram |> plants Fred + result == Ok [Grass, Clover, Violets, Clover] # for Ginny expect @@ -139,8 +139,8 @@ expect VRCGVVRVCGGCCGVRGCVCGCGV VRCCCGCRRGVCGCRVVCVGCGCV """ - result = diagram |> plants(Ginny) - result == Ok([Clover, Grass, Grass, Clover]) + result = diagram |> plants Ginny + result == Ok [Clover, Grass, Grass, Clover] # for Harriet expect @@ -149,8 +149,8 @@ expect VRCGVVRVCGGCCGVRGCVCGCGV VRCCCGCRRGVCGCRVVCVGCGCV """ - result = diagram |> plants(Harriet) - result == Ok([Violets, Radishes, Radishes, Violets]) + result = diagram |> plants Harriet + result == Ok [Violets, Radishes, Radishes, Violets] # for Ileana expect @@ -159,8 +159,8 @@ expect VRCGVVRVCGGCCGVRGCVCGCGV VRCCCGCRRGVCGCRVVCVGCGCV """ - result = diagram |> plants(Ileana) - result == Ok([Grass, Clover, Violets, Clover]) + result = diagram |> plants Ileana + result == Ok [Grass, Clover, Violets, Clover] # for Joseph expect @@ -169,8 +169,8 @@ expect VRCGVVRVCGGCCGVRGCVCGCGV VRCCCGCRRGVCGCRVVCVGCGCV """ - result = diagram |> plants(Joseph) - result == Ok([Violets, Clover, Violets, Grass]) + result = diagram |> plants Joseph + result == Ok [Violets, Clover, Violets, Grass] # for Kincaid, second to last student's garden expect @@ -179,8 +179,8 @@ expect VRCGVVRVCGGCCGVRGCVCGCGV VRCCCGCRRGVCGCRVVCVGCGCV """ - result = diagram |> plants(Kincaid) - result == Ok([Grass, Clover, Clover, Grass]) + result = diagram |> plants Kincaid + result == Ok [Grass, Clover, Clover, Grass] # for Larry, last student's garden expect @@ -189,6 +189,6 @@ expect VRCGVVRVCGGCCGVRGCVCGCGV VRCCCGCRRGVCGCRVVCVGCGCV """ - result = diagram |> plants(Larry) - result == Ok([Grass, Violets, Clover, Violets]) + result = diagram |> plants Larry + result == Ok [Grass, Violets, Clover, Violets] diff --git a/exercises/practice/knapsack/knapsack-test.roc b/exercises/practice/knapsack/knapsack-test.roc index 6d363d4a..046371d9 100644 --- a/exercises/practice/knapsack/knapsack-test.roc +++ b/exercises/practice/knapsack/knapsack-test.roc @@ -1,6 +1,6 @@ # These tests are auto-generated with test data from: # https://github.com/exercism/problem-specifications/tree/main/exercises/knapsack/canonical-data.json -# File last updated on 2025-01-04 +# File last updated on 2025-07-26 app [main!] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.19.0/Hj-J_zxz7V9YurCSTFcFdu6cQJie4guzsPMUi5kBYUk.tar.br", } @@ -8,14 +8,14 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line!("") + Stdout.line! "" import Knapsack exposing [maximum_value] # no items expect items = [] - result = maximum_value({ items, maximum_weight: 100 }) + result = maximum_value { items, maximum_weight: 100 } result == 0 # one item, too heavy @@ -23,7 +23,7 @@ expect items = [ { weight: 100, value: 1 }, ] - result = maximum_value({ items, maximum_weight: 10 }) + result = maximum_value { items, maximum_weight: 10 } result == 0 # five items (cannot be greedy by weight) @@ -35,7 +35,7 @@ expect { weight: 2, value: 5 }, { weight: 10, value: 21 }, ] - result = maximum_value({ items, maximum_weight: 10 }) + result = maximum_value { items, maximum_weight: 10 } result == 21 # five items (cannot be greedy by value) @@ -47,7 +47,7 @@ expect { weight: 2, value: 20 }, { weight: 10, value: 50 }, ] - result = maximum_value({ items, maximum_weight: 10 }) + result = maximum_value { items, maximum_weight: 10 } result == 80 # example knapsack @@ -58,7 +58,7 @@ expect { weight: 6, value: 30 }, { weight: 4, value: 50 }, ] - result = maximum_value({ items, maximum_weight: 10 }) + result = maximum_value { items, maximum_weight: 10 } result == 90 # 8 items @@ -73,7 +73,7 @@ expect { weight: 2, value: 5 }, { weight: 2, value: 5 }, ] - result = maximum_value({ items, maximum_weight: 104 }) + result = maximum_value { items, maximum_weight: 104 } result == 900 # 15 items @@ -95,6 +95,6 @@ expect { weight: 118, value: 229 }, { weight: 120, value: 240 }, ] - result = maximum_value({ items, maximum_weight: 750 }) + result = maximum_value { items, maximum_weight: 750 } result == 1458 diff --git a/exercises/practice/largest-series-product/largest-series-product-test.roc b/exercises/practice/largest-series-product/largest-series-product-test.roc index 904451b6..42e0a095 100644 --- a/exercises/practice/largest-series-product/largest-series-product-test.roc +++ b/exercises/practice/largest-series-product/largest-series-product-test.roc @@ -1,6 +1,6 @@ # These tests are auto-generated with test data from: # https://github.com/exercism/problem-specifications/tree/main/exercises/largest-series-product/canonical-data.json -# File last updated on 2025-01-04 +# File last updated on 2025-07-26 app [main!] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.19.0/Hj-J_zxz7V9YurCSTFcFdu6cQJie4guzsPMUi5kBYUk.tar.br", } @@ -8,102 +8,102 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line!("") + Stdout.line! "" import LargestSeriesProduct exposing [largest_product] # finds the largest product if span equals length expect digits = "29" - result = digits |> largest_product(2) - expected = Ok(18) + result = digits |> largest_product 2 + expected = Ok 18 result == expected # can find the largest product of 2 with numbers in order expect digits = "0123456789" - result = digits |> largest_product(2) - expected = Ok(72) + result = digits |> largest_product 2 + expected = Ok 72 result == expected # can find the largest product of 2 expect digits = "576802143" - result = digits |> largest_product(2) - expected = Ok(48) + result = digits |> largest_product 2 + expected = Ok 48 result == expected # can find the largest product of 3 with numbers in order expect digits = "0123456789" - result = digits |> largest_product(3) - expected = Ok(504) + result = digits |> largest_product 3 + expected = Ok 504 result == expected # can find the largest product of 3 expect digits = "1027839564" - result = digits |> largest_product(3) - expected = Ok(270) + result = digits |> largest_product 3 + expected = Ok 270 result == expected # can find the largest product of 5 with numbers in order expect digits = "0123456789" - result = digits |> largest_product(5) - expected = Ok(15120) + result = digits |> largest_product 5 + expected = Ok 15120 result == expected # can get the largest product of a big number expect digits = "73167176531330624919225119674426574742355349194934" - result = digits |> largest_product(6) - expected = Ok(23520) + result = digits |> largest_product 6 + expected = Ok 23520 result == expected # reports zero if the only digits are zero expect digits = "0000" - result = digits |> largest_product(2) - expected = Ok(0) + result = digits |> largest_product 2 + expected = Ok 0 result == expected # reports zero if all spans include zero expect digits = "99099" - result = digits |> largest_product(3) - expected = Ok(0) + result = digits |> largest_product 3 + expected = Ok 0 result == expected # rejects span longer than string length expect digits = "123" - result = digits |> largest_product(4) + result = digits |> largest_product 4 result |> Result.is_err # reports 1 for empty string and empty product (0 span) expect digits = "" - result = digits |> largest_product(0) - expected = Ok(1) + result = digits |> largest_product 0 + expected = Ok 1 result == expected # reports 1 for nonempty string and empty product (0 span) expect digits = "123" - result = digits |> largest_product(0) - expected = Ok(1) + result = digits |> largest_product 0 + expected = Ok 1 result == expected # rejects empty string and nonzero span expect digits = "" - result = digits |> largest_product(1) + result = digits |> largest_product 1 result |> Result.is_err # rejects invalid character in digits expect digits = "1234a5" - result = digits |> largest_product(2) + result = digits |> largest_product 2 result |> Result.is_err diff --git a/exercises/practice/leap/leap-test.roc b/exercises/practice/leap/leap-test.roc index 02ca8f19..b80b8f81 100644 --- a/exercises/practice/leap/leap-test.roc +++ b/exercises/practice/leap/leap-test.roc @@ -1,6 +1,6 @@ # These tests are auto-generated with test data from: # https://github.com/exercism/problem-specifications/tree/main/exercises/leap/canonical-data.json -# File last updated on 2025-01-04 +# File last updated on 2025-07-26 app [main!] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.19.0/Hj-J_zxz7V9YurCSTFcFdu6cQJie4guzsPMUi5kBYUk.tar.br", } @@ -8,52 +8,52 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line!("") + Stdout.line! "" import Leap exposing [is_leap_year] # year not divisible by 4 in common year expect - result = is_leap_year(2015) + result = is_leap_year 2015 result == Bool.false # year divisible by 2, not divisible by 4 in common year expect - result = is_leap_year(1970) + result = is_leap_year 1970 result == Bool.false # year divisible by 4, not divisible by 100 in leap year expect - result = is_leap_year(1996) + result = is_leap_year 1996 result == Bool.true # year divisible by 4 and 5 is still a leap year expect - result = is_leap_year(1960) + result = is_leap_year 1960 result == Bool.true # year divisible by 100, not divisible by 400 in common year expect - result = is_leap_year(2100) + result = is_leap_year 2100 result == Bool.false # year divisible by 100 but not by 3 is still not a leap year expect - result = is_leap_year(1900) + result = is_leap_year 1900 result == Bool.false # year divisible by 400 is leap year expect - result = is_leap_year(2000) + result = is_leap_year 2000 result == Bool.true # year divisible by 400 but not by 125 is still a leap year expect - result = is_leap_year(2400) + result = is_leap_year 2400 result == Bool.true # year divisible by 200, not divisible by 400 in common year expect - result = is_leap_year(1800) + result = is_leap_year 1800 result == Bool.false diff --git a/exercises/practice/list-ops/list-ops-test.roc b/exercises/practice/list-ops/list-ops-test.roc index 648e9447..60d75d16 100644 --- a/exercises/practice/list-ops/list-ops-test.roc +++ b/exercises/practice/list-ops/list-ops-test.roc @@ -1,6 +1,6 @@ # These tests are auto-generated with test data from: # https://github.com/exercism/problem-specifications/tree/main/exercises/list-ops/canonical-data.json -# File last updated on 2025-01-04 +# File last updated on 2025-07-26 app [main!] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.19.0/Hj-J_zxz7V9YurCSTFcFdu6cQJie4guzsPMUi5kBYUk.tar.br", } @@ -8,7 +8,7 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line!("") + Stdout.line! "" import ListOps exposing [append, concat, filter, length, map, foldl, foldr, reverse] @@ -18,22 +18,22 @@ import ListOps exposing [append, concat, filter, length, map, foldl, foldr, reve # empty lists expect - result = append([], []) + result = append [] [] result == [] # list to empty list expect - result = append([], [1, 2, 3, 4]) + result = append [] [1, 2, 3, 4] result == [1, 2, 3, 4] # empty list to list expect - result = append([1, 2, 3, 4], []) + result = append [1, 2, 3, 4] [] result == [1, 2, 3, 4] # non-empty lists expect - result = append([1, 2], [2, 3, 4, 5]) + result = append [1, 2] [2, 3, 4, 5] result == [1, 2, 2, 3, 4, 5] ## @@ -42,17 +42,17 @@ expect # empty list expect - result = concat([]) + result = concat [] result == [] # list of lists expect - result = concat([[1, 2], [3], [], [4, 5, 6]]) + result = concat [[1, 2], [3], [], [4, 5, 6]] result == [1, 2, 3, 4, 5, 6] # list of nested lists expect - result = concat([[[1], [2]], [[3]], [[]], [[4, 5, 6]]]) + result = concat [[[1], [2]], [[3]], [[]], [[4, 5, 6]]] result == [[1], [2], [3], [], [4, 5, 6]] ## @@ -61,12 +61,12 @@ expect # empty list expect - result = filter([], Num.is_odd) + result = filter [] (Num.is_odd) result == [] # non-empty list expect - result = filter([1, 2, 3, 5], Num.is_odd) + result = filter [1, 2, 3, 5] (Num.is_odd) result == [1, 3, 5] ## @@ -75,12 +75,12 @@ expect # empty list expect - result = length([]) + result = length [] result == 0 # non-empty list expect - result = length([1, 2, 3, 4]) + result = length [1, 2, 3, 4] result == 4 ## @@ -89,12 +89,12 @@ expect # empty list expect - result = map([], |x| x + 1) + result = map [] (|x| x + 1) result == [] # non-empty list expect - result = map([1, 3, 5, 7], |x| x + 1) + result = map [1, 3, 5, 7] (|x| x + 1) result == [2, 4, 6, 8] ## @@ -103,17 +103,17 @@ expect # empty list expect - result = foldl([], 2, |acc, el| el * acc) + result = foldl [] 2 (|acc, el| el * acc) result == 2 # direction independent function applied to non-empty list expect - result = foldl([1, 2, 3, 4], 5, |acc, el| el + acc) + result = foldl [1, 2, 3, 4] 5 (|acc, el| el + acc) result == 15 # direction dependent function applied to non-empty list expect - result = foldl([1, 2, 3, 4], 24, |acc, el| el / acc) |> Num.round + result = foldl [1, 2, 3, 4] 24 (|acc, el| el / acc) |> Num.round result == 64 ## @@ -122,17 +122,17 @@ expect # empty list expect - result = foldr([], 2, |acc, el| el * acc) + result = foldr [] 2 (|acc, el| el * acc) result == 2 # direction independent function applied to non-empty list expect - result = foldr([1, 2, 3, 4], 5, |acc, el| el + acc) + result = foldr [1, 2, 3, 4] 5 (|acc, el| el + acc) result == 15 # direction dependent function applied to non-empty list expect - result = foldr([1, 2, 3, 4], 24, |acc, el| el / acc) |> Num.round + result = foldr [1, 2, 3, 4] 24 (|acc, el| el / acc) |> Num.round result == 9 ## @@ -141,16 +141,16 @@ expect # empty list expect - result = reverse([]) + result = reverse [] result == [] # non-empty list expect - result = reverse([1, 3, 5, 7]) + result = reverse [1, 3, 5, 7] result == [7, 5, 3, 1] # list of lists is not flattened expect - result = reverse([[1, 2], [3], [], [4, 5, 6]]) + result = reverse [[1, 2], [3], [], [4, 5, 6]] result == [[4, 5, 6], [], [3], [1, 2]] diff --git a/exercises/practice/luhn/luhn-test.roc b/exercises/practice/luhn/luhn-test.roc index acf0790a..4928e34f 100644 --- a/exercises/practice/luhn/luhn-test.roc +++ b/exercises/practice/luhn/luhn-test.roc @@ -1,6 +1,6 @@ # These tests are auto-generated with test data from: # https://github.com/exercism/problem-specifications/tree/main/exercises/luhn/canonical-data.json -# File last updated on 2025-01-04 +# File last updated on 2025-07-26 app [main!] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.19.0/Hj-J_zxz7V9YurCSTFcFdu6cQJie4guzsPMUi5kBYUk.tar.br", } @@ -8,117 +8,117 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line!("") + Stdout.line! "" import Luhn exposing [valid] # single digit strings can not be valid expect - result = valid("1") + result = valid "1" result == Bool.false # a single zero is invalid expect - result = valid("0") + result = valid "0" result == Bool.false # a simple valid SIN that remains valid if reversed expect - result = valid("059") + result = valid "059" result == Bool.true # a simple valid SIN that becomes invalid if reversed expect - result = valid("59") + result = valid "59" result == Bool.true # a valid Canadian SIN expect - result = valid("055 444 285") + result = valid "055 444 285" result == Bool.true # invalid Canadian SIN expect - result = valid("055 444 286") + result = valid "055 444 286" result == Bool.false # invalid credit card expect - result = valid("8273 1232 7352 0569") + result = valid "8273 1232 7352 0569" result == Bool.false # invalid long number with an even remainder expect - result = valid("1 2345 6789 1234 5678 9012") + result = valid "1 2345 6789 1234 5678 9012" result == Bool.false # invalid long number with a remainder divisible by 5 expect - result = valid("1 2345 6789 1234 5678 9013") + result = valid "1 2345 6789 1234 5678 9013" result == Bool.false # valid number with an even number of digits expect - result = valid("095 245 88") + result = valid "095 245 88" result == Bool.true # valid number with an odd number of spaces expect - result = valid("234 567 891 234") + result = valid "234 567 891 234" result == Bool.true # valid strings with a non-digit added at the end become invalid expect - result = valid("059a") + result = valid "059a" result == Bool.false # valid strings with punctuation included become invalid expect - result = valid("055-444-285") + result = valid "055-444-285" result == Bool.false # valid strings with symbols included become invalid expect - result = valid("055# 444$ 285") + result = valid "055# 444$ 285" result == Bool.false # single zero with space is invalid expect - result = valid(" 0") + result = valid " 0" result == Bool.false # more than a single zero is valid expect - result = valid("0000 0") + result = valid "0000 0" result == Bool.true # input digit 9 is correctly converted to output digit 9 expect - result = valid("091") + result = valid "091" result == Bool.true # very long input is valid expect - result = valid("9999999999 9999999999 9999999999 9999999999") + result = valid "9999999999 9999999999 9999999999 9999999999" result == Bool.true # valid luhn with an odd number of digits and non zero first digit expect - result = valid("109") + result = valid "109" result == Bool.true # using ascii value for non-doubled non-digit isn't allowed expect - result = valid("055b 444 285") + result = valid "055b 444 285" result == Bool.false # using ascii value for doubled non-digit isn't allowed expect - result = valid(":9") + result = valid ":9" result == Bool.false # non-numeric, non-space char in the middle with a sum that's divisible by 10 isn't allowed expect - result = valid("59%59") + result = valid "59%59" result == Bool.false diff --git a/exercises/practice/matching-brackets/matching-brackets-test.roc b/exercises/practice/matching-brackets/matching-brackets-test.roc index c40a1ad2..6922a02b 100644 --- a/exercises/practice/matching-brackets/matching-brackets-test.roc +++ b/exercises/practice/matching-brackets/matching-brackets-test.roc @@ -1,6 +1,6 @@ # These tests are auto-generated with test data from: # https://github.com/exercism/problem-specifications/tree/main/exercises/matching-brackets/canonical-data.json -# File last updated on 2025-01-04 +# File last updated on 2025-07-26 app [main!] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.19.0/Hj-J_zxz7V9YurCSTFcFdu6cQJie4guzsPMUi5kBYUk.tar.br", } @@ -8,7 +8,7 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line!("") + Stdout.line! "" import MatchingBrackets exposing [is_paired] diff --git a/exercises/practice/matrix/matrix-test.roc b/exercises/practice/matrix/matrix-test.roc index 6d104da3..de612e8a 100644 --- a/exercises/practice/matrix/matrix-test.roc +++ b/exercises/practice/matrix/matrix-test.roc @@ -1,6 +1,6 @@ # These tests are auto-generated with test data from: # https://github.com/exercism/problem-specifications/tree/main/exercises/matrix/canonical-data.json -# File last updated on 2025-01-04 +# File last updated on 2025-07-26 app [main!] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.19.0/Hj-J_zxz7V9YurCSTFcFdu6cQJie4guzsPMUi5kBYUk.tar.br", } @@ -8,15 +8,15 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line!("") + Stdout.line! "" import Matrix exposing [row, column] # extract row from one number matrix expect matrix_str = "1" - result = matrix_str |> row(1) - result == Ok([1]) + result = matrix_str |> row 1 + result == Ok [1] # can extract row expect @@ -25,8 +25,8 @@ expect 1 2 3 4 """ - result = matrix_str |> row(2) - result == Ok([3, 4]) + result = matrix_str |> row 2 + result == Ok [3, 4] # extract row where numbers have different widths expect @@ -35,8 +35,8 @@ expect 1 2 10 20 """ - result = matrix_str |> row(2) - result == Ok([10, 20]) + result = matrix_str |> row 2 + result == Ok [10, 20] # can extract row from non-square matrix with no corresponding column expect @@ -47,14 +47,14 @@ expect 7 8 9 8 7 6 """ - result = matrix_str |> row(4) - result == Ok([8, 7, 6]) + result = matrix_str |> row 4 + result == Ok [8, 7, 6] # extract column from one number matrix expect matrix_str = "1" - result = matrix_str |> column(1) - result == Ok([1]) + result = matrix_str |> column 1 + result == Ok [1] # can extract column expect @@ -64,8 +64,8 @@ expect 4 5 6 7 8 9 """ - result = matrix_str |> column(3) - result == Ok([3, 6, 9]) + result = matrix_str |> column 3 + result == Ok [3, 6, 9] # can extract column from non-square matrix with no corresponding row expect @@ -75,8 +75,8 @@ expect 5 6 7 8 9 8 7 6 """ - result = matrix_str |> column(4) - result == Ok([4, 8, 6]) + result = matrix_str |> column 4 + result == Ok [4, 8, 6] # extract column where numbers have different widths expect @@ -86,6 +86,6 @@ expect 18 3 1 9 4 800 """ - result = matrix_str |> column(2) - result == Ok([1903, 3, 4]) + result = matrix_str |> column 2 + result == Ok [1903, 3, 4] diff --git a/exercises/practice/meetup/meetup-test.roc b/exercises/practice/meetup/meetup-test.roc index a081093b..2149e8e9 100644 --- a/exercises/practice/meetup/meetup-test.roc +++ b/exercises/practice/meetup/meetup-test.roc @@ -1,6 +1,6 @@ # These tests are auto-generated with test data from: # https://github.com/exercism/problem-specifications/tree/main/exercises/meetup/canonical-data.json -# File last updated on 2025-01-04 +# File last updated on 2025-07-26 app [main!] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.19.0/Hj-J_zxz7V9YurCSTFcFdu6cQJie4guzsPMUi5kBYUk.tar.br", isodate: "https://github.com/imclerran/roc-isodate/releases/download/v0.6.0/79DATSmwkFXMsS0dF7w1RTHeQCGwFNzh9zylic4Fw9w.tar.br", @@ -9,1242 +9,1052 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line!("") + Stdout.line! "" import Meetup exposing [meetup] # when teenth Monday is the 13th, the first day of the teenth week expect - result = meetup( - { - year: 2013, - month: 5, - week: Teenth, - day_of_week: Monday, - }, - ) - expected = Ok("2013-05-13") + result = meetup { + year: 2013, + month: 5, + week: Teenth, + day_of_week: Monday, + } + expected = Ok "2013-05-13" result == expected # when teenth Monday is the 19th, the last day of the teenth week expect - result = meetup( - { - year: 2013, - month: 8, - week: Teenth, - day_of_week: Monday, - }, - ) - expected = Ok("2013-08-19") + result = meetup { + year: 2013, + month: 8, + week: Teenth, + day_of_week: Monday, + } + expected = Ok "2013-08-19" result == expected # when teenth Monday is some day in the middle of the teenth week expect - result = meetup( - { - year: 2013, - month: 9, - week: Teenth, - day_of_week: Monday, - }, - ) - expected = Ok("2013-09-16") + result = meetup { + year: 2013, + month: 9, + week: Teenth, + day_of_week: Monday, + } + expected = Ok "2013-09-16" result == expected # when teenth Tuesday is the 19th, the last day of the teenth week expect - result = meetup( - { - year: 2013, - month: 3, - week: Teenth, - day_of_week: Tuesday, - }, - ) - expected = Ok("2013-03-19") + result = meetup { + year: 2013, + month: 3, + week: Teenth, + day_of_week: Tuesday, + } + expected = Ok "2013-03-19" result == expected # when teenth Tuesday is some day in the middle of the teenth week expect - result = meetup( - { - year: 2013, - month: 4, - week: Teenth, - day_of_week: Tuesday, - }, - ) - expected = Ok("2013-04-16") + result = meetup { + year: 2013, + month: 4, + week: Teenth, + day_of_week: Tuesday, + } + expected = Ok "2013-04-16" result == expected # when teenth Tuesday is the 13th, the first day of the teenth week expect - result = meetup( - { - year: 2013, - month: 8, - week: Teenth, - day_of_week: Tuesday, - }, - ) - expected = Ok("2013-08-13") + result = meetup { + year: 2013, + month: 8, + week: Teenth, + day_of_week: Tuesday, + } + expected = Ok "2013-08-13" result == expected # when teenth Wednesday is some day in the middle of the teenth week expect - result = meetup( - { - year: 2013, - month: 1, - week: Teenth, - day_of_week: Wednesday, - }, - ) - expected = Ok("2013-01-16") + result = meetup { + year: 2013, + month: 1, + week: Teenth, + day_of_week: Wednesday, + } + expected = Ok "2013-01-16" result == expected # when teenth Wednesday is the 13th, the first day of the teenth week expect - result = meetup( - { - year: 2013, - month: 2, - week: Teenth, - day_of_week: Wednesday, - }, - ) - expected = Ok("2013-02-13") + result = meetup { + year: 2013, + month: 2, + week: Teenth, + day_of_week: Wednesday, + } + expected = Ok "2013-02-13" result == expected # when teenth Wednesday is the 19th, the last day of the teenth week expect - result = meetup( - { - year: 2013, - month: 6, - week: Teenth, - day_of_week: Wednesday, - }, - ) - expected = Ok("2013-06-19") + result = meetup { + year: 2013, + month: 6, + week: Teenth, + day_of_week: Wednesday, + } + expected = Ok "2013-06-19" result == expected # when teenth Thursday is some day in the middle of the teenth week expect - result = meetup( - { - year: 2013, - month: 5, - week: Teenth, - day_of_week: Thursday, - }, - ) - expected = Ok("2013-05-16") + result = meetup { + year: 2013, + month: 5, + week: Teenth, + day_of_week: Thursday, + } + expected = Ok "2013-05-16" result == expected # when teenth Thursday is the 13th, the first day of the teenth week expect - result = meetup( - { - year: 2013, - month: 6, - week: Teenth, - day_of_week: Thursday, - }, - ) - expected = Ok("2013-06-13") + result = meetup { + year: 2013, + month: 6, + week: Teenth, + day_of_week: Thursday, + } + expected = Ok "2013-06-13" result == expected # when teenth Thursday is the 19th, the last day of the teenth week expect - result = meetup( - { - year: 2013, - month: 9, - week: Teenth, - day_of_week: Thursday, - }, - ) - expected = Ok("2013-09-19") + result = meetup { + year: 2013, + month: 9, + week: Teenth, + day_of_week: Thursday, + } + expected = Ok "2013-09-19" result == expected # when teenth Friday is the 19th, the last day of the teenth week expect - result = meetup( - { - year: 2013, - month: 4, - week: Teenth, - day_of_week: Friday, - }, - ) - expected = Ok("2013-04-19") + result = meetup { + year: 2013, + month: 4, + week: Teenth, + day_of_week: Friday, + } + expected = Ok "2013-04-19" result == expected # when teenth Friday is some day in the middle of the teenth week expect - result = meetup( - { - year: 2013, - month: 8, - week: Teenth, - day_of_week: Friday, - }, - ) - expected = Ok("2013-08-16") + result = meetup { + year: 2013, + month: 8, + week: Teenth, + day_of_week: Friday, + } + expected = Ok "2013-08-16" result == expected # when teenth Friday is the 13th, the first day of the teenth week expect - result = meetup( - { - year: 2013, - month: 9, - week: Teenth, - day_of_week: Friday, - }, - ) - expected = Ok("2013-09-13") + result = meetup { + year: 2013, + month: 9, + week: Teenth, + day_of_week: Friday, + } + expected = Ok "2013-09-13" result == expected # when teenth Saturday is some day in the middle of the teenth week expect - result = meetup( - { - year: 2013, - month: 2, - week: Teenth, - day_of_week: Saturday, - }, - ) - expected = Ok("2013-02-16") + result = meetup { + year: 2013, + month: 2, + week: Teenth, + day_of_week: Saturday, + } + expected = Ok "2013-02-16" result == expected # when teenth Saturday is the 13th, the first day of the teenth week expect - result = meetup( - { - year: 2013, - month: 4, - week: Teenth, - day_of_week: Saturday, - }, - ) - expected = Ok("2013-04-13") + result = meetup { + year: 2013, + month: 4, + week: Teenth, + day_of_week: Saturday, + } + expected = Ok "2013-04-13" result == expected # when teenth Saturday is the 19th, the last day of the teenth week expect - result = meetup( - { - year: 2013, - month: 10, - week: Teenth, - day_of_week: Saturday, - }, - ) - expected = Ok("2013-10-19") + result = meetup { + year: 2013, + month: 10, + week: Teenth, + day_of_week: Saturday, + } + expected = Ok "2013-10-19" result == expected # when teenth Sunday is the 19th, the last day of the teenth week expect - result = meetup( - { - year: 2013, - month: 5, - week: Teenth, - day_of_week: Sunday, - }, - ) - expected = Ok("2013-05-19") + result = meetup { + year: 2013, + month: 5, + week: Teenth, + day_of_week: Sunday, + } + expected = Ok "2013-05-19" result == expected # when teenth Sunday is some day in the middle of the teenth week expect - result = meetup( - { - year: 2013, - month: 6, - week: Teenth, - day_of_week: Sunday, - }, - ) - expected = Ok("2013-06-16") + result = meetup { + year: 2013, + month: 6, + week: Teenth, + day_of_week: Sunday, + } + expected = Ok "2013-06-16" result == expected # when teenth Sunday is the 13th, the first day of the teenth week expect - result = meetup( - { - year: 2013, - month: 10, - week: Teenth, - day_of_week: Sunday, - }, - ) - expected = Ok("2013-10-13") + result = meetup { + year: 2013, + month: 10, + week: Teenth, + day_of_week: Sunday, + } + expected = Ok "2013-10-13" result == expected # when first Monday is some day in the middle of the first week expect - result = meetup( - { - year: 2013, - month: 3, - week: First, - day_of_week: Monday, - }, - ) - expected = Ok("2013-03-04") + result = meetup { + year: 2013, + month: 3, + week: First, + day_of_week: Monday, + } + expected = Ok "2013-03-04" result == expected # when first Monday is the 1st, the first day of the first week expect - result = meetup( - { - year: 2013, - month: 4, - week: First, - day_of_week: Monday, - }, - ) - expected = Ok("2013-04-01") + result = meetup { + year: 2013, + month: 4, + week: First, + day_of_week: Monday, + } + expected = Ok "2013-04-01" result == expected # when first Tuesday is the 7th, the last day of the first week expect - result = meetup( - { - year: 2013, - month: 5, - week: First, - day_of_week: Tuesday, - }, - ) - expected = Ok("2013-05-07") + result = meetup { + year: 2013, + month: 5, + week: First, + day_of_week: Tuesday, + } + expected = Ok "2013-05-07" result == expected # when first Tuesday is some day in the middle of the first week expect - result = meetup( - { - year: 2013, - month: 6, - week: First, - day_of_week: Tuesday, - }, - ) - expected = Ok("2013-06-04") + result = meetup { + year: 2013, + month: 6, + week: First, + day_of_week: Tuesday, + } + expected = Ok "2013-06-04" result == expected # when first Wednesday is some day in the middle of the first week expect - result = meetup( - { - year: 2013, - month: 7, - week: First, - day_of_week: Wednesday, - }, - ) - expected = Ok("2013-07-03") + result = meetup { + year: 2013, + month: 7, + week: First, + day_of_week: Wednesday, + } + expected = Ok "2013-07-03" result == expected # when first Wednesday is the 7th, the last day of the first week expect - result = meetup( - { - year: 2013, - month: 8, - week: First, - day_of_week: Wednesday, - }, - ) - expected = Ok("2013-08-07") + result = meetup { + year: 2013, + month: 8, + week: First, + day_of_week: Wednesday, + } + expected = Ok "2013-08-07" result == expected # when first Thursday is some day in the middle of the first week expect - result = meetup( - { - year: 2013, - month: 9, - week: First, - day_of_week: Thursday, - }, - ) - expected = Ok("2013-09-05") + result = meetup { + year: 2013, + month: 9, + week: First, + day_of_week: Thursday, + } + expected = Ok "2013-09-05" result == expected # when first Thursday is another day in the middle of the first week expect - result = meetup( - { - year: 2013, - month: 10, - week: First, - day_of_week: Thursday, - }, - ) - expected = Ok("2013-10-03") + result = meetup { + year: 2013, + month: 10, + week: First, + day_of_week: Thursday, + } + expected = Ok "2013-10-03" result == expected # when first Friday is the 1st, the first day of the first week expect - result = meetup( - { - year: 2013, - month: 11, - week: First, - day_of_week: Friday, - }, - ) - expected = Ok("2013-11-01") + result = meetup { + year: 2013, + month: 11, + week: First, + day_of_week: Friday, + } + expected = Ok "2013-11-01" result == expected # when first Friday is some day in the middle of the first week expect - result = meetup( - { - year: 2013, - month: 12, - week: First, - day_of_week: Friday, - }, - ) - expected = Ok("2013-12-06") + result = meetup { + year: 2013, + month: 12, + week: First, + day_of_week: Friday, + } + expected = Ok "2013-12-06" result == expected # when first Saturday is some day in the middle of the first week expect - result = meetup( - { - year: 2013, - month: 1, - week: First, - day_of_week: Saturday, - }, - ) - expected = Ok("2013-01-05") + result = meetup { + year: 2013, + month: 1, + week: First, + day_of_week: Saturday, + } + expected = Ok "2013-01-05" result == expected # when first Saturday is another day in the middle of the first week expect - result = meetup( - { - year: 2013, - month: 2, - week: First, - day_of_week: Saturday, - }, - ) - expected = Ok("2013-02-02") + result = meetup { + year: 2013, + month: 2, + week: First, + day_of_week: Saturday, + } + expected = Ok "2013-02-02" result == expected # when first Sunday is some day in the middle of the first week expect - result = meetup( - { - year: 2013, - month: 3, - week: First, - day_of_week: Sunday, - }, - ) - expected = Ok("2013-03-03") + result = meetup { + year: 2013, + month: 3, + week: First, + day_of_week: Sunday, + } + expected = Ok "2013-03-03" result == expected # when first Sunday is the 7th, the last day of the first week expect - result = meetup( - { - year: 2013, - month: 4, - week: First, - day_of_week: Sunday, - }, - ) - expected = Ok("2013-04-07") + result = meetup { + year: 2013, + month: 4, + week: First, + day_of_week: Sunday, + } + expected = Ok "2013-04-07" result == expected # when second Monday is some day in the middle of the second week expect - result = meetup( - { - year: 2013, - month: 3, - week: Second, - day_of_week: Monday, - }, - ) - expected = Ok("2013-03-11") + result = meetup { + year: 2013, + month: 3, + week: Second, + day_of_week: Monday, + } + expected = Ok "2013-03-11" result == expected # when second Monday is the 8th, the first day of the second week expect - result = meetup( - { - year: 2013, - month: 4, - week: Second, - day_of_week: Monday, - }, - ) - expected = Ok("2013-04-08") + result = meetup { + year: 2013, + month: 4, + week: Second, + day_of_week: Monday, + } + expected = Ok "2013-04-08" result == expected # when second Tuesday is the 14th, the last day of the second week expect - result = meetup( - { - year: 2013, - month: 5, - week: Second, - day_of_week: Tuesday, - }, - ) - expected = Ok("2013-05-14") + result = meetup { + year: 2013, + month: 5, + week: Second, + day_of_week: Tuesday, + } + expected = Ok "2013-05-14" result == expected # when second Tuesday is some day in the middle of the second week expect - result = meetup( - { - year: 2013, - month: 6, - week: Second, - day_of_week: Tuesday, - }, - ) - expected = Ok("2013-06-11") + result = meetup { + year: 2013, + month: 6, + week: Second, + day_of_week: Tuesday, + } + expected = Ok "2013-06-11" result == expected # when second Wednesday is some day in the middle of the second week expect - result = meetup( - { - year: 2013, - month: 7, - week: Second, - day_of_week: Wednesday, - }, - ) - expected = Ok("2013-07-10") + result = meetup { + year: 2013, + month: 7, + week: Second, + day_of_week: Wednesday, + } + expected = Ok "2013-07-10" result == expected # when second Wednesday is the 14th, the last day of the second week expect - result = meetup( - { - year: 2013, - month: 8, - week: Second, - day_of_week: Wednesday, - }, - ) - expected = Ok("2013-08-14") + result = meetup { + year: 2013, + month: 8, + week: Second, + day_of_week: Wednesday, + } + expected = Ok "2013-08-14" result == expected # when second Thursday is some day in the middle of the second week expect - result = meetup( - { - year: 2013, - month: 9, - week: Second, - day_of_week: Thursday, - }, - ) - expected = Ok("2013-09-12") + result = meetup { + year: 2013, + month: 9, + week: Second, + day_of_week: Thursday, + } + expected = Ok "2013-09-12" result == expected # when second Thursday is another day in the middle of the second week expect - result = meetup( - { - year: 2013, - month: 10, - week: Second, - day_of_week: Thursday, - }, - ) - expected = Ok("2013-10-10") + result = meetup { + year: 2013, + month: 10, + week: Second, + day_of_week: Thursday, + } + expected = Ok "2013-10-10" result == expected # when second Friday is the 8th, the first day of the second week expect - result = meetup( - { - year: 2013, - month: 11, - week: Second, - day_of_week: Friday, - }, - ) - expected = Ok("2013-11-08") + result = meetup { + year: 2013, + month: 11, + week: Second, + day_of_week: Friday, + } + expected = Ok "2013-11-08" result == expected # when second Friday is some day in the middle of the second week expect - result = meetup( - { - year: 2013, - month: 12, - week: Second, - day_of_week: Friday, - }, - ) - expected = Ok("2013-12-13") + result = meetup { + year: 2013, + month: 12, + week: Second, + day_of_week: Friday, + } + expected = Ok "2013-12-13" result == expected # when second Saturday is some day in the middle of the second week expect - result = meetup( - { - year: 2013, - month: 1, - week: Second, - day_of_week: Saturday, - }, - ) - expected = Ok("2013-01-12") + result = meetup { + year: 2013, + month: 1, + week: Second, + day_of_week: Saturday, + } + expected = Ok "2013-01-12" result == expected # when second Saturday is another day in the middle of the second week expect - result = meetup( - { - year: 2013, - month: 2, - week: Second, - day_of_week: Saturday, - }, - ) - expected = Ok("2013-02-09") + result = meetup { + year: 2013, + month: 2, + week: Second, + day_of_week: Saturday, + } + expected = Ok "2013-02-09" result == expected # when second Sunday is some day in the middle of the second week expect - result = meetup( - { - year: 2013, - month: 3, - week: Second, - day_of_week: Sunday, - }, - ) - expected = Ok("2013-03-10") + result = meetup { + year: 2013, + month: 3, + week: Second, + day_of_week: Sunday, + } + expected = Ok "2013-03-10" result == expected # when second Sunday is the 14th, the last day of the second week expect - result = meetup( - { - year: 2013, - month: 4, - week: Second, - day_of_week: Sunday, - }, - ) - expected = Ok("2013-04-14") + result = meetup { + year: 2013, + month: 4, + week: Second, + day_of_week: Sunday, + } + expected = Ok "2013-04-14" result == expected # when third Monday is some day in the middle of the third week expect - result = meetup( - { - year: 2013, - month: 3, - week: Third, - day_of_week: Monday, - }, - ) - expected = Ok("2013-03-18") + result = meetup { + year: 2013, + month: 3, + week: Third, + day_of_week: Monday, + } + expected = Ok "2013-03-18" result == expected # when third Monday is the 15th, the first day of the third week expect - result = meetup( - { - year: 2013, - month: 4, - week: Third, - day_of_week: Monday, - }, - ) - expected = Ok("2013-04-15") + result = meetup { + year: 2013, + month: 4, + week: Third, + day_of_week: Monday, + } + expected = Ok "2013-04-15" result == expected # when third Tuesday is the 21st, the last day of the third week expect - result = meetup( - { - year: 2013, - month: 5, - week: Third, - day_of_week: Tuesday, - }, - ) - expected = Ok("2013-05-21") + result = meetup { + year: 2013, + month: 5, + week: Third, + day_of_week: Tuesday, + } + expected = Ok "2013-05-21" result == expected # when third Tuesday is some day in the middle of the third week expect - result = meetup( - { - year: 2013, - month: 6, - week: Third, - day_of_week: Tuesday, - }, - ) - expected = Ok("2013-06-18") + result = meetup { + year: 2013, + month: 6, + week: Third, + day_of_week: Tuesday, + } + expected = Ok "2013-06-18" result == expected # when third Wednesday is some day in the middle of the third week expect - result = meetup( - { - year: 2013, - month: 7, - week: Third, - day_of_week: Wednesday, - }, - ) - expected = Ok("2013-07-17") + result = meetup { + year: 2013, + month: 7, + week: Third, + day_of_week: Wednesday, + } + expected = Ok "2013-07-17" result == expected # when third Wednesday is the 21st, the last day of the third week expect - result = meetup( - { - year: 2013, - month: 8, - week: Third, - day_of_week: Wednesday, - }, - ) - expected = Ok("2013-08-21") + result = meetup { + year: 2013, + month: 8, + week: Third, + day_of_week: Wednesday, + } + expected = Ok "2013-08-21" result == expected # when third Thursday is some day in the middle of the third week expect - result = meetup( - { - year: 2013, - month: 9, - week: Third, - day_of_week: Thursday, - }, - ) - expected = Ok("2013-09-19") + result = meetup { + year: 2013, + month: 9, + week: Third, + day_of_week: Thursday, + } + expected = Ok "2013-09-19" result == expected # when third Thursday is another day in the middle of the third week expect - result = meetup( - { - year: 2013, - month: 10, - week: Third, - day_of_week: Thursday, - }, - ) - expected = Ok("2013-10-17") + result = meetup { + year: 2013, + month: 10, + week: Third, + day_of_week: Thursday, + } + expected = Ok "2013-10-17" result == expected # when third Friday is the 15th, the first day of the third week expect - result = meetup( - { - year: 2013, - month: 11, - week: Third, - day_of_week: Friday, - }, - ) - expected = Ok("2013-11-15") + result = meetup { + year: 2013, + month: 11, + week: Third, + day_of_week: Friday, + } + expected = Ok "2013-11-15" result == expected # when third Friday is some day in the middle of the third week expect - result = meetup( - { - year: 2013, - month: 12, - week: Third, - day_of_week: Friday, - }, - ) - expected = Ok("2013-12-20") + result = meetup { + year: 2013, + month: 12, + week: Third, + day_of_week: Friday, + } + expected = Ok "2013-12-20" result == expected # when third Saturday is some day in the middle of the third week expect - result = meetup( - { - year: 2013, - month: 1, - week: Third, - day_of_week: Saturday, - }, - ) - expected = Ok("2013-01-19") + result = meetup { + year: 2013, + month: 1, + week: Third, + day_of_week: Saturday, + } + expected = Ok "2013-01-19" result == expected # when third Saturday is another day in the middle of the third week expect - result = meetup( - { - year: 2013, - month: 2, - week: Third, - day_of_week: Saturday, - }, - ) - expected = Ok("2013-02-16") + result = meetup { + year: 2013, + month: 2, + week: Third, + day_of_week: Saturday, + } + expected = Ok "2013-02-16" result == expected # when third Sunday is some day in the middle of the third week expect - result = meetup( - { - year: 2013, - month: 3, - week: Third, - day_of_week: Sunday, - }, - ) - expected = Ok("2013-03-17") + result = meetup { + year: 2013, + month: 3, + week: Third, + day_of_week: Sunday, + } + expected = Ok "2013-03-17" result == expected # when third Sunday is the 21st, the last day of the third week expect - result = meetup( - { - year: 2013, - month: 4, - week: Third, - day_of_week: Sunday, - }, - ) - expected = Ok("2013-04-21") + result = meetup { + year: 2013, + month: 4, + week: Third, + day_of_week: Sunday, + } + expected = Ok "2013-04-21" result == expected # when fourth Monday is some day in the middle of the fourth week expect - result = meetup( - { - year: 2013, - month: 3, - week: Fourth, - day_of_week: Monday, - }, - ) - expected = Ok("2013-03-25") + result = meetup { + year: 2013, + month: 3, + week: Fourth, + day_of_week: Monday, + } + expected = Ok "2013-03-25" result == expected # when fourth Monday is the 22nd, the first day of the fourth week expect - result = meetup( - { - year: 2013, - month: 4, - week: Fourth, - day_of_week: Monday, - }, - ) - expected = Ok("2013-04-22") + result = meetup { + year: 2013, + month: 4, + week: Fourth, + day_of_week: Monday, + } + expected = Ok "2013-04-22" result == expected # when fourth Tuesday is the 28th, the last day of the fourth week expect - result = meetup( - { - year: 2013, - month: 5, - week: Fourth, - day_of_week: Tuesday, - }, - ) - expected = Ok("2013-05-28") + result = meetup { + year: 2013, + month: 5, + week: Fourth, + day_of_week: Tuesday, + } + expected = Ok "2013-05-28" result == expected # when fourth Tuesday is some day in the middle of the fourth week expect - result = meetup( - { - year: 2013, - month: 6, - week: Fourth, - day_of_week: Tuesday, - }, - ) - expected = Ok("2013-06-25") + result = meetup { + year: 2013, + month: 6, + week: Fourth, + day_of_week: Tuesday, + } + expected = Ok "2013-06-25" result == expected # when fourth Wednesday is some day in the middle of the fourth week expect - result = meetup( - { - year: 2013, - month: 7, - week: Fourth, - day_of_week: Wednesday, - }, - ) - expected = Ok("2013-07-24") + result = meetup { + year: 2013, + month: 7, + week: Fourth, + day_of_week: Wednesday, + } + expected = Ok "2013-07-24" result == expected # when fourth Wednesday is the 28th, the last day of the fourth week expect - result = meetup( - { - year: 2013, - month: 8, - week: Fourth, - day_of_week: Wednesday, - }, - ) - expected = Ok("2013-08-28") + result = meetup { + year: 2013, + month: 8, + week: Fourth, + day_of_week: Wednesday, + } + expected = Ok "2013-08-28" result == expected # when fourth Thursday is some day in the middle of the fourth week expect - result = meetup( - { - year: 2013, - month: 9, - week: Fourth, - day_of_week: Thursday, - }, - ) - expected = Ok("2013-09-26") + result = meetup { + year: 2013, + month: 9, + week: Fourth, + day_of_week: Thursday, + } + expected = Ok "2013-09-26" result == expected # when fourth Thursday is another day in the middle of the fourth week expect - result = meetup( - { - year: 2013, - month: 10, - week: Fourth, - day_of_week: Thursday, - }, - ) - expected = Ok("2013-10-24") + result = meetup { + year: 2013, + month: 10, + week: Fourth, + day_of_week: Thursday, + } + expected = Ok "2013-10-24" result == expected # when fourth Friday is the 22nd, the first day of the fourth week expect - result = meetup( - { - year: 2013, - month: 11, - week: Fourth, - day_of_week: Friday, - }, - ) - expected = Ok("2013-11-22") + result = meetup { + year: 2013, + month: 11, + week: Fourth, + day_of_week: Friday, + } + expected = Ok "2013-11-22" result == expected # when fourth Friday is some day in the middle of the fourth week expect - result = meetup( - { - year: 2013, - month: 12, - week: Fourth, - day_of_week: Friday, - }, - ) - expected = Ok("2013-12-27") + result = meetup { + year: 2013, + month: 12, + week: Fourth, + day_of_week: Friday, + } + expected = Ok "2013-12-27" result == expected # when fourth Saturday is some day in the middle of the fourth week expect - result = meetup( - { - year: 2013, - month: 1, - week: Fourth, - day_of_week: Saturday, - }, - ) - expected = Ok("2013-01-26") + result = meetup { + year: 2013, + month: 1, + week: Fourth, + day_of_week: Saturday, + } + expected = Ok "2013-01-26" result == expected # when fourth Saturday is another day in the middle of the fourth week expect - result = meetup( - { - year: 2013, - month: 2, - week: Fourth, - day_of_week: Saturday, - }, - ) - expected = Ok("2013-02-23") + result = meetup { + year: 2013, + month: 2, + week: Fourth, + day_of_week: Saturday, + } + expected = Ok "2013-02-23" result == expected # when fourth Sunday is some day in the middle of the fourth week expect - result = meetup( - { - year: 2013, - month: 3, - week: Fourth, - day_of_week: Sunday, - }, - ) - expected = Ok("2013-03-24") + result = meetup { + year: 2013, + month: 3, + week: Fourth, + day_of_week: Sunday, + } + expected = Ok "2013-03-24" result == expected # when fourth Sunday is the 28th, the last day of the fourth week expect - result = meetup( - { - year: 2013, - month: 4, - week: Fourth, - day_of_week: Sunday, - }, - ) - expected = Ok("2013-04-28") + result = meetup { + year: 2013, + month: 4, + week: Fourth, + day_of_week: Sunday, + } + expected = Ok "2013-04-28" result == expected # last Monday in a month with four Mondays expect - result = meetup( - { - year: 2013, - month: 3, - week: Last, - day_of_week: Monday, - }, - ) - expected = Ok("2013-03-25") + result = meetup { + year: 2013, + month: 3, + week: Last, + day_of_week: Monday, + } + expected = Ok "2013-03-25" result == expected # last Monday in a month with five Mondays expect - result = meetup( - { - year: 2013, - month: 4, - week: Last, - day_of_week: Monday, - }, - ) - expected = Ok("2013-04-29") + result = meetup { + year: 2013, + month: 4, + week: Last, + day_of_week: Monday, + } + expected = Ok "2013-04-29" result == expected # last Tuesday in a month with four Tuesdays expect - result = meetup( - { - year: 2013, - month: 5, - week: Last, - day_of_week: Tuesday, - }, - ) - expected = Ok("2013-05-28") + result = meetup { + year: 2013, + month: 5, + week: Last, + day_of_week: Tuesday, + } + expected = Ok "2013-05-28" result == expected # last Tuesday in another month with four Tuesdays expect - result = meetup( - { - year: 2013, - month: 6, - week: Last, - day_of_week: Tuesday, - }, - ) - expected = Ok("2013-06-25") + result = meetup { + year: 2013, + month: 6, + week: Last, + day_of_week: Tuesday, + } + expected = Ok "2013-06-25" result == expected # last Wednesday in a month with five Wednesdays expect - result = meetup( - { - year: 2013, - month: 7, - week: Last, - day_of_week: Wednesday, - }, - ) - expected = Ok("2013-07-31") + result = meetup { + year: 2013, + month: 7, + week: Last, + day_of_week: Wednesday, + } + expected = Ok "2013-07-31" result == expected # last Wednesday in a month with four Wednesdays expect - result = meetup( - { - year: 2013, - month: 8, - week: Last, - day_of_week: Wednesday, - }, - ) - expected = Ok("2013-08-28") + result = meetup { + year: 2013, + month: 8, + week: Last, + day_of_week: Wednesday, + } + expected = Ok "2013-08-28" result == expected # last Thursday in a month with four Thursdays expect - result = meetup( - { - year: 2013, - month: 9, - week: Last, - day_of_week: Thursday, - }, - ) - expected = Ok("2013-09-26") + result = meetup { + year: 2013, + month: 9, + week: Last, + day_of_week: Thursday, + } + expected = Ok "2013-09-26" result == expected # last Thursday in a month with five Thursdays expect - result = meetup( - { - year: 2013, - month: 10, - week: Last, - day_of_week: Thursday, - }, - ) - expected = Ok("2013-10-31") + result = meetup { + year: 2013, + month: 10, + week: Last, + day_of_week: Thursday, + } + expected = Ok "2013-10-31" result == expected # last Friday in a month with five Fridays expect - result = meetup( - { - year: 2013, - month: 11, - week: Last, - day_of_week: Friday, - }, - ) - expected = Ok("2013-11-29") + result = meetup { + year: 2013, + month: 11, + week: Last, + day_of_week: Friday, + } + expected = Ok "2013-11-29" result == expected # last Friday in a month with four Fridays expect - result = meetup( - { - year: 2013, - month: 12, - week: Last, - day_of_week: Friday, - }, - ) - expected = Ok("2013-12-27") + result = meetup { + year: 2013, + month: 12, + week: Last, + day_of_week: Friday, + } + expected = Ok "2013-12-27" result == expected # last Saturday in a month with four Saturdays expect - result = meetup( - { - year: 2013, - month: 1, - week: Last, - day_of_week: Saturday, - }, - ) - expected = Ok("2013-01-26") + result = meetup { + year: 2013, + month: 1, + week: Last, + day_of_week: Saturday, + } + expected = Ok "2013-01-26" result == expected # last Saturday in another month with four Saturdays expect - result = meetup( - { - year: 2013, - month: 2, - week: Last, - day_of_week: Saturday, - }, - ) - expected = Ok("2013-02-23") + result = meetup { + year: 2013, + month: 2, + week: Last, + day_of_week: Saturday, + } + expected = Ok "2013-02-23" result == expected # last Sunday in a month with five Sundays expect - result = meetup( - { - year: 2013, - month: 3, - week: Last, - day_of_week: Sunday, - }, - ) - expected = Ok("2013-03-31") + result = meetup { + year: 2013, + month: 3, + week: Last, + day_of_week: Sunday, + } + expected = Ok "2013-03-31" result == expected # last Sunday in a month with four Sundays expect - result = meetup( - { - year: 2013, - month: 4, - week: Last, - day_of_week: Sunday, - }, - ) - expected = Ok("2013-04-28") + result = meetup { + year: 2013, + month: 4, + week: Last, + day_of_week: Sunday, + } + expected = Ok "2013-04-28" result == expected # when last Wednesday in February in a leap year is the 29th expect - result = meetup( - { - year: 2012, - month: 2, - week: Last, - day_of_week: Wednesday, - }, - ) - expected = Ok("2012-02-29") + result = meetup { + year: 2012, + month: 2, + week: Last, + day_of_week: Wednesday, + } + expected = Ok "2012-02-29" result == expected # last Wednesday in December that is also the last day of the year expect - result = meetup( - { - year: 2014, - month: 12, - week: Last, - day_of_week: Wednesday, - }, - ) - expected = Ok("2014-12-31") + result = meetup { + year: 2014, + month: 12, + week: Last, + day_of_week: Wednesday, + } + expected = Ok "2014-12-31" result == expected # when last Sunday in February in a non-leap year is not the 29th expect - result = meetup( - { - year: 2015, - month: 2, - week: Last, - day_of_week: Sunday, - }, - ) - expected = Ok("2015-02-22") + result = meetup { + year: 2015, + month: 2, + week: Last, + day_of_week: Sunday, + } + expected = Ok "2015-02-22" result == expected # when first Friday is the 7th, the last day of the first week expect - result = meetup( - { - year: 2012, - month: 12, - week: First, - day_of_week: Friday, - }, - ) - expected = Ok("2012-12-07") + result = meetup { + year: 2012, + month: 12, + week: First, + day_of_week: Friday, + } + expected = Ok "2012-12-07" result == expected diff --git a/exercises/practice/micro-blog/micro-blog-test.roc b/exercises/practice/micro-blog/micro-blog-test.roc index 089cc9fb..9f1f1f19 100644 --- a/exercises/practice/micro-blog/micro-blog-test.roc +++ b/exercises/practice/micro-blog/micro-blog-test.roc @@ -1,6 +1,6 @@ # These tests are auto-generated with test data from: # https://github.com/exercism/problem-specifications/tree/main/exercises/micro-blog/canonical-data.json -# File last updated on 2025-01-04 +# File last updated on 2025-07-26 app [main!] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.19.0/Hj-J_zxz7V9YurCSTFcFdu6cQJie4guzsPMUi5kBYUk.tar.br", unicode: "https://github.com/roc-lang/unicode/releases/download/0.3.0/9KKFsA4CdOz0JIOL7iBSI_2jGIXQ6TsFBXgd086idpY.tar.br", @@ -9,67 +9,67 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line!("") + Stdout.line! "" import MicroBlog exposing [truncate] # English language short expect - result = truncate("Hi") - result == Ok("Hi") + result = truncate "Hi" + result == Ok "Hi" # English language long expect - result = truncate("Hello there") - result == Ok("Hello") + result = truncate "Hello there" + result == Ok "Hello" # German language short (broth) expect - result = truncate("brühe") - result == Ok("brühe") + result = truncate "brühe" + result == Ok "brühe" # German language long (bear carpet → beards) expect - result = truncate("Bärteppich") - result == Ok("Bärte") + result = truncate "Bärteppich" + result == Ok "Bärte" # Bulgarian language short (good) expect - result = truncate("Добър") - result == Ok("Добър") + result = truncate "Добър" + result == Ok "Добър" # Greek language short (health) expect - result = truncate("υγειά") - result == Ok("υγειά") + result = truncate "υγειά" + result == Ok "υγειά" # Maths short expect - result = truncate("a=πr²") - result == Ok("a=πr²") + result = truncate "a=πr²" + result == Ok "a=πr²" # Maths long expect - result = truncate("∅⊊ℕ⊊ℤ⊊ℚ⊊ℝ⊊ℂ") - result == Ok("∅⊊ℕ⊊ℤ") + result = truncate "∅⊊ℕ⊊ℤ⊊ℚ⊊ℝ⊊ℂ" + result == Ok "∅⊊ℕ⊊ℤ" # English and emoji short expect - result = truncate("Fly 🛫") - result == Ok("Fly 🛫") + result = truncate "Fly 🛫" + result == Ok "Fly 🛫" # Emoji short expect - result = truncate("💇") - result == Ok("💇") + result = truncate "💇" + result == Ok "💇" # Emoji long expect - result = truncate("❄🌡🤧🤒🏥🕰😀") - result == Ok("❄🌡🤧🤒🏥") + result = truncate "❄🌡🤧🤒🏥🕰😀" + result == Ok "❄🌡🤧🤒🏥" # Royal Flush? expect - result = truncate("🃎🂸🃅🃋🃍🃁🃊") - result == Ok("🃎🂸🃅🃋🃍") + result = truncate "🃎🂸🃅🃋🃍🃁🃊" + result == Ok "🃎🂸🃅🃋🃍" diff --git a/exercises/practice/minesweeper/minesweeper-test.roc b/exercises/practice/minesweeper/minesweeper-test.roc index aafb6cd1..601218fe 100644 --- a/exercises/practice/minesweeper/minesweeper-test.roc +++ b/exercises/practice/minesweeper/minesweeper-test.roc @@ -1,6 +1,6 @@ # These tests are auto-generated with test data from: # https://github.com/exercism/problem-specifications/tree/main/exercises/minesweeper/canonical-data.json -# File last updated on 2025-01-04 +# File last updated on 2025-07-26 app [main!] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.19.0/Hj-J_zxz7V9YurCSTFcFdu6cQJie4guzsPMUi5kBYUk.tar.br", } @@ -8,22 +8,22 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line!("") + Stdout.line! "" import Minesweeper exposing [annotate] # no rows expect - minefield = "" |> Str.replace_each("·", " ") - result = annotate(minefield) - expected = "" |> Str.replace_each("·", " ") + minefield = "" |> Str.replace_each "·" " " + result = annotate minefield + expected = "" |> Str.replace_each "·" " " result == expected # no columns expect - minefield = "" |> Str.replace_each("·", " ") - result = annotate(minefield) - expected = "" |> Str.replace_each("·", " ") + minefield = "" |> Str.replace_each "·" " " + result = annotate minefield + expected = "" |> Str.replace_each "·" " " result == expected # no mines @@ -34,15 +34,15 @@ expect ··· ··· """ - |> Str.replace_each("·", " ") - result = annotate(minefield) + |> Str.replace_each "·" " " + result = annotate minefield expected = """ ··· ··· ··· """ - |> Str.replace_each("·", " ") + |> Str.replace_each "·" " " result == expected # minefield with only mines @@ -53,15 +53,15 @@ expect *** *** """ - |> Str.replace_each("·", " ") - result = annotate(minefield) + |> Str.replace_each "·" " " + result = annotate minefield expected = """ *** *** *** """ - |> Str.replace_each("·", " ") + |> Str.replace_each "·" " " result == expected # mine surrounded by spaces @@ -72,15 +72,15 @@ expect ·*· ··· """ - |> Str.replace_each("·", " ") - result = annotate(minefield) + |> Str.replace_each "·" " " + result = annotate minefield expected = """ 111 1*1 111 """ - |> Str.replace_each("·", " ") + |> Str.replace_each "·" " " result == expected # space surrounded by mines @@ -91,29 +91,29 @@ expect *·* *** """ - |> Str.replace_each("·", " ") - result = annotate(minefield) + |> Str.replace_each "·" " " + result = annotate minefield expected = """ *** *8* *** """ - |> Str.replace_each("·", " ") + |> Str.replace_each "·" " " result == expected # horizontal line expect - minefield = "·*·*·" |> Str.replace_each("·", " ") - result = annotate(minefield) - expected = "1*2*1" |> Str.replace_each("·", " ") + minefield = "·*·*·" |> Str.replace_each "·" " " + result = annotate minefield + expected = "1*2*1" |> Str.replace_each "·" " " result == expected # horizontal line, mines at edges expect - minefield = "*···*" |> Str.replace_each("·", " ") - result = annotate(minefield) - expected = "*1·1*" |> Str.replace_each("·", " ") + minefield = "*···*" |> Str.replace_each "·" " " + result = annotate minefield + expected = "*1·1*" |> Str.replace_each "·" " " result == expected # vertical line @@ -126,8 +126,8 @@ expect * · """ - |> Str.replace_each("·", " ") - result = annotate(minefield) + |> Str.replace_each "·" " " + result = annotate minefield expected = """ 1 @@ -136,7 +136,7 @@ expect * 1 """ - |> Str.replace_each("·", " ") + |> Str.replace_each "·" " " result == expected # vertical line, mines at edges @@ -149,8 +149,8 @@ expect · * """ - |> Str.replace_each("·", " ") - result = annotate(minefield) + |> Str.replace_each "·" " " + result = annotate minefield expected = """ * @@ -159,7 +159,7 @@ expect 1 * """ - |> Str.replace_each("·", " ") + |> Str.replace_each "·" " " result == expected # cross @@ -172,8 +172,8 @@ expect ··*·· ··*·· """ - |> Str.replace_each("·", " ") - result = annotate(minefield) + |> Str.replace_each "·" " " + result = annotate minefield expected = """ ·2*2· @@ -182,7 +182,7 @@ expect 25*52 ·2*2· """ - |> Str.replace_each("·", " ") + |> Str.replace_each "·" " " result == expected # large minefield @@ -196,8 +196,8 @@ expect ·*··*· ······ """ - |> Str.replace_each("·", " ") - result = annotate(minefield) + |> Str.replace_each "·" " " + result = annotate minefield expected = """ 1*22*1 @@ -207,6 +207,6 @@ expect 1*22*2 111111 """ - |> Str.replace_each("·", " ") + |> Str.replace_each "·" " " result == expected diff --git a/exercises/practice/nth-prime/nth-prime-test.roc b/exercises/practice/nth-prime/nth-prime-test.roc index 577c988e..6bb1741d 100644 --- a/exercises/practice/nth-prime/nth-prime-test.roc +++ b/exercises/practice/nth-prime/nth-prime-test.roc @@ -1,6 +1,6 @@ # These tests are auto-generated with test data from: # https://github.com/exercism/problem-specifications/tree/main/exercises/nth-prime/canonical-data.json -# File last updated on 2025-01-04 +# File last updated on 2025-07-26 app [main!] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.19.0/Hj-J_zxz7V9YurCSTFcFdu6cQJie4guzsPMUi5kBYUk.tar.br", } @@ -8,32 +8,32 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line!("") + Stdout.line! "" import NthPrime exposing [prime] # first prime expect - result = prime(1) - result == Ok(2) + result = prime 1 + result == Ok 2 # second prime expect - result = prime(2) - result == Ok(3) + result = prime 2 + result == Ok 3 # sixth prime expect - result = prime(6) - result == Ok(13) + result = prime 6 + result == Ok 13 # big prime expect - result = prime(10001) - result == Ok(104743) + result = prime 10001 + result == Ok 104743 # there is no zeroth prime expect - result = prime(0) + result = prime 0 result |> Result.is_err diff --git a/exercises/practice/nucleotide-count/nucleotide-count-test.roc b/exercises/practice/nucleotide-count/nucleotide-count-test.roc index b1a47b9d..8f722a9d 100644 --- a/exercises/practice/nucleotide-count/nucleotide-count-test.roc +++ b/exercises/practice/nucleotide-count/nucleotide-count-test.roc @@ -1,6 +1,6 @@ # These tests are auto-generated with test data from: # https://github.com/exercism/problem-specifications/tree/main/exercises/nucleotide-count/canonical-data.json -# File last updated on 2025-01-04 +# File last updated on 2025-07-26 app [main!] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.19.0/Hj-J_zxz7V9YurCSTFcFdu6cQJie4guzsPMUi5kBYUk.tar.br", } @@ -8,32 +8,32 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line!("") + Stdout.line! "" import NucleotideCount exposing [nucleotide_counts] # empty strand expect - result = nucleotide_counts("") - result == Ok({ a: 0, c: 0, g: 0, t: 0 }) + result = nucleotide_counts "" + result == Ok { a: 0, c: 0, g: 0, t: 0 } # can count one nucleotide in single-character input expect - result = nucleotide_counts("G") - result == Ok({ a: 0, c: 0, g: 1, t: 0 }) + result = nucleotide_counts "G" + result == Ok { a: 0, c: 0, g: 1, t: 0 } # strand with repeated nucleotide expect - result = nucleotide_counts("GGGGGGG") - result == Ok({ a: 0, c: 0, g: 7, t: 0 }) + result = nucleotide_counts "GGGGGGG" + result == Ok { a: 0, c: 0, g: 7, t: 0 } # strand with multiple nucleotides expect - result = nucleotide_counts("AGCTTTTCATTCTGACTGCAACGGGCAATATGTCTCTGTGTGGATTAAAAAAAGAGTGTCTGATAGCAGC") - result == Ok({ a: 20, c: 12, g: 17, t: 21 }) + result = nucleotide_counts "AGCTTTTCATTCTGACTGCAACGGGCAATATGTCTCTGTGTGGATTAAAAAAAGAGTGTCTGATAGCAGC" + result == Ok { a: 20, c: 12, g: 17, t: 21 } # strand with invalid nucleotides expect - result = nucleotide_counts("AGXXACT") - Result.is_err(result) + result = nucleotide_counts "AGXXACT" + Result.is_err result diff --git a/exercises/practice/ocr-numbers/ocr-numbers-test.roc b/exercises/practice/ocr-numbers/ocr-numbers-test.roc index ab12cca5..44b441ac 100644 --- a/exercises/practice/ocr-numbers/ocr-numbers-test.roc +++ b/exercises/practice/ocr-numbers/ocr-numbers-test.roc @@ -1,6 +1,6 @@ # These tests are auto-generated with test data from: # https://github.com/exercism/problem-specifications/tree/main/exercises/ocr-numbers/canonical-data.json -# File last updated on 2025-01-04 +# File last updated on 2025-07-26 app [main!] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.19.0/Hj-J_zxz7V9YurCSTFcFdu6cQJie4guzsPMUi5kBYUk.tar.br", } @@ -8,7 +8,7 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line!("") + Stdout.line! "" import OcrNumbers exposing [convert] @@ -21,8 +21,8 @@ expect |_| """ - result = convert(grid) - expected = Ok("0") + result = convert grid + expected = Ok "0" result == expected # Recognizes 1 @@ -34,8 +34,8 @@ expect | """ - result = convert(grid) - expected = Ok("1") + result = convert grid + expected = Ok "1" result == expected # Unreadable but correctly sized inputs return ? @@ -47,8 +47,8 @@ expect | """ - result = convert(grid) - expected = Ok("?") + result = convert grid + expected = Ok "?" result == expected # Input with a number of lines that is not a multiple of four raises an error @@ -59,7 +59,7 @@ expect | | """ - result = convert(grid) + result = convert grid result |> Result.is_err # Input with a number of columns that is not a multiple of three raises an error @@ -71,7 +71,7 @@ expect | """ - result = convert(grid) + result = convert grid result |> Result.is_err # Recognizes 110101100 @@ -83,8 +83,8 @@ expect | ||_| ||_| | ||_||_| """ - result = convert(grid) - expected = Ok("110101100") + result = convert grid + expected = Ok "110101100" result == expected # Garbled numbers in a string are replaced with ? @@ -96,8 +96,8 @@ expect | | _| ||_| | ||_||_| """ - result = convert(grid) - expected = Ok("11?10?1?0") + result = convert grid + expected = Ok "11?10?1?0" result == expected # Recognizes 2 @@ -109,8 +109,8 @@ expect |_ """ - result = convert(grid) - expected = Ok("2") + result = convert grid + expected = Ok "2" result == expected # Recognizes 3 @@ -122,8 +122,8 @@ expect _| """ - result = convert(grid) - expected = Ok("3") + result = convert grid + expected = Ok "3" result == expected # Recognizes 4 @@ -135,8 +135,8 @@ expect | """ - result = convert(grid) - expected = Ok("4") + result = convert grid + expected = Ok "4" result == expected # Recognizes 5 @@ -148,8 +148,8 @@ expect _| """ - result = convert(grid) - expected = Ok("5") + result = convert grid + expected = Ok "5" result == expected # Recognizes 6 @@ -161,8 +161,8 @@ expect |_| """ - result = convert(grid) - expected = Ok("6") + result = convert grid + expected = Ok "6" result == expected # Recognizes 7 @@ -174,8 +174,8 @@ expect | """ - result = convert(grid) - expected = Ok("7") + result = convert grid + expected = Ok "7" result == expected # Recognizes 8 @@ -187,8 +187,8 @@ expect |_| """ - result = convert(grid) - expected = Ok("8") + result = convert grid + expected = Ok "8" result == expected # Recognizes 9 @@ -200,8 +200,8 @@ expect _| """ - result = convert(grid) - expected = Ok("9") + result = convert grid + expected = Ok "9" result == expected # Recognizes string of decimal numbers @@ -213,8 +213,8 @@ expect ||_ _| | _||_| ||_| _||_| """ - result = convert(grid) - expected = Ok("1234567890") + result = convert grid + expected = Ok "1234567890" result == expected # Numbers separated by empty lines are recognized. Lines are joined by commas. @@ -234,7 +234,7 @@ expect ||_| _| """ - result = convert(grid) - expected = Ok("123,456,789") + result = convert grid + expected = Ok "123,456,789" result == expected diff --git a/exercises/practice/palindrome-products/palindrome-products-test.roc b/exercises/practice/palindrome-products/palindrome-products-test.roc index b593715d..284ede4d 100644 --- a/exercises/practice/palindrome-products/palindrome-products-test.roc +++ b/exercises/practice/palindrome-products/palindrome-products-test.roc @@ -1,6 +1,6 @@ # These tests are auto-generated with test data from: # https://github.com/exercism/problem-specifications/tree/main/exercises/palindrome-products/canonical-data.json -# File last updated on 2025-01-04 +# File last updated on 2025-07-26 app [main!] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.19.0/Hj-J_zxz7V9YurCSTFcFdu6cQJie4guzsPMUi5kBYUk.tar.br", } @@ -8,188 +8,144 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line!("") + Stdout.line! "" import PalindromeProducts exposing [smallest, largest] -is_eq = |result, expected| +isEq = |result, expected| when (result, expected) is - (Ok({ value, factors }), Ok({ value: expected_value, factors: expected_factors })) -> - value == expected_value and factors == expected_factors + (Ok { value, factors }, Ok { value: expectedValue, factors: expectedFactors }) -> + value == expectedValue and factors == expectedFactors _ -> Bool.false # find the smallest palindrome from single digit factors expect - result = smallest({ min: 1, max: 9 }) - expected = Ok( - { - value: 1, - factors: Set.from_list( - [ - (1, 1), - ], - ), - }, - ) - result |> is_eq(expected) + result = smallest { min: 1, max: 9 } + expected = Ok { + value: 1, + factors: Set.from_list [ + (1, 1), + ], + } + result |> isEq expected # find the largest palindrome from single digit factors expect - result = largest({ min: 1, max: 9 }) - expected = Ok( - { - value: 9, - factors: Set.from_list( - [ - (1, 9), - (3, 3), - ], - ), - }, - ) - result |> is_eq(expected) + result = largest { min: 1, max: 9 } + expected = Ok { + value: 9, + factors: Set.from_list [ + (1, 9), + (3, 3), + ], + } + result |> isEq expected # find the smallest palindrome from double digit factors expect - result = smallest({ min: 10, max: 99 }) - expected = Ok( - { - value: 121, - factors: Set.from_list( - [ - (11, 11), - ], - ), - }, - ) - result |> is_eq(expected) + result = smallest { min: 10, max: 99 } + expected = Ok { + value: 121, + factors: Set.from_list [ + (11, 11), + ], + } + result |> isEq expected # find the largest palindrome from double digit factors expect - result = largest({ min: 10, max: 99 }) - expected = Ok( - { - value: 9009, - factors: Set.from_list( - [ - (91, 99), - ], - ), - }, - ) - result |> is_eq(expected) + result = largest { min: 10, max: 99 } + expected = Ok { + value: 9009, + factors: Set.from_list [ + (91, 99), + ], + } + result |> isEq expected # find the smallest palindrome from triple digit factors expect - result = smallest({ min: 100, max: 999 }) - expected = Ok( - { - value: 10201, - factors: Set.from_list( - [ - (101, 101), - ], - ), - }, - ) - result |> is_eq(expected) + result = smallest { min: 100, max: 999 } + expected = Ok { + value: 10201, + factors: Set.from_list [ + (101, 101), + ], + } + result |> isEq expected # find the largest palindrome from triple digit factors expect - result = largest({ min: 100, max: 999 }) - expected = Ok( - { - value: 906609, - factors: Set.from_list( - [ - (913, 993), - ], - ), - }, - ) - result |> is_eq(expected) + result = largest { min: 100, max: 999 } + expected = Ok { + value: 906609, + factors: Set.from_list [ + (913, 993), + ], + } + result |> isEq expected # find the smallest palindrome from four digit factors expect - result = smallest({ min: 1000, max: 9999 }) - expected = Ok( - { - value: 1002001, - factors: Set.from_list( - [ - (1001, 1001), - ], - ), - }, - ) - result |> is_eq(expected) + result = smallest { min: 1000, max: 9999 } + expected = Ok { + value: 1002001, + factors: Set.from_list [ + (1001, 1001), + ], + } + result |> isEq expected # find the largest palindrome from four digit factors expect - result = largest({ min: 1000, max: 9999 }) - expected = Ok( - { - value: 99000099, - factors: Set.from_list( - [ - (9901, 9999), - ], - ), - }, - ) - result |> is_eq(expected) + result = largest { min: 1000, max: 9999 } + expected = Ok { + value: 99000099, + factors: Set.from_list [ + (9901, 9999), + ], + } + result |> isEq expected # empty result for smallest if no palindrome in the range expect - result = smallest({ min: 1002, max: 1003 }) - expected = Ok( - { - value: 0, - factors: Set.from_list( - [ - ], - ), - }, - ) - result |> is_eq(expected) + result = smallest { min: 1002, max: 1003 } + expected = Ok { + value: 0, + factors: Set.from_list [ + ], + } + result |> isEq expected # empty result for largest if no palindrome in the range expect - result = largest({ min: 15, max: 15 }) - expected = Ok( - { - value: 0, - factors: Set.from_list( - [ - ], - ), - }, - ) - result |> is_eq(expected) + result = largest { min: 15, max: 15 } + expected = Ok { + value: 0, + factors: Set.from_list [ + ], + } + result |> isEq expected # error result for smallest if min is more than max expect - result = smallest({ min: 10000, max: 1 }) + result = smallest { min: 10000, max: 1 } result |> Result.is_err # error result for largest if min is more than max expect - result = largest({ min: 2, max: 1 }) + result = largest { min: 2, max: 1 } result |> Result.is_err # smallest product does not use the smallest factor expect - result = smallest({ min: 3215, max: 4000 }) - expected = Ok( - { - value: 10988901, - factors: Set.from_list( - [ - (3297, 3333), - ], - ), - }, - ) - result |> is_eq(expected) + result = smallest { min: 3215, max: 4000 } + expected = Ok { + value: 10988901, + factors: Set.from_list [ + (3297, 3333), + ], + } + result |> isEq expected diff --git a/exercises/practice/pangram/pangram-test.roc b/exercises/practice/pangram/pangram-test.roc index c29c9f9b..857e27ad 100644 --- a/exercises/practice/pangram/pangram-test.roc +++ b/exercises/practice/pangram/pangram-test.roc @@ -1,6 +1,6 @@ # These tests are auto-generated with test data from: # https://github.com/exercism/problem-specifications/tree/main/exercises/pangram/canonical-data.json -# File last updated on 2025-01-04 +# File last updated on 2025-07-26 app [main!] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.19.0/Hj-J_zxz7V9YurCSTFcFdu6cQJie4guzsPMUi5kBYUk.tar.br", } @@ -8,57 +8,57 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line!("") + Stdout.line! "" import Pangram exposing [is_pangram] # empty sentence expect - result = is_pangram("") + result = is_pangram "" result == Bool.false # perfect lower case expect - result = is_pangram("abcdefghijklmnopqrstuvwxyz") + result = is_pangram "abcdefghijklmnopqrstuvwxyz" result == Bool.true # only lower case expect - result = is_pangram("the quick brown fox jumps over the lazy dog") + result = is_pangram "the quick brown fox jumps over the lazy dog" result == Bool.true # missing the letter 'x' expect - result = is_pangram("a quick movement of the enemy will jeopardize five gunboats") + result = is_pangram "a quick movement of the enemy will jeopardize five gunboats" result == Bool.false # missing the letter 'h' expect - result = is_pangram("five boxing wizards jump quickly at it") + result = is_pangram "five boxing wizards jump quickly at it" result == Bool.false # with underscores expect - result = is_pangram("the_quick_brown_fox_jumps_over_the_lazy_dog") + result = is_pangram "the_quick_brown_fox_jumps_over_the_lazy_dog" result == Bool.true # with numbers expect - result = is_pangram("the 1 quick brown fox jumps over the 2 lazy dogs") + result = is_pangram "the 1 quick brown fox jumps over the 2 lazy dogs" result == Bool.true # missing letters replaced by numbers expect - result = is_pangram("7h3 qu1ck brown fox jumps ov3r 7h3 lazy dog") + result = is_pangram "7h3 qu1ck brown fox jumps ov3r 7h3 lazy dog" result == Bool.false # mixed case and punctuation expect - result = is_pangram("\"Five quacking Zephyrs jolt my wax bed.\"") + result = is_pangram "\"Five quacking Zephyrs jolt my wax bed.\"" result == Bool.true # a-m and A-M are 26 different characters but not a pangram expect - result = is_pangram("abcdefghijklm ABCDEFGHIJKLM") + result = is_pangram "abcdefghijklm ABCDEFGHIJKLM" result == Bool.false diff --git a/exercises/practice/pascals-triangle/pascals-triangle-test.roc b/exercises/practice/pascals-triangle/pascals-triangle-test.roc index 4695a21e..eb18c455 100644 --- a/exercises/practice/pascals-triangle/pascals-triangle-test.roc +++ b/exercises/practice/pascals-triangle/pascals-triangle-test.roc @@ -1,6 +1,6 @@ # These tests are auto-generated with test data from: # https://github.com/exercism/problem-specifications/tree/main/exercises/pascals-triangle/canonical-data.json -# File last updated on 2025-01-04 +# File last updated on 2025-07-26 app [main!] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.19.0/Hj-J_zxz7V9YurCSTFcFdu6cQJie4guzsPMUi5kBYUk.tar.br", } @@ -8,19 +8,19 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line!("") + Stdout.line! "" import PascalsTriangle exposing [pascals_triangle] # zero rows expect - result = pascals_triangle(0) + result = pascals_triangle 0 expected = [] result == expected # single row expect - result = pascals_triangle(1) + result = pascals_triangle 1 expected = [ [1], ] @@ -28,7 +28,7 @@ expect # two rows expect - result = pascals_triangle(2) + result = pascals_triangle 2 expected = [ [1], [1, 1], @@ -37,7 +37,7 @@ expect # three rows expect - result = pascals_triangle(3) + result = pascals_triangle 3 expected = [ [1], [1, 1], @@ -47,7 +47,7 @@ expect # four rows expect - result = pascals_triangle(4) + result = pascals_triangle 4 expected = [ [1], [1, 1], @@ -58,7 +58,7 @@ expect # five rows expect - result = pascals_triangle(5) + result = pascals_triangle 5 expected = [ [1], [1, 1], @@ -70,7 +70,7 @@ expect # six rows expect - result = pascals_triangle(6) + result = pascals_triangle 6 expected = [ [1], [1, 1], @@ -83,7 +83,7 @@ expect # ten rows expect - result = pascals_triangle(10) + result = pascals_triangle 10 expected = [ [1], [1, 1], diff --git a/exercises/practice/perfect-numbers/perfect-numbers-test.roc b/exercises/practice/perfect-numbers/perfect-numbers-test.roc index 9ac8eaa0..7437cd02 100644 --- a/exercises/practice/perfect-numbers/perfect-numbers-test.roc +++ b/exercises/practice/perfect-numbers/perfect-numbers-test.roc @@ -1,6 +1,6 @@ # These tests are auto-generated with test data from: # https://github.com/exercism/problem-specifications/tree/main/exercises/perfect-numbers/canonical-data.json -# File last updated on 2025-01-04 +# File last updated on 2025-07-26 app [main!] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.19.0/Hj-J_zxz7V9YurCSTFcFdu6cQJie4guzsPMUi5kBYUk.tar.br", } @@ -8,7 +8,7 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line!("") + Stdout.line! "" import PerfectNumbers exposing [classify] @@ -18,18 +18,18 @@ import PerfectNumbers exposing [classify] # Smallest perfect number is classified correctly expect - result = classify(6) - result == Ok(Perfect) + result = classify 6 + result == Ok Perfect # Medium perfect number is classified correctly expect - result = classify(28) - result == Ok(Perfect) + result = classify 28 + result == Ok Perfect # Large perfect number is classified correctly expect - result = classify(33550336) - result == Ok(Perfect) + result = classify 33550336 + result == Ok Perfect ## ## Abundant numbers @@ -37,18 +37,18 @@ expect # Smallest abundant number is classified correctly expect - result = classify(12) - result == Ok(Abundant) + result = classify 12 + result == Ok Abundant # Medium abundant number is classified correctly expect - result = classify(30) - result == Ok(Abundant) + result = classify 30 + result == Ok Abundant # Large abundant number is classified correctly expect - result = classify(33550335) - result == Ok(Abundant) + result = classify 33550335 + result == Ok Abundant ## ## Deficient numbers @@ -56,28 +56,28 @@ expect # Smallest prime deficient number is classified correctly expect - result = classify(2) - result == Ok(Deficient) + result = classify 2 + result == Ok Deficient # Smallest non-prime deficient number is classified correctly expect - result = classify(4) - result == Ok(Deficient) + result = classify 4 + result == Ok Deficient # Medium deficient number is classified correctly expect - result = classify(32) - result == Ok(Deficient) + result = classify 32 + result == Ok Deficient # Large deficient number is classified correctly expect - result = classify(33550337) - result == Ok(Deficient) + result = classify 33550337 + result == Ok Deficient # Edge case (no factors other than itself) is classified correctly expect - result = classify(1) - result == Ok(Deficient) + result = classify 1 + result == Ok Deficient ## ## Invalid inputs @@ -85,6 +85,6 @@ expect # Zero is rejected (as it is not a positive integer) expect - result = classify(0) - Result.is_err(result) + result = classify 0 + Result.is_err result diff --git a/exercises/practice/phone-number/phone-number-test.roc b/exercises/practice/phone-number/phone-number-test.roc index adf9a71d..39fe9ee1 100644 --- a/exercises/practice/phone-number/phone-number-test.roc +++ b/exercises/practice/phone-number/phone-number-test.roc @@ -1,6 +1,6 @@ # These tests are auto-generated with test data from: # https://github.com/exercism/problem-specifications/tree/main/exercises/phone-number/canonical-data.json -# File last updated on 2025-01-04 +# File last updated on 2025-07-26 app [main!] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.19.0/Hj-J_zxz7V9YurCSTFcFdu6cQJie4guzsPMUi5kBYUk.tar.br", } @@ -8,102 +8,102 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line!("") + Stdout.line! "" import PhoneNumber exposing [clean] # cleans the number expect - result = clean("(223) 456-7890") - expected = Ok("2234567890") + result = clean "(223) 456-7890" + expected = Ok "2234567890" result == expected # cleans numbers with dots expect - result = clean("223.456.7890") - expected = Ok("2234567890") + result = clean "223.456.7890" + expected = Ok "2234567890" result == expected # cleans numbers with multiple spaces expect - result = clean("223 456 7890 ") - expected = Ok("2234567890") + result = clean "223 456 7890 " + expected = Ok "2234567890" result == expected # invalid when 9 digits expect - result = clean("123456789") + result = clean "123456789" result |> Result.is_err # invalid when 11 digits does not start with a 1 expect - result = clean("22234567890") + result = clean "22234567890" result |> Result.is_err # valid when 11 digits and starting with 1 expect - result = clean("12234567890") - expected = Ok("2234567890") + result = clean "12234567890" + expected = Ok "2234567890" result == expected # valid when 11 digits and starting with 1 even with punctuation expect - result = clean("+1 (223) 456-7890") - expected = Ok("2234567890") + result = clean "+1 (223) 456-7890" + expected = Ok "2234567890" result == expected # invalid when more than 11 digits expect - result = clean("321234567890") + result = clean "321234567890" result |> Result.is_err # invalid with letters expect - result = clean("523-abc-7890") + result = clean "523-abc-7890" result |> Result.is_err # invalid with punctuations expect - result = clean("523-@:!-7890") + result = clean "523-@:!-7890" result |> Result.is_err # invalid if area code starts with 0 expect - result = clean("(023) 456-7890") + result = clean "(023) 456-7890" result |> Result.is_err # invalid if area code starts with 1 expect - result = clean("(123) 456-7890") + result = clean "(123) 456-7890" result |> Result.is_err # invalid if exchange code starts with 0 expect - result = clean("(223) 056-7890") + result = clean "(223) 056-7890" result |> Result.is_err # invalid if exchange code starts with 1 expect - result = clean("(223) 156-7890") + result = clean "(223) 156-7890" result |> Result.is_err # invalid if area code starts with 0 on valid 11-digit number expect - result = clean("1 (023) 456-7890") + result = clean "1 (023) 456-7890" result |> Result.is_err # invalid if area code starts with 1 on valid 11-digit number expect - result = clean("1 (123) 456-7890") + result = clean "1 (123) 456-7890" result |> Result.is_err # invalid if exchange code starts with 0 on valid 11-digit number expect - result = clean("1 (223) 056-7890") + result = clean "1 (223) 056-7890" result |> Result.is_err # invalid if exchange code starts with 1 on valid 11-digit number expect - result = clean("1 (223) 156-7890") + result = clean "1 (223) 156-7890" result |> Result.is_err diff --git a/exercises/practice/pig-latin/pig-latin-test.roc b/exercises/practice/pig-latin/pig-latin-test.roc index 86496c34..222db292 100644 --- a/exercises/practice/pig-latin/pig-latin-test.roc +++ b/exercises/practice/pig-latin/pig-latin-test.roc @@ -1,6 +1,6 @@ # These tests are auto-generated with test data from: # https://github.com/exercism/problem-specifications/tree/main/exercises/pig-latin/canonical-data.json -# File last updated on 2025-01-04 +# File last updated on 2025-07-26 app [main!] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.19.0/Hj-J_zxz7V9YurCSTFcFdu6cQJie4guzsPMUi5kBYUk.tar.br", } @@ -8,7 +8,7 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line!("") + Stdout.line! "" import PigLatin exposing [translate] @@ -18,32 +18,32 @@ import PigLatin exposing [translate] # word beginning with a expect - result = translate("apple") + result = translate "apple" result == "appleay" # word beginning with e expect - result = translate("ear") + result = translate "ear" result == "earay" # word beginning with i expect - result = translate("igloo") + result = translate "igloo" result == "iglooay" # word beginning with o expect - result = translate("object") + result = translate "object" result == "objectay" # word beginning with u expect - result = translate("under") + result = translate "under" result == "underay" # word beginning with a vowel and followed by a qu expect - result = translate("equal") + result = translate "equal" result == "equalay" ## @@ -52,56 +52,61 @@ expect # word beginning with p expect - result = translate("pig") + result = translate "pig" result == "igpay" # word beginning with k expect - result = translate("koala") + result = translate "koala" result == "oalakay" # word beginning with x expect - result = translate("xenon") + result = translate "xenon" result == "enonxay" # word beginning with q without a following u expect - result = translate("qat") + result = translate "qat" result == "atqay" +# word beginning with consonant and vowel containing qu +expect + result = translate "liquid" + result == "iquidlay" + ## ## some letter clusters are treated like a single consonant ## # word beginning with ch expect - result = translate("chair") + result = translate "chair" result == "airchay" # word beginning with qu expect - result = translate("queen") + result = translate "queen" result == "eenquay" # word beginning with qu and a preceding consonant expect - result = translate("square") + result = translate "square" result == "aresquay" # word beginning with th expect - result = translate("therapy") + result = translate "therapy" result == "erapythay" # word beginning with thr expect - result = translate("thrush") + result = translate "thrush" result == "ushthray" # word beginning with sch expect - result = translate("school") + result = translate "school" result == "oolschay" ## @@ -110,12 +115,12 @@ expect # word beginning with yt expect - result = translate("yttria") + result = translate "yttria" result == "yttriaay" # word beginning with xr expect - result = translate("xray") + result = translate "xray" result == "xrayay" ## @@ -124,17 +129,17 @@ expect # y is treated like a consonant at the beginning of a word expect - result = translate("yellow") + result = translate "yellow" result == "ellowyay" # y is treated like a vowel at the end of a consonant cluster expect - result = translate("rhythm") + result = translate "rhythm" result == "ythmrhay" # y as second letter in two letter word expect - result = translate("my") + result = translate "my" result == "ymay" ## @@ -143,6 +148,6 @@ expect # a whole phrase expect - result = translate("quick fast run") + result = translate "quick fast run" result == "ickquay astfay unray" diff --git a/exercises/practice/poker/poker-test.roc b/exercises/practice/poker/poker-test.roc index 624c41bb..83c4c303 100644 --- a/exercises/practice/poker/poker-test.roc +++ b/exercises/practice/poker/poker-test.roc @@ -1,6 +1,6 @@ # These tests are auto-generated with test data from: # https://github.com/exercism/problem-specifications/tree/main/exercises/poker/canonical-data.json -# File last updated on 2025-01-04 +# File last updated on 2025-07-26 app [main!] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.19.0/Hj-J_zxz7V9YurCSTFcFdu6cQJie4guzsPMUi5kBYUk.tar.br", } @@ -8,229 +8,229 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line!("") + Stdout.line! "" import Poker exposing [best_hands] # single hand always wins expect hands = ["4S 5S 7H 8D JC"] - result = best_hands(hands) - result == Ok(["4S 5S 7H 8D JC"]) + result = best_hands hands + result == Ok ["4S 5S 7H 8D JC"] # highest card out of all hands wins expect hands = ["4D 5S 6S 8D 3C", "2S 4C 7S 9H 10H", "3S 4S 5D 6H JH"] - result = best_hands(hands) - result == Ok(["3S 4S 5D 6H JH"]) + result = best_hands hands + result == Ok ["3S 4S 5D 6H JH"] # a tie has multiple winners expect hands = ["4D 5S 6S 8D 3C", "2S 4C 7S 9H 10H", "3S 4S 5D 6H JH", "3H 4H 5C 6C JD"] - result = best_hands(hands) - result == Ok(["3S 4S 5D 6H JH", "3H 4H 5C 6C JD"]) + result = best_hands hands + result == Ok ["3S 4S 5D 6H JH", "3H 4H 5C 6C JD"] # multiple hands with the same high cards, tie compares next highest ranked, down to last card expect hands = ["3S 5H 6S 8D 7H", "2S 5D 6D 8C 7S"] - result = best_hands(hands) - result == Ok(["3S 5H 6S 8D 7H"]) + result = best_hands hands + result == Ok ["3S 5H 6S 8D 7H"] # winning high card hand also has the lowest card expect hands = ["2S 5H 6S 8D 7H", "3S 4D 6D 8C 7S"] - result = best_hands(hands) - result == Ok(["2S 5H 6S 8D 7H"]) + result = best_hands hands + result == Ok ["2S 5H 6S 8D 7H"] # one pair beats high card expect hands = ["4S 5H 6C 8D KH", "2S 4H 6S 4D JH"] - result = best_hands(hands) - result == Ok(["2S 4H 6S 4D JH"]) + result = best_hands hands + result == Ok ["2S 4H 6S 4D JH"] # highest pair wins expect hands = ["4S 2H 6S 2D JH", "2S 4H 6C 4D JD"] - result = best_hands(hands) - result == Ok(["2S 4H 6C 4D JD"]) + result = best_hands hands + result == Ok ["2S 4H 6C 4D JD"] # both hands have the same pair, high card wins expect hands = ["4H 4S AH JC 3D", "4C 4D AS 5D 6C"] - result = best_hands(hands) - result == Ok(["4H 4S AH JC 3D"]) + result = best_hands hands + result == Ok ["4H 4S AH JC 3D"] # two pairs beats one pair expect hands = ["2S 8H 6S 8D JH", "4S 5H 4C 8C 5C"] - result = best_hands(hands) - result == Ok(["4S 5H 4C 8C 5C"]) + result = best_hands hands + result == Ok ["4S 5H 4C 8C 5C"] # both hands have two pairs, highest ranked pair wins expect hands = ["2S 8H 2D 8D 3H", "4S 5H 4C 8S 5D"] - result = best_hands(hands) - result == Ok(["2S 8H 2D 8D 3H"]) + result = best_hands hands + result == Ok ["2S 8H 2D 8D 3H"] # both hands have two pairs, with the same highest ranked pair, tie goes to low pair expect hands = ["2S QS 2C QD JH", "JD QH JS 8D QC"] - result = best_hands(hands) - result == Ok(["JD QH JS 8D QC"]) + result = best_hands hands + result == Ok ["JD QH JS 8D QC"] # both hands have two identically ranked pairs, tie goes to remaining card (kicker) expect hands = ["JD QH JS 8D QC", "JS QS JC 2D QD"] - result = best_hands(hands) - result == Ok(["JD QH JS 8D QC"]) + result = best_hands hands + result == Ok ["JD QH JS 8D QC"] # both hands have two pairs that add to the same value, win goes to highest pair expect hands = ["6S 6H 3S 3H AS", "7H 7S 2H 2S AC"] - result = best_hands(hands) - result == Ok(["7H 7S 2H 2S AC"]) + result = best_hands hands + result == Ok ["7H 7S 2H 2S AC"] # two pairs first ranked by largest pair expect hands = ["5C 2S 5S 4H 4C", "6S 2S 6H 7C 2C"] - result = best_hands(hands) - result == Ok(["6S 2S 6H 7C 2C"]) + result = best_hands hands + result == Ok ["6S 2S 6H 7C 2C"] # three of a kind beats two pair expect hands = ["2S 8H 2H 8D JH", "4S 5H 4C 8S 4H"] - result = best_hands(hands) - result == Ok(["4S 5H 4C 8S 4H"]) + result = best_hands hands + result == Ok ["4S 5H 4C 8S 4H"] # both hands have three of a kind, tie goes to highest ranked triplet expect hands = ["2S 2H 2C 8D JH", "4S AH AS 8C AD"] - result = best_hands(hands) - result == Ok(["4S AH AS 8C AD"]) + result = best_hands hands + result == Ok ["4S AH AS 8C AD"] # with multiple decks, two players can have same three of a kind, ties go to highest remaining cards expect hands = ["5S AH AS 7C AD", "4S AH AS 8C AD"] - result = best_hands(hands) - result == Ok(["4S AH AS 8C AD"]) + result = best_hands hands + result == Ok ["4S AH AS 8C AD"] # a straight beats three of a kind expect hands = ["4S 5H 4C 8D 4H", "3S 4D 2S 6D 5C"] - result = best_hands(hands) - result == Ok(["3S 4D 2S 6D 5C"]) + result = best_hands hands + result == Ok ["3S 4D 2S 6D 5C"] # aces can end a straight (10 J Q K A) expect hands = ["4S 5H 4C 8D 4H", "10D JH QS KD AC"] - result = best_hands(hands) - result == Ok(["10D JH QS KD AC"]) + result = best_hands hands + result == Ok ["10D JH QS KD AC"] # aces can start a straight (A 2 3 4 5) expect hands = ["4S 5H 4C 8D 4H", "4D AH 3S 2D 5C"] - result = best_hands(hands) - result == Ok(["4D AH 3S 2D 5C"]) + result = best_hands hands + result == Ok ["4D AH 3S 2D 5C"] # aces cannot be in the middle of a straight (Q K A 2 3) expect hands = ["2C 3D 7H 5H 2S", "QS KH AC 2D 3S"] - result = best_hands(hands) - result == Ok(["2C 3D 7H 5H 2S"]) + result = best_hands hands + result == Ok ["2C 3D 7H 5H 2S"] # both hands with a straight, tie goes to highest ranked card expect hands = ["4S 6C 7S 8D 5H", "5S 7H 8S 9D 6H"] - result = best_hands(hands) - result == Ok(["5S 7H 8S 9D 6H"]) + result = best_hands hands + result == Ok ["5S 7H 8S 9D 6H"] # even though an ace is usually high, a 5-high straight is the lowest-scoring straight expect hands = ["2H 3C 4D 5D 6H", "4S AH 3S 2D 5H"] - result = best_hands(hands) - result == Ok(["2H 3C 4D 5D 6H"]) + result = best_hands hands + result == Ok ["2H 3C 4D 5D 6H"] # flush beats a straight expect hands = ["4C 6H 7D 8D 5H", "2S 4S 5S 6S 7S"] - result = best_hands(hands) - result == Ok(["2S 4S 5S 6S 7S"]) + result = best_hands hands + result == Ok ["2S 4S 5S 6S 7S"] # both hands have a flush, tie goes to high card, down to the last one if necessary expect hands = ["2H 7H 8H 9H 6H", "3S 5S 6S 7S 8S"] - result = best_hands(hands) - result == Ok(["2H 7H 8H 9H 6H"]) + result = best_hands hands + result == Ok ["2H 7H 8H 9H 6H"] # full house beats a flush expect hands = ["3H 6H 7H 8H 5H", "4S 5H 4C 5D 4H"] - result = best_hands(hands) - result == Ok(["4S 5H 4C 5D 4H"]) + result = best_hands hands + result == Ok ["4S 5H 4C 5D 4H"] # both hands have a full house, tie goes to highest-ranked triplet expect hands = ["4H 4S 4D 9S 9D", "5H 5S 5D 8S 8D"] - result = best_hands(hands) - result == Ok(["5H 5S 5D 8S 8D"]) + result = best_hands hands + result == Ok ["5H 5S 5D 8S 8D"] # with multiple decks, both hands have a full house with the same triplet, tie goes to the pair expect hands = ["5H 5S 5D 9S 9D", "5H 5S 5D 8S 8D"] - result = best_hands(hands) - result == Ok(["5H 5S 5D 9S 9D"]) + result = best_hands hands + result == Ok ["5H 5S 5D 9S 9D"] # four of a kind beats a full house expect hands = ["4S 5H 4D 5D 4H", "3S 3H 2S 3D 3C"] - result = best_hands(hands) - result == Ok(["3S 3H 2S 3D 3C"]) + result = best_hands hands + result == Ok ["3S 3H 2S 3D 3C"] # both hands have four of a kind, tie goes to high quad expect hands = ["2S 2H 2C 8D 2D", "4S 5H 5S 5D 5C"] - result = best_hands(hands) - result == Ok(["4S 5H 5S 5D 5C"]) + result = best_hands hands + result == Ok ["4S 5H 5S 5D 5C"] # with multiple decks, both hands with identical four of a kind, tie determined by kicker expect hands = ["3S 3H 2S 3D 3C", "3S 3H 4S 3D 3C"] - result = best_hands(hands) - result == Ok(["3S 3H 4S 3D 3C"]) + result = best_hands hands + result == Ok ["3S 3H 4S 3D 3C"] # straight flush beats four of a kind expect hands = ["4S 5H 5S 5D 5C", "7S 8S 9S 6S 10S"] - result = best_hands(hands) - result == Ok(["7S 8S 9S 6S 10S"]) + result = best_hands hands + result == Ok ["7S 8S 9S 6S 10S"] # aces can end a straight flush (10 J Q K A) expect hands = ["KC AH AS AD AC", "10C JC QC KC AC"] - result = best_hands(hands) - result == Ok(["10C JC QC KC AC"]) + result = best_hands hands + result == Ok ["10C JC QC KC AC"] # aces can start a straight flush (A 2 3 4 5) expect hands = ["KS AH AS AD AC", "4H AH 3H 2H 5H"] - result = best_hands(hands) - result == Ok(["4H AH 3H 2H 5H"]) + result = best_hands hands + result == Ok ["4H AH 3H 2H 5H"] # aces cannot be in the middle of a straight flush (Q K A 2 3) expect hands = ["2C AC QC 10C KC", "QH KH AH 2H 3H"] - result = best_hands(hands) - result == Ok(["2C AC QC 10C KC"]) + result = best_hands hands + result == Ok ["2C AC QC 10C KC"] # both hands have a straight flush, tie goes to highest-ranked card expect hands = ["4H 6H 7H 8H 5H", "5S 7S 8S 9S 6S"] - result = best_hands(hands) - result == Ok(["5S 7S 8S 9S 6S"]) + result = best_hands hands + result == Ok ["5S 7S 8S 9S 6S"] # even though an ace is usually high, a 5-high straight flush is the lowest-scoring straight flush expect hands = ["2H 3H 4H 5H 6H", "4D AD 3D 2D 5D"] - result = best_hands(hands) - result == Ok(["2H 3H 4H 5H 6H"]) + result = best_hands hands + result == Ok ["2H 3H 4H 5H 6H"] diff --git a/exercises/practice/prime-factors/prime-factors-test.roc b/exercises/practice/prime-factors/prime-factors-test.roc index 80a245aa..51a06cf9 100644 --- a/exercises/practice/prime-factors/prime-factors-test.roc +++ b/exercises/practice/prime-factors/prime-factors-test.roc @@ -1,6 +1,6 @@ # These tests are auto-generated with test data from: # https://github.com/exercism/problem-specifications/tree/main/exercises/prime-factors/canonical-data.json -# File last updated on 2025-01-04 +# File last updated on 2025-07-26 app [main!] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.19.0/Hj-J_zxz7V9YurCSTFcFdu6cQJie4guzsPMUi5kBYUk.tar.br", } @@ -8,67 +8,67 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line!("") + Stdout.line! "" import PrimeFactors exposing [prime_factors] # no factors expect - result = prime_factors(1) + result = prime_factors 1 result == [] # prime number expect - result = prime_factors(2) + result = prime_factors 2 result == [2] # another prime number expect - result = prime_factors(3) + result = prime_factors 3 result == [3] # square of a prime expect - result = prime_factors(9) + result = prime_factors 9 result == [3, 3] # product of first prime expect - result = prime_factors(4) + result = prime_factors 4 result == [2, 2] # cube of a prime expect - result = prime_factors(8) + result = prime_factors 8 result == [2, 2, 2] # product of second prime expect - result = prime_factors(27) + result = prime_factors 27 result == [3, 3, 3] # product of third prime expect - result = prime_factors(625) + result = prime_factors 625 result == [5, 5, 5, 5] # product of first and second prime expect - result = prime_factors(6) + result = prime_factors 6 result == [2, 3] # product of primes and non-primes expect - result = prime_factors(12) + result = prime_factors 12 result == [2, 2, 3] # product of primes expect - result = prime_factors(901255) + result = prime_factors 901255 result == [5, 17, 23, 461] # factors include a large prime expect - result = prime_factors(93819012551) + result = prime_factors 93819012551 result == [11, 9539, 894119] diff --git a/exercises/practice/protein-translation/protein-translation-test.roc b/exercises/practice/protein-translation/protein-translation-test.roc index 3e4d8576..d5162f48 100644 --- a/exercises/practice/protein-translation/protein-translation-test.roc +++ b/exercises/practice/protein-translation/protein-translation-test.roc @@ -1,6 +1,6 @@ # These tests are auto-generated with test data from: # https://github.com/exercism/problem-specifications/tree/main/exercises/protein-translation/canonical-data.json -# File last updated on 2025-01-04 +# File last updated on 2025-07-26 app [main!] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.19.0/Hj-J_zxz7V9YurCSTFcFdu6cQJie4guzsPMUi5kBYUk.tar.br", } @@ -8,7 +8,7 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line!("") + Stdout.line! "" import ProteinTranslation exposing [to_protein] @@ -16,163 +16,163 @@ import ProteinTranslation exposing [to_protein] expect rna = "" result = rna |> to_protein - result == Ok([]) + result == Ok [] # Methionine RNA sequence expect rna = "AUG" result = rna |> to_protein - result == Ok([Methionine]) + result == Ok [Methionine] # Phenylalanine RNA sequence 1 expect rna = "UUU" result = rna |> to_protein - result == Ok([Phenylalanine]) + result == Ok [Phenylalanine] # Phenylalanine RNA sequence 2 expect rna = "UUC" result = rna |> to_protein - result == Ok([Phenylalanine]) + result == Ok [Phenylalanine] # Leucine RNA sequence 1 expect rna = "UUA" result = rna |> to_protein - result == Ok([Leucine]) + result == Ok [Leucine] # Leucine RNA sequence 2 expect rna = "UUG" result = rna |> to_protein - result == Ok([Leucine]) + result == Ok [Leucine] # Serine RNA sequence 1 expect rna = "UCU" result = rna |> to_protein - result == Ok([Serine]) + result == Ok [Serine] # Serine RNA sequence 2 expect rna = "UCC" result = rna |> to_protein - result == Ok([Serine]) + result == Ok [Serine] # Serine RNA sequence 3 expect rna = "UCA" result = rna |> to_protein - result == Ok([Serine]) + result == Ok [Serine] # Serine RNA sequence 4 expect rna = "UCG" result = rna |> to_protein - result == Ok([Serine]) + result == Ok [Serine] # Tyrosine RNA sequence 1 expect rna = "UAU" result = rna |> to_protein - result == Ok([Tyrosine]) + result == Ok [Tyrosine] # Tyrosine RNA sequence 2 expect rna = "UAC" result = rna |> to_protein - result == Ok([Tyrosine]) + result == Ok [Tyrosine] # Cysteine RNA sequence 1 expect rna = "UGU" result = rna |> to_protein - result == Ok([Cysteine]) + result == Ok [Cysteine] # Cysteine RNA sequence 2 expect rna = "UGC" result = rna |> to_protein - result == Ok([Cysteine]) + result == Ok [Cysteine] # Tryptophan RNA sequence expect rna = "UGG" result = rna |> to_protein - result == Ok([Tryptophan]) + result == Ok [Tryptophan] # STOP codon RNA sequence 1 expect rna = "UAA" result = rna |> to_protein - result == Ok([]) + result == Ok [] # STOP codon RNA sequence 2 expect rna = "UAG" result = rna |> to_protein - result == Ok([]) + result == Ok [] # STOP codon RNA sequence 3 expect rna = "UGA" result = rna |> to_protein - result == Ok([]) + result == Ok [] # Sequence of two protein codons translates into proteins expect rna = "UUUUUU" result = rna |> to_protein - result == Ok([Phenylalanine, Phenylalanine]) + result == Ok [Phenylalanine, Phenylalanine] # Sequence of two different protein codons translates into proteins expect rna = "UUAUUG" result = rna |> to_protein - result == Ok([Leucine, Leucine]) + result == Ok [Leucine, Leucine] # Translate RNA strand into correct protein list expect rna = "AUGUUUUGG" result = rna |> to_protein - result == Ok([Methionine, Phenylalanine, Tryptophan]) + result == Ok [Methionine, Phenylalanine, Tryptophan] # Translation stops if STOP codon at beginning of sequence expect rna = "UAGUGG" result = rna |> to_protein - result == Ok([]) + result == Ok [] # Translation stops if STOP codon at end of two-codon sequence expect rna = "UGGUAG" result = rna |> to_protein - result == Ok([Tryptophan]) + result == Ok [Tryptophan] # Translation stops if STOP codon at end of three-codon sequence expect rna = "AUGUUUUAA" result = rna |> to_protein - result == Ok([Methionine, Phenylalanine]) + result == Ok [Methionine, Phenylalanine] # Translation stops if STOP codon in middle of three-codon sequence expect rna = "UGGUAGUGG" result = rna |> to_protein - result == Ok([Tryptophan]) + result == Ok [Tryptophan] # Translation stops if STOP codon in middle of six-codon sequence expect rna = "UGGUGUUAUUAAUGGUUU" result = rna |> to_protein - result == Ok([Tryptophan, Cysteine, Tyrosine]) + result == Ok [Tryptophan, Cysteine, Tyrosine] # Sequence of two non-STOP codons does not translate to a STOP codon expect rna = "AUGAUG" result = rna |> to_protein - result == Ok([Methionine, Methionine]) + result == Ok [Methionine, Methionine] # Unknown amino acids, not part of a codon, can't translate expect @@ -190,5 +190,5 @@ expect expect rna = "UUCUUCUAAUGGU" result = rna |> to_protein - result == Ok([Phenylalanine, Phenylalanine]) + result == Ok [Phenylalanine, Phenylalanine] diff --git a/exercises/practice/proverb/proverb-test.roc b/exercises/practice/proverb/proverb-test.roc index c0f454eb..13619ad8 100644 --- a/exercises/practice/proverb/proverb-test.roc +++ b/exercises/practice/proverb/proverb-test.roc @@ -1,6 +1,6 @@ # These tests are auto-generated with test data from: # https://github.com/exercism/problem-specifications/tree/main/exercises/proverb/canonical-data.json -# File last updated on 2025-01-04 +# File last updated on 2025-07-26 app [main!] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.19.0/Hj-J_zxz7V9YurCSTFcFdu6cQJie4guzsPMUi5kBYUk.tar.br", } @@ -8,25 +8,25 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line!("") + Stdout.line! "" import Proverb exposing [recite] # zero pieces expect - result = recite([]) + result = recite [] expected = "" result == expected # one piece expect - result = recite(["nail"]) + result = recite ["nail"] expected = "And all for the want of a nail." result == expected # two pieces expect - result = recite(["nail", "shoe"]) + result = recite ["nail", "shoe"] expected = """ For want of a nail the shoe was lost. @@ -36,7 +36,7 @@ expect # three pieces expect - result = recite(["nail", "shoe", "horse"]) + result = recite ["nail", "shoe", "horse"] expected = """ For want of a nail the shoe was lost. @@ -47,7 +47,7 @@ expect # full proverb expect - result = recite(["nail", "shoe", "horse", "rider", "message", "battle", "kingdom"]) + result = recite ["nail", "shoe", "horse", "rider", "message", "battle", "kingdom"] expected = """ For want of a nail the shoe was lost. @@ -62,7 +62,7 @@ expect # four pieces modernized expect - result = recite(["pin", "gun", "soldier", "battle"]) + result = recite ["pin", "gun", "soldier", "battle"] expected = """ For want of a pin the gun was lost. diff --git a/exercises/practice/pythagorean-triplet/pythagorean-triplet-test.roc b/exercises/practice/pythagorean-triplet/pythagorean-triplet-test.roc index 5731e48c..4efbb485 100644 --- a/exercises/practice/pythagorean-triplet/pythagorean-triplet-test.roc +++ b/exercises/practice/pythagorean-triplet/pythagorean-triplet-test.roc @@ -1,6 +1,6 @@ # These tests are auto-generated with test data from: # https://github.com/exercism/problem-specifications/tree/main/exercises/pythagorean-triplet/canonical-data.json -# File last updated on 2025-01-04 +# File last updated on 2025-07-26 app [main!] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.19.0/Hj-J_zxz7V9YurCSTFcFdu6cQJie4guzsPMUi5kBYUk.tar.br", } @@ -8,85 +8,73 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line!("") + Stdout.line! "" import PythagoreanTriplet exposing [triplets_with_sum] # triplets whose sum is 12 expect - result = triplets_with_sum(12) - expected = Set.from_list( - [ - (3, 4, 5), - ], - ) + result = triplets_with_sum 12 + expected = Set.from_list [ + (3, 4, 5), + ] result == expected # triplets whose sum is 108 expect - result = triplets_with_sum(108) - expected = Set.from_list( - [ - (27, 36, 45), - ], - ) + result = triplets_with_sum 108 + expected = Set.from_list [ + (27, 36, 45), + ] result == expected # triplets whose sum is 1000 expect - result = triplets_with_sum(1000) - expected = Set.from_list( - [ - (200, 375, 425), - ], - ) + result = triplets_with_sum 1000 + expected = Set.from_list [ + (200, 375, 425), + ] result == expected # no matching triplets for 1001 expect - result = triplets_with_sum(1001) - expected = Set.from_list([]) + result = triplets_with_sum 1001 + expected = Set.from_list [] result == expected # returns all matching triplets expect - result = triplets_with_sum(90) - expected = Set.from_list( - [ - (9, 40, 41), - (15, 36, 39), - ], - ) + result = triplets_with_sum 90 + expected = Set.from_list [ + (9, 40, 41), + (15, 36, 39), + ] result == expected # several matching triplets expect - result = triplets_with_sum(840) - expected = Set.from_list( - [ - (40, 399, 401), - (56, 390, 394), - (105, 360, 375), - (120, 350, 370), - (140, 336, 364), - (168, 315, 357), - (210, 280, 350), - (240, 252, 348), - ], - ) + result = triplets_with_sum 840 + expected = Set.from_list [ + (40, 399, 401), + (56, 390, 394), + (105, 360, 375), + (120, 350, 370), + (140, 336, 364), + (168, 315, 357), + (210, 280, 350), + (240, 252, 348), + ] result == expected # triplets for large number expect - result = triplets_with_sum(30000) - expected = Set.from_list( - [ - (1200, 14375, 14425), - (1875, 14000, 14125), - (5000, 12000, 13000), - (6000, 11250, 12750), - (7500, 10000, 12500), - ], - ) + result = triplets_with_sum 30000 + expected = Set.from_list [ + (1200, 14375, 14425), + (1875, 14000, 14125), + (5000, 12000, 13000), + (6000, 11250, 12750), + (7500, 10000, 12500), + ] result == expected diff --git a/exercises/practice/queen-attack/queen-attack-test.roc b/exercises/practice/queen-attack/queen-attack-test.roc index 250636f2..dfe18b29 100644 --- a/exercises/practice/queen-attack/queen-attack-test.roc +++ b/exercises/practice/queen-attack/queen-attack-test.roc @@ -1,6 +1,6 @@ # These tests are auto-generated with test data from: # https://github.com/exercism/problem-specifications/tree/main/exercises/queen-attack/canonical-data.json -# File last updated on 2025-01-04 +# File last updated on 2025-07-26 app [main!] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.19.0/Hj-J_zxz7V9YurCSTFcFdu6cQJie4guzsPMUi5kBYUk.tar.br", } @@ -8,7 +8,7 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line!("") + Stdout.line! "" import QueenAttack exposing [create, rank, file, queen_can_attack] @@ -18,33 +18,29 @@ import QueenAttack exposing [create, rank, file, queen_can_attack] # queen with a valid position expect - maybe_square = create("C6") + maybeSquare = create "C6" result = - maybe_square - |> Result.try( - |square| - Ok(rank(square)), - ) - result == Ok(6) + maybeSquare + |> Result.try |square| + Ok (rank square) + result == Ok 6 expect - maybe_square = create("C6") + maybeSquare = create "C6" result = - maybe_square - |> Result.try( - |square| - Ok(file(square)), - ) - result == Ok('C') + maybeSquare + |> Result.try |square| + Ok (file square) + result == Ok 'C' # queen must have row on board expect - result = create("E0") + result = create "E0" result |> Result.is_err # queen must have column on board expect - result = create("I4") + result = create "I4" result |> Result.is_err ## @@ -53,97 +49,97 @@ expect # cannot attack expect - maybe_square1 = create("E6") - maybe_square2 = create("G2") + maybeSquare1 = create "E6" + maybeSquare2 = create "G2" result = - when (maybe_square1, maybe_square2) is - (Ok(square1), Ok(square2)) -> - square1 |> queen_can_attack(square2) + when (maybeSquare1, maybeSquare2) is + (Ok square1, Ok square2) -> + square1 |> queen_can_attack square2 - _ -> crash("Unreachable: E6 and G2 are both valid squares") + _ -> crash "Unreachable: E6 and G2 are both valid squares" result == Bool.false # can attack on same row expect - maybe_square1 = create("E6") - maybe_square2 = create("G6") + maybeSquare1 = create "E6" + maybeSquare2 = create "G6" result = - when (maybe_square1, maybe_square2) is - (Ok(square1), Ok(square2)) -> - square1 |> queen_can_attack(square2) + when (maybeSquare1, maybeSquare2) is + (Ok square1, Ok square2) -> + square1 |> queen_can_attack square2 - _ -> crash("Unreachable: E6 and G6 are both valid squares") + _ -> crash "Unreachable: E6 and G6 are both valid squares" result == Bool.true # can attack on same column expect - maybe_square1 = create("F4") - maybe_square2 = create("F6") + maybeSquare1 = create "F4" + maybeSquare2 = create "F6" result = - when (maybe_square1, maybe_square2) is - (Ok(square1), Ok(square2)) -> - square1 |> queen_can_attack(square2) + when (maybeSquare1, maybeSquare2) is + (Ok square1, Ok square2) -> + square1 |> queen_can_attack square2 - _ -> crash("Unreachable: F4 and F6 are both valid squares") + _ -> crash "Unreachable: F4 and F6 are both valid squares" result == Bool.true # can attack on first diagonal expect - maybe_square1 = create("C6") - maybe_square2 = create("E8") + maybeSquare1 = create "C6" + maybeSquare2 = create "E8" result = - when (maybe_square1, maybe_square2) is - (Ok(square1), Ok(square2)) -> - square1 |> queen_can_attack(square2) + when (maybeSquare1, maybeSquare2) is + (Ok square1, Ok square2) -> + square1 |> queen_can_attack square2 - _ -> crash("Unreachable: C6 and E8 are both valid squares") + _ -> crash "Unreachable: C6 and E8 are both valid squares" result == Bool.true # can attack on second diagonal expect - maybe_square1 = create("C6") - maybe_square2 = create("B5") + maybeSquare1 = create "C6" + maybeSquare2 = create "B5" result = - when (maybe_square1, maybe_square2) is - (Ok(square1), Ok(square2)) -> - square1 |> queen_can_attack(square2) + when (maybeSquare1, maybeSquare2) is + (Ok square1, Ok square2) -> + square1 |> queen_can_attack square2 - _ -> crash("Unreachable: C6 and B5 are both valid squares") + _ -> crash "Unreachable: C6 and B5 are both valid squares" result == Bool.true # can attack on third diagonal expect - maybe_square1 = create("C6") - maybe_square2 = create("B7") + maybeSquare1 = create "C6" + maybeSquare2 = create "B7" result = - when (maybe_square1, maybe_square2) is - (Ok(square1), Ok(square2)) -> - square1 |> queen_can_attack(square2) + when (maybeSquare1, maybeSquare2) is + (Ok square1, Ok square2) -> + square1 |> queen_can_attack square2 - _ -> crash("Unreachable: C6 and B7 are both valid squares") + _ -> crash "Unreachable: C6 and B7 are both valid squares" result == Bool.true # can attack on fourth diagonal expect - maybe_square1 = create("H7") - maybe_square2 = create("G8") + maybeSquare1 = create "H7" + maybeSquare2 = create "G8" result = - when (maybe_square1, maybe_square2) is - (Ok(square1), Ok(square2)) -> - square1 |> queen_can_attack(square2) + when (maybeSquare1, maybeSquare2) is + (Ok square1, Ok square2) -> + square1 |> queen_can_attack square2 - _ -> crash("Unreachable: H7 and G8 are both valid squares") + _ -> crash "Unreachable: H7 and G8 are both valid squares" result == Bool.true # cannot attack if falling diagonals are only the same when reflected across the longest falling diagonal expect - maybe_square1 = create("B4") - maybe_square2 = create("F6") + maybeSquare1 = create "B4" + maybeSquare2 = create "F6" result = - when (maybe_square1, maybe_square2) is - (Ok(square1), Ok(square2)) -> - square1 |> queen_can_attack(square2) + when (maybeSquare1, maybeSquare2) is + (Ok square1, Ok square2) -> + square1 |> queen_can_attack square2 - _ -> crash("Unreachable: B4 and F6 are both valid squares") + _ -> crash "Unreachable: B4 and F6 are both valid squares" result == Bool.false diff --git a/exercises/practice/rail-fence-cipher/rail-fence-cipher-test.roc b/exercises/practice/rail-fence-cipher/rail-fence-cipher-test.roc index 98d50090..397248ab 100644 --- a/exercises/practice/rail-fence-cipher/rail-fence-cipher-test.roc +++ b/exercises/practice/rail-fence-cipher/rail-fence-cipher-test.roc @@ -1,6 +1,6 @@ # These tests are auto-generated with test data from: # https://github.com/exercism/problem-specifications/tree/main/exercises/rail-fence-cipher/canonical-data.json -# File last updated on 2025-01-04 +# File last updated on 2025-07-26 app [main!] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.19.0/Hj-J_zxz7V9YurCSTFcFdu6cQJie4guzsPMUi5kBYUk.tar.br", } @@ -8,7 +8,7 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line!("") + Stdout.line! "" import RailFenceCipher exposing [encode, decode] @@ -19,22 +19,22 @@ import RailFenceCipher exposing [encode, decode] # encode with two rails expect message = "XOXOXOXOXOXOXOXOXO" - result = message |> encode(2) - expected = Ok("XXXXXXXXXOOOOOOOOO") + result = message |> encode 2 + expected = Ok "XXXXXXXXXOOOOOOOOO" result == expected # encode with three rails expect message = "WEAREDISCOVEREDFLEEATONCE" - result = message |> encode(3) - expected = Ok("WECRLTEERDSOEEFEAOCAIVDEN") + result = message |> encode 3 + expected = Ok "WECRLTEERDSOEEFEAOCAIVDEN" result == expected # encode with ending in the middle expect message = "EXERCISES" - result = message |> encode(4) - expected = Ok("ESXIEECSR") + result = message |> encode 4 + expected = Ok "ESXIEECSR" result == expected ## @@ -44,21 +44,21 @@ expect # decode with three rails expect message = "TEITELHDVLSNHDTISEIIEA" - result = message |> decode(3) - expected = Ok("THEDEVILISINTHEDETAILS") + result = message |> decode 3 + expected = Ok "THEDEVILISINTHEDETAILS" result == expected # decode with five rails expect message = "EIEXMSMESAORIWSCE" - result = message |> decode(5) - expected = Ok("EXERCISMISAWESOME") + result = message |> decode 5 + expected = Ok "EXERCISMISAWESOME" result == expected # decode with six rails expect message = "133714114238148966225439541018335470986172518171757571896261" - result = message |> decode(6) - expected = Ok("112358132134558914423337761098715972584418167651094617711286") + result = message |> decode 6 + expected = Ok "112358132134558914423337761098715972584418167651094617711286" result == expected diff --git a/exercises/practice/raindrops/raindrops-test.roc b/exercises/practice/raindrops/raindrops-test.roc index 851eaef6..bc5c2d6c 100644 --- a/exercises/practice/raindrops/raindrops-test.roc +++ b/exercises/practice/raindrops/raindrops-test.roc @@ -1,6 +1,6 @@ # These tests are auto-generated with test data from: # https://github.com/exercism/problem-specifications/tree/main/exercises/raindrops/canonical-data.json -# File last updated on 2025-01-04 +# File last updated on 2025-07-26 app [main!] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.19.0/Hj-J_zxz7V9YurCSTFcFdu6cQJie4guzsPMUi5kBYUk.tar.br", } @@ -8,97 +8,97 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line!("") + Stdout.line! "" import Raindrops exposing [convert] # the sound for 1 is 1 expect - result = convert(1) + result = convert 1 result == "1" # the sound for 3 is Pling expect - result = convert(3) + result = convert 3 result == "Pling" # the sound for 5 is Plang expect - result = convert(5) + result = convert 5 result == "Plang" # the sound for 7 is Plong expect - result = convert(7) + result = convert 7 result == "Plong" # the sound for 6 is Pling as it has a factor 3 expect - result = convert(6) + result = convert 6 result == "Pling" # 2 to the power 3 does not make a raindrop sound as 3 is the exponent not the base expect - result = convert(8) + result = convert 8 result == "8" # the sound for 9 is Pling as it has a factor 3 expect - result = convert(9) + result = convert 9 result == "Pling" # the sound for 10 is Plang as it has a factor 5 expect - result = convert(10) + result = convert 10 result == "Plang" # the sound for 14 is Plong as it has a factor of 7 expect - result = convert(14) + result = convert 14 result == "Plong" # the sound for 15 is PlingPlang as it has factors 3 and 5 expect - result = convert(15) + result = convert 15 result == "PlingPlang" # the sound for 21 is PlingPlong as it has factors 3 and 7 expect - result = convert(21) + result = convert 21 result == "PlingPlong" # the sound for 25 is Plang as it has a factor 5 expect - result = convert(25) + result = convert 25 result == "Plang" # the sound for 27 is Pling as it has a factor 3 expect - result = convert(27) + result = convert 27 result == "Pling" # the sound for 35 is PlangPlong as it has factors 5 and 7 expect - result = convert(35) + result = convert 35 result == "PlangPlong" # the sound for 49 is Plong as it has a factor 7 expect - result = convert(49) + result = convert 49 result == "Plong" # the sound for 52 is 52 expect - result = convert(52) + result = convert 52 result == "52" # the sound for 105 is PlingPlangPlong as it has factors 3, 5 and 7 expect - result = convert(105) + result = convert 105 result == "PlingPlangPlong" # the sound for 3125 is Plang as it has a factor 5 expect - result = convert(3125) + result = convert 3125 result == "Plang" diff --git a/exercises/practice/rational-numbers/rational-numbers-test.roc b/exercises/practice/rational-numbers/rational-numbers-test.roc index 3eb5b5c7..c3b8571d 100644 --- a/exercises/practice/rational-numbers/rational-numbers-test.roc +++ b/exercises/practice/rational-numbers/rational-numbers-test.roc @@ -1,6 +1,6 @@ # These tests are auto-generated with test data from: # https://github.com/exercism/problem-specifications/tree/main/exercises/rational-numbers/canonical-data.json -# File last updated on 2025-01-04 +# File last updated on 2025-07-26 app [main!] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.19.0/Hj-J_zxz7V9YurCSTFcFdu6cQJie4guzsPMUi5kBYUk.tar.br", } @@ -8,7 +8,7 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line!("") + Stdout.line! "" import RationalNumbers exposing [add, sub, mul, div, abs, exp, exp_real, reduce] @@ -18,93 +18,93 @@ import RationalNumbers exposing [add, sub, mul, div, abs, exp, exp_real, reduce] # Add two positive rational numbers expect - result = Rational(1, 2) |> add(Rational(2, 3)) - result == Rational(7, 6) + result = Rational 1 2 |> add (Rational 2 3) + result == Rational 7 6 # Add a positive rational number and a negative rational number expect - result = Rational(1, 2) |> add(Rational(-2, 3)) - result == Rational(-1, 6) + result = Rational 1 2 |> add (Rational -2 3) + result == Rational -1 6 # Add two negative rational numbers expect - result = Rational(-1, 2) |> add(Rational(-2, 3)) - result == Rational(-7, 6) + result = Rational -1 2 |> add (Rational -2 3) + result == Rational -7 6 # Add a rational number to its additive inverse expect - result = Rational(1, 2) |> add(Rational(-1, 2)) - result == Rational(0, 1) + result = Rational 1 2 |> add (Rational -1 2) + result == Rational 0 1 # Subtract two positive rational numbers expect - result = Rational(1, 2) |> sub(Rational(2, 3)) - result == Rational(-1, 6) + result = Rational 1 2 |> sub (Rational 2 3) + result == Rational -1 6 # Subtract a positive rational number and a negative rational number expect - result = Rational(1, 2) |> sub(Rational(-2, 3)) - result == Rational(7, 6) + result = Rational 1 2 |> sub (Rational -2 3) + result == Rational 7 6 # Subtract two negative rational numbers expect - result = Rational(-1, 2) |> sub(Rational(-2, 3)) - result == Rational(1, 6) + result = Rational -1 2 |> sub (Rational -2 3) + result == Rational 1 6 # Subtract a rational number from itself expect - result = Rational(1, 2) |> sub(Rational(1, 2)) - result == Rational(0, 1) + result = Rational 1 2 |> sub (Rational 1 2) + result == Rational 0 1 # Multiply two positive rational numbers expect - result = Rational(1, 2) |> mul(Rational(2, 3)) - result == Rational(1, 3) + result = Rational 1 2 |> mul (Rational 2 3) + result == Rational 1 3 # Multiply a negative rational number by a positive rational number expect - result = Rational(-1, 2) |> mul(Rational(2, 3)) - result == Rational(-1, 3) + result = Rational -1 2 |> mul (Rational 2 3) + result == Rational -1 3 # Multiply two negative rational numbers expect - result = Rational(-1, 2) |> mul(Rational(-2, 3)) - result == Rational(1, 3) + result = Rational -1 2 |> mul (Rational -2 3) + result == Rational 1 3 # Multiply a rational number by its reciprocal expect - result = Rational(1, 2) |> mul(Rational(2, 1)) - result == Rational(1, 1) + result = Rational 1 2 |> mul (Rational 2 1) + result == Rational 1 1 # Multiply a rational number by 1 expect - result = Rational(1, 2) |> mul(Rational(1, 1)) - result == Rational(1, 2) + result = Rational 1 2 |> mul (Rational 1 1) + result == Rational 1 2 # Multiply a rational number by 0 expect - result = Rational(1, 2) |> mul(Rational(0, 1)) - result == Rational(0, 1) + result = Rational 1 2 |> mul (Rational 0 1) + result == Rational 0 1 # Divide two positive rational numbers expect - result = Rational(1, 2) |> div(Rational(2, 3)) - result == Rational(3, 4) + result = Rational 1 2 |> div (Rational 2 3) + result == Rational 3 4 # Divide a positive rational number by a negative rational number expect - result = Rational(1, 2) |> div(Rational(-2, 3)) - result == Rational(-3, 4) + result = Rational 1 2 |> div (Rational -2 3) + result == Rational -3 4 # Divide two negative rational numbers expect - result = Rational(-1, 2) |> div(Rational(-2, 3)) - result == Rational(3, 4) + result = Rational -1 2 |> div (Rational -2 3) + result == Rational 3 4 # Divide a rational number by 1 expect - result = Rational(1, 2) |> div(Rational(1, 1)) - result == Rational(1, 2) + result = Rational 1 2 |> div (Rational 1 1) + result == Rational 1 2 ## ## Absolute value @@ -112,33 +112,33 @@ expect # Absolute value of a positive rational number expect - result = Rational(1, 2) |> abs - result == Rational(1, 2) + result = Rational 1 2 |> abs + result == Rational 1 2 # Absolute value of a positive rational number with negative numerator and denominator expect - result = Rational(-1, -2) |> abs - result == Rational(1, 2) + result = Rational -1 -2 |> abs + result == Rational 1 2 # Absolute value of a negative rational number expect - result = Rational(-1, 2) |> abs - result == Rational(1, 2) + result = Rational -1 2 |> abs + result == Rational 1 2 # Absolute value of a negative rational number with negative denominator expect - result = Rational(1, -2) |> abs - result == Rational(1, 2) + result = Rational 1 -2 |> abs + result == Rational 1 2 # Absolute value of zero expect - result = Rational(0, 1) |> abs - result == Rational(0, 1) + result = Rational 0 1 |> abs + result == Rational 0 1 # Absolute value of a rational number is reduced to lowest terms expect - result = Rational(2, 4) |> abs - result == Rational(1, 2) + result = Rational 2 4 |> abs + result == Rational 1 2 ## ## Exponentiation of a rational number @@ -146,48 +146,48 @@ expect # Raise a positive rational number to a positive integer power expect - result = Rational(1, 2) |> exp(3) - result == Rational(1, 8) + result = Rational 1 2 |> exp 3 + result == Rational 1 8 # Raise a negative rational number to a positive integer power expect - result = Rational(-1, 2) |> exp(3) - result == Rational(-1, 8) + result = Rational -1 2 |> exp 3 + result == Rational -1 8 # Raise a positive rational number to a negative integer power expect - result = Rational(3, 5) |> exp(-2) - result == Rational(25, 9) + result = Rational 3 5 |> exp -2 + result == Rational 25 9 # Raise a negative rational number to an even negative integer power expect - result = Rational(-3, 5) |> exp(-2) - result == Rational(25, 9) + result = Rational -3 5 |> exp -2 + result == Rational 25 9 # Raise a negative rational number to an odd negative integer power expect - result = Rational(-3, 5) |> exp(-3) - result == Rational(-125, 27) + result = Rational -3 5 |> exp -3 + result == Rational -125 27 # Raise zero to an integer power expect - result = Rational(0, 1) |> exp(5) - result == Rational(0, 1) + result = Rational 0 1 |> exp 5 + result == Rational 0 1 # Raise one to an integer power expect - result = Rational(1, 1) |> exp(4) - result == Rational(1, 1) + result = Rational 1 1 |> exp 4 + result == Rational 1 1 # Raise a positive rational number to the power of zero expect - result = Rational(1, 2) |> exp(0) - result == Rational(1, 1) + result = Rational 1 2 |> exp 0 + result == Rational 1 1 # Raise a negative rational number to the power of zero expect - result = Rational(-1, 2) |> exp(0) - result == Rational(1, 1) + result = Rational -1 2 |> exp 0 + result == Rational 1 1 ## ## Exponentiation of a real number to a rational number @@ -195,18 +195,18 @@ expect # Raise a real number to a positive rational number expect - result = 8 |> exp_real(Rational(4, 3)) - result |> Num.is_approx_eq(16.0f64, {}) + result = 8 |> exp_real (Rational 4 3) + result |> Num.is_approx_eq 16.0f64 {} # Raise a real number to a negative rational number expect - result = 9 |> exp_real(Rational(-1, 2)) - result |> Num.is_approx_eq(0.3333333333333333f64, {}) + result = 9 |> exp_real (Rational -1 2) + result |> Num.is_approx_eq 0.3333333333333333f64 {} # Raise a real number to a zero rational number expect - result = 2 |> exp_real(Rational(0, 1)) - result |> Num.is_approx_eq(1.0f64, {}) + result = 2 |> exp_real (Rational 0 1) + result |> Num.is_approx_eq 1.0f64 {} ## ## Reduction to lowest terms @@ -214,36 +214,36 @@ expect # Reduce a positive rational number to lowest terms expect - result = Rational(2, 4) |> reduce - result == Rational(1, 2) + result = Rational 2 4 |> reduce + result == Rational 1 2 # Reduce places the minus sign on the numerator expect - result = Rational(3, -4) |> reduce - result == Rational(-3, 4) + result = Rational 3 -4 |> reduce + result == Rational -3 4 # Reduce a negative rational number to lowest terms expect - result = Rational(-4, 6) |> reduce - result == Rational(-2, 3) + result = Rational -4 6 |> reduce + result == Rational -2 3 # Reduce a rational number with a negative denominator to lowest terms expect - result = Rational(3, -9) |> reduce - result == Rational(-1, 3) + result = Rational 3 -9 |> reduce + result == Rational -1 3 # Reduce zero to lowest terms expect - result = Rational(0, 6) |> reduce - result == Rational(0, 1) + result = Rational 0 6 |> reduce + result == Rational 0 1 # Reduce an integer to lowest terms expect - result = Rational(-14, 7) |> reduce - result == Rational(-2, 1) + result = Rational -14 7 |> reduce + result == Rational -2 1 # Reduce one to lowest terms expect - result = Rational(13, 13) |> reduce - result == Rational(1, 1) + result = Rational 13 13 |> reduce + result == Rational 1 1 diff --git a/exercises/practice/rectangles/rectangles-test.roc b/exercises/practice/rectangles/rectangles-test.roc index 946323ce..22c7a3de 100644 --- a/exercises/practice/rectangles/rectangles-test.roc +++ b/exercises/practice/rectangles/rectangles-test.roc @@ -1,6 +1,6 @@ # These tests are auto-generated with test data from: # https://github.com/exercism/problem-specifications/tree/main/exercises/rectangles/canonical-data.json -# File last updated on 2025-01-04 +# File last updated on 2025-07-26 app [main!] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.19.0/Hj-J_zxz7V9YurCSTFcFdu6cQJie4guzsPMUi5kBYUk.tar.br", } @@ -8,135 +8,126 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line!("") + Stdout.line! "" import Rectangles exposing [rectangles] # no rows expect - result = rectangles("") + result = rectangles "" result == 0 # no columns expect - result = rectangles("") + result = rectangles "" result == 0 # no rectangles expect - result = rectangles(" ") + result = rectangles " " result == 0 # one rectangle expect - result = rectangles( + result = rectangles """ +-+ | | +-+ - """, - ) + """ result == 1 # two rectangles without shared parts expect - result = rectangles( + result = rectangles """ +-+ | | +-+-+ | | +-+ - """, - ) + """ result == 2 # five rectangles with shared parts expect - result = rectangles( + result = rectangles """ +-+ | | +-+-+ | | | +-+-+ - """, - ) + """ result == 5 # rectangle of height 1 is counted expect - result = rectangles( + result = rectangles """ +--+ +--+ - """, - ) + """ result == 1 # rectangle of width 1 is counted expect - result = rectangles( + result = rectangles """ ++ || ++ - """, - ) + """ result == 1 # 1x1 square is counted expect - result = rectangles( + result = rectangles """ ++ ++ - """, - ) + """ result == 1 # only complete rectangles are counted expect - result = rectangles( + result = rectangles """ +-+ | +-+-+ | | - +-+-+ - """, - ) + """ result == 1 # rectangles can be of different sizes expect - result = rectangles( + result = rectangles """ +------+----+ | | | +---+--+ | | | | +---+-------+ - """, - ) + """ result == 3 # corner is required for a rectangle to be complete expect - result = rectangles( + result = rectangles """ +------+----+ | | | +------+ | | | | +---+-------+ - """, - ) + """ result == 2 # large input with many rectangles expect - result = rectangles( + result = rectangles """ +---+--+----+ | +--+----+ @@ -146,13 +137,12 @@ expect +---+--+--+-+ +------+ | | +-+ - """, - ) + """ result == 60 # rectangles must have four sides expect - result = rectangles( + result = rectangles """ +-+ +-+ | | | | @@ -161,7 +151,6 @@ expect +-+-+-+ | | | | +-+ +-+ - """, - ) + """ result == 5 diff --git a/exercises/practice/resistor-color-duo/resistor-color-duo-test.roc b/exercises/practice/resistor-color-duo/resistor-color-duo-test.roc index 85b25000..8402f1b6 100644 --- a/exercises/practice/resistor-color-duo/resistor-color-duo-test.roc +++ b/exercises/practice/resistor-color-duo/resistor-color-duo-test.roc @@ -1,6 +1,6 @@ # These tests are auto-generated with test data from: # https://github.com/exercism/problem-specifications/tree/main/exercises/resistor-color-duo/canonical-data.json -# File last updated on 2025-01-04 +# File last updated on 2025-07-26 app [main!] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.19.0/Hj-J_zxz7V9YurCSTFcFdu6cQJie4guzsPMUi5kBYUk.tar.br", } @@ -8,37 +8,37 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line!("") + Stdout.line! "" import ResistorColorDuo exposing [value] # Brown and black expect - result = value(Brown, Black) + result = value Brown Black result == 10 # Blue and grey expect - result = value(Blue, Grey) + result = value Blue Grey result == 68 # Yellow and violet expect - result = value(Yellow, Violet) + result = value Yellow Violet result == 47 # White and red expect - result = value(White, Red) + result = value White Red result == 92 # Orange and orange expect - result = value(Orange, Orange) + result = value Orange Orange result == 33 # Black and brown, one-digit expect - result = value(Black, Brown) + result = value Black Brown result == 1 diff --git a/exercises/practice/resistor-color/resistor-color-test.roc b/exercises/practice/resistor-color/resistor-color-test.roc index a5f4d511..255774ca 100644 --- a/exercises/practice/resistor-color/resistor-color-test.roc +++ b/exercises/practice/resistor-color/resistor-color-test.roc @@ -1,6 +1,6 @@ # These tests are auto-generated with test data from: # https://github.com/exercism/problem-specifications/tree/main/exercises/resistor-color/canonical-data.json -# File last updated on 2025-01-04 +# File last updated on 2025-07-26 app [main!] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.19.0/Hj-J_zxz7V9YurCSTFcFdu6cQJie4guzsPMUi5kBYUk.tar.br", } @@ -8,7 +8,7 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line!("") + Stdout.line! "" import ResistorColor exposing [color_code, colors] @@ -18,18 +18,18 @@ import ResistorColor exposing [color_code, colors] # Black expect - result = color_code("black") - result == Ok(0) + result = color_code "black" + result == Ok 0 # White expect - result = color_code("white") - result == Ok(9) + result = color_code "white" + result == Ok 9 # Orange expect - result = color_code("orange") - result == Ok(3) + result = color_code "orange" + result == Ok 3 ## ## Colors diff --git a/exercises/practice/rest-api/rest-api-test.roc b/exercises/practice/rest-api/rest-api-test.roc index 2d443166..04341533 100644 --- a/exercises/practice/rest-api/rest-api-test.roc +++ b/exercises/practice/rest-api/rest-api-test.roc @@ -1,6 +1,6 @@ # These tests are auto-generated with test data from: # https://github.com/exercism/problem-specifications/tree/main/exercises/rest-api/canonical-data.json -# File last updated on 2025-01-04 +# File last updated on 2025-07-26 app [main!] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.19.0/Hj-J_zxz7V9YurCSTFcFdu6cQJie4guzsPMUi5kBYUk.tar.br", json: "https://github.com/lukewilliamboswell/roc-json/releases/download/0.12.0/1trwx8sltQ-e9Y2rOB4LWUWLS_sFVyETK8Twl0i9qpw.tar.gz", @@ -9,21 +9,19 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line!("") + Stdout.line! "" import RestApi exposing [get, post] -standardize_result = |result| +standardizeResult = |result| result - |> Result.try( - |string| - string - |> Str.replace_each(".0,", ",") - |> Str.replace_each(".0}", "}") - |> Str.to_utf8 - |> List.drop_if(|c| [' ', '\t', '\n'] |> List.contains(c)) - |> Str.from_utf8, - ) + |> Result.try |string| + string + |> Str.replace_each ".0," "," + |> Str.replace_each ".0}" "}" + |> Str.to_utf8 + |> List.drop_if |c| [' ', '\t', '\n'] |> List.contains c + |> Str.from_utf8 ## ## user management @@ -37,13 +35,11 @@ expect } result = database - |> get( - { - url: "/users", - }, - ) - |> standardize_result - expected = Ok("{\"users\":[]}") + |> get { + url: "/users", + } + |> standardizeResult + expected = Ok "{\"users\":[]}" result == expected # add user @@ -54,14 +50,12 @@ expect } result = database - |> post( - { - url: "/add", - payload: "{\"user\": \"Adam\"}", - }, - ) - |> standardize_result - expected = Ok("{\"balance\":0,\"name\":\"Adam\",\"owed_by\":{},\"owes\":{}}") + |> post { + url: "/add", + payload: "{\"user\": \"Adam\"}", + } + |> standardizeResult + expected = Ok "{\"balance\":0,\"name\":\"Adam\",\"owed_by\":{},\"owes\":{}}" result == expected # get single user @@ -70,28 +64,26 @@ expect users: [ { name: "Adam", - owes: Dict.from_list([]), - owed_by: Dict.from_list([]), + owes: Dict.from_list [], + owed_by: Dict.from_list [], balance: 0.0, }, { name: "Bob", - owes: Dict.from_list([]), - owed_by: Dict.from_list([]), + owes: Dict.from_list [], + owed_by: Dict.from_list [], balance: 0.0, }, ], } result = database - |> get( - { - url: "/users", - payload: "{\"users\": [\"Bob\"]}", - }, - ) - |> standardize_result - expected = Ok("{\"users\":[{\"balance\":0,\"name\":\"Bob\",\"owed_by\":{},\"owes\":{}}]}") + |> get { + url: "/users", + payload: "{\"users\": [\"Bob\"]}", + } + |> standardizeResult + expected = Ok "{\"users\":[{\"balance\":0,\"name\":\"Bob\",\"owed_by\":{},\"owes\":{}}]}" result == expected ## @@ -104,28 +96,26 @@ expect users: [ { name: "Adam", - owes: Dict.from_list([]), - owed_by: Dict.from_list([]), + owes: Dict.from_list [], + owed_by: Dict.from_list [], balance: 0.0, }, { name: "Bob", - owes: Dict.from_list([]), - owed_by: Dict.from_list([]), + owes: Dict.from_list [], + owed_by: Dict.from_list [], balance: 0.0, }, ], } result = database - |> post( - { - url: "/iou", - payload: "{\"amount\": 3.0, \"borrower\": \"Bob\", \"lender\": \"Adam\"}", - }, - ) - |> standardize_result - expected = Ok("{\"users\":[{\"balance\":3,\"name\":\"Adam\",\"owed_by\":{\"Bob\":3},\"owes\":{}},{\"balance\":-3,\"name\":\"Bob\",\"owed_by\":{},\"owes\":{\"Adam\":3}}]}") + |> post { + url: "/iou", + payload: "{\"amount\": 3.0, \"borrower\": \"Bob\", \"lender\": \"Adam\"}", + } + |> standardizeResult + expected = Ok "{\"users\":[{\"balance\":3,\"name\":\"Adam\",\"owed_by\":{\"Bob\":3},\"owes\":{}},{\"balance\":-3,\"name\":\"Bob\",\"owed_by\":{},\"owes\":{\"Adam\":3}}]}" result == expected # borrower has negative balance @@ -134,42 +124,36 @@ expect users: [ { name: "Adam", - owes: Dict.from_list([]), - owed_by: Dict.from_list([]), + owes: Dict.from_list [], + owed_by: Dict.from_list [], balance: 0.0, }, { name: "Bob", - owes: Dict.from_list( - [ - ("Chuck", 3.0), - ], - ), - owed_by: Dict.from_list([]), + owes: Dict.from_list [ + ("Chuck", 3.0), + ], + owed_by: Dict.from_list [], balance: -3.0, }, { name: "Chuck", - owes: Dict.from_list([]), - owed_by: Dict.from_list( - [ - ("Bob", 3.0), - ], - ), + owes: Dict.from_list [], + owed_by: Dict.from_list [ + ("Bob", 3.0), + ], balance: 3.0, }, ], } result = database - |> post( - { - url: "/iou", - payload: "{\"amount\": 3.0, \"borrower\": \"Bob\", \"lender\": \"Adam\"}", - }, - ) - |> standardize_result - expected = Ok("{\"users\":[{\"balance\":3,\"name\":\"Adam\",\"owed_by\":{\"Bob\":3},\"owes\":{}},{\"balance\":-6,\"name\":\"Bob\",\"owed_by\":{},\"owes\":{\"Adam\":3,\"Chuck\":3}}]}") + |> post { + url: "/iou", + payload: "{\"amount\": 3.0, \"borrower\": \"Bob\", \"lender\": \"Adam\"}", + } + |> standardizeResult + expected = Ok "{\"users\":[{\"balance\":3,\"name\":\"Adam\",\"owed_by\":{\"Bob\":3},\"owes\":{}},{\"balance\":-6,\"name\":\"Bob\",\"owed_by\":{},\"owes\":{\"Adam\":3,\"Chuck\":3}}]}" result == expected # lender has negative balance @@ -178,42 +162,36 @@ expect users: [ { name: "Adam", - owes: Dict.from_list([]), - owed_by: Dict.from_list([]), + owes: Dict.from_list [], + owed_by: Dict.from_list [], balance: 0.0, }, { name: "Bob", - owes: Dict.from_list( - [ - ("Chuck", 3.0), - ], - ), - owed_by: Dict.from_list([]), + owes: Dict.from_list [ + ("Chuck", 3.0), + ], + owed_by: Dict.from_list [], balance: -3.0, }, { name: "Chuck", - owes: Dict.from_list([]), - owed_by: Dict.from_list( - [ - ("Bob", 3.0), - ], - ), + owes: Dict.from_list [], + owed_by: Dict.from_list [ + ("Bob", 3.0), + ], balance: 3.0, }, ], } result = database - |> post( - { - url: "/iou", - payload: "{\"amount\": 3.0, \"borrower\": \"Adam\", \"lender\": \"Bob\"}", - }, - ) - |> standardize_result - expected = Ok("{\"users\":[{\"balance\":-3,\"name\":\"Adam\",\"owed_by\":{},\"owes\":{\"Bob\":3}},{\"balance\":0,\"name\":\"Bob\",\"owed_by\":{\"Adam\":3},\"owes\":{\"Chuck\":3}}]}") + |> post { + url: "/iou", + payload: "{\"amount\": 3.0, \"borrower\": \"Adam\", \"lender\": \"Bob\"}", + } + |> standardizeResult + expected = Ok "{\"users\":[{\"balance\":-3,\"name\":\"Adam\",\"owed_by\":{},\"owes\":{\"Bob\":3}},{\"balance\":0,\"name\":\"Bob\",\"owed_by\":{\"Adam\":3},\"owes\":{\"Chuck\":3}}]}" result == expected # lender owes borrower @@ -222,36 +200,30 @@ expect users: [ { name: "Adam", - owes: Dict.from_list( - [ - ("Bob", 3.0), - ], - ), - owed_by: Dict.from_list([]), + owes: Dict.from_list [ + ("Bob", 3.0), + ], + owed_by: Dict.from_list [], balance: -3.0, }, { name: "Bob", - owes: Dict.from_list([]), - owed_by: Dict.from_list( - [ - ("Adam", 3.0), - ], - ), + owes: Dict.from_list [], + owed_by: Dict.from_list [ + ("Adam", 3.0), + ], balance: 3.0, }, ], } result = database - |> post( - { - url: "/iou", - payload: "{\"amount\": 2.0, \"borrower\": \"Bob\", \"lender\": \"Adam\"}", - }, - ) - |> standardize_result - expected = Ok("{\"users\":[{\"balance\":-1,\"name\":\"Adam\",\"owed_by\":{},\"owes\":{\"Bob\":1}},{\"balance\":1,\"name\":\"Bob\",\"owed_by\":{\"Adam\":1},\"owes\":{}}]}") + |> post { + url: "/iou", + payload: "{\"amount\": 2.0, \"borrower\": \"Bob\", \"lender\": \"Adam\"}", + } + |> standardizeResult + expected = Ok "{\"users\":[{\"balance\":-1,\"name\":\"Adam\",\"owed_by\":{},\"owes\":{\"Bob\":1}},{\"balance\":1,\"name\":\"Bob\",\"owed_by\":{\"Adam\":1},\"owes\":{}}]}" result == expected # lender owes borrower less than new loan @@ -260,36 +232,30 @@ expect users: [ { name: "Adam", - owes: Dict.from_list( - [ - ("Bob", 3.0), - ], - ), - owed_by: Dict.from_list([]), + owes: Dict.from_list [ + ("Bob", 3.0), + ], + owed_by: Dict.from_list [], balance: -3.0, }, { name: "Bob", - owes: Dict.from_list([]), - owed_by: Dict.from_list( - [ - ("Adam", 3.0), - ], - ), + owes: Dict.from_list [], + owed_by: Dict.from_list [ + ("Adam", 3.0), + ], balance: 3.0, }, ], } result = database - |> post( - { - url: "/iou", - payload: "{\"amount\": 4.0, \"borrower\": \"Bob\", \"lender\": \"Adam\"}", - }, - ) - |> standardize_result - expected = Ok("{\"users\":[{\"balance\":1,\"name\":\"Adam\",\"owed_by\":{\"Bob\":1},\"owes\":{}},{\"balance\":-1,\"name\":\"Bob\",\"owed_by\":{},\"owes\":{\"Adam\":1}}]}") + |> post { + url: "/iou", + payload: "{\"amount\": 4.0, \"borrower\": \"Bob\", \"lender\": \"Adam\"}", + } + |> standardizeResult + expected = Ok "{\"users\":[{\"balance\":1,\"name\":\"Adam\",\"owed_by\":{\"Bob\":1},\"owes\":{}},{\"balance\":-1,\"name\":\"Bob\",\"owed_by\":{},\"owes\":{\"Adam\":1}}]}" result == expected # lender owes borrower same as new loan @@ -298,35 +264,29 @@ expect users: [ { name: "Adam", - owes: Dict.from_list( - [ - ("Bob", 3.0), - ], - ), - owed_by: Dict.from_list([]), + owes: Dict.from_list [ + ("Bob", 3.0), + ], + owed_by: Dict.from_list [], balance: -3.0, }, { name: "Bob", - owes: Dict.from_list([]), - owed_by: Dict.from_list( - [ - ("Adam", 3.0), - ], - ), + owes: Dict.from_list [], + owed_by: Dict.from_list [ + ("Adam", 3.0), + ], balance: 3.0, }, ], } result = database - |> post( - { - url: "/iou", - payload: "{\"amount\": 3.0, \"borrower\": \"Bob\", \"lender\": \"Adam\"}", - }, - ) - |> standardize_result - expected = Ok("{\"users\":[{\"balance\":0,\"name\":\"Adam\",\"owed_by\":{},\"owes\":{}},{\"balance\":0,\"name\":\"Bob\",\"owed_by\":{},\"owes\":{}}]}") + |> post { + url: "/iou", + payload: "{\"amount\": 3.0, \"borrower\": \"Bob\", \"lender\": \"Adam\"}", + } + |> standardizeResult + expected = Ok "{\"users\":[{\"balance\":0,\"name\":\"Adam\",\"owed_by\":{},\"owes\":{}},{\"balance\":0,\"name\":\"Bob\",\"owed_by\":{},\"owes\":{}}]}" result == expected diff --git a/exercises/practice/reverse-string/reverse-string-test.roc b/exercises/practice/reverse-string/reverse-string-test.roc index d296e117..170ea04e 100644 --- a/exercises/practice/reverse-string/reverse-string-test.roc +++ b/exercises/practice/reverse-string/reverse-string-test.roc @@ -1,6 +1,6 @@ # These tests are auto-generated with test data from: # https://github.com/exercism/problem-specifications/tree/main/exercises/reverse-string/canonical-data.json -# File last updated on 2025-01-04 +# File last updated on 2025-07-26 app [main!] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.19.0/Hj-J_zxz7V9YurCSTFcFdu6cQJie4guzsPMUi5kBYUk.tar.br", unicode: "https://github.com/roc-lang/unicode/releases/download/0.3.0/9KKFsA4CdOz0JIOL7iBSI_2jGIXQ6TsFBXgd086idpY.tar.br", @@ -9,52 +9,52 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line!("") + Stdout.line! "" import ReverseString exposing [reverse] # an empty string expect - result = reverse("") + result = reverse "" result == "" # a word expect - result = reverse("robot") + result = reverse "robot" result == "tobor" # a capitalized word expect - result = reverse("Ramen") + result = reverse "Ramen" result == "nemaR" # a sentence with punctuation expect - result = reverse("I'm hungry!") + result = reverse "I'm hungry!" result == "!yrgnuh m'I" # a palindrome expect - result = reverse("racecar") + result = reverse "racecar" result == "racecar" # an even-sized word expect - result = reverse("drawer") + result = reverse "drawer" result == "reward" # wide characters expect - result = reverse("子猫") + result = reverse "子猫" result == "猫子" # grapheme cluster with pre-combined form expect - result = reverse("Würstchenstand") + result = reverse "Würstchenstand" result == "dnatsnehctsrüW" # grapheme clusters expect - result = reverse("ผู้เขียนโปรแกรม") + result = reverse "ผู้เขียนโปรแกรม" result == "มรกแรปโนยขีเผู้" diff --git a/exercises/practice/rna-transcription/rna-transcription-test.roc b/exercises/practice/rna-transcription/rna-transcription-test.roc index 9eef5626..5f070dd5 100644 --- a/exercises/practice/rna-transcription/rna-transcription-test.roc +++ b/exercises/practice/rna-transcription/rna-transcription-test.roc @@ -1,6 +1,6 @@ # These tests are auto-generated with test data from: # https://github.com/exercism/problem-specifications/tree/main/exercises/rna-transcription/canonical-data.json -# File last updated on 2025-01-04 +# File last updated on 2025-07-26 app [main!] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.19.0/Hj-J_zxz7V9YurCSTFcFdu6cQJie4guzsPMUi5kBYUk.tar.br", } @@ -8,37 +8,37 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line!("") + Stdout.line! "" import RnaTranscription exposing [to_rna] # Empty RNA sequence expect - result = to_rna("") + result = to_rna "" result == "" # RNA complement of cytosine is guanine expect - result = to_rna("C") + result = to_rna "C" result == "G" # RNA complement of guanine is cytosine expect - result = to_rna("G") + result = to_rna "G" result == "C" # RNA complement of thymine is adenine expect - result = to_rna("T") + result = to_rna "T" result == "A" # RNA complement of adenine is uracil expect - result = to_rna("A") + result = to_rna "A" result == "U" # RNA complement expect - result = to_rna("ACGTGGTCTTAA") + result = to_rna "ACGTGGTCTTAA" result == "UGCACCAGAAUU" diff --git a/exercises/practice/robot-simulator/robot-simulator-test.roc b/exercises/practice/robot-simulator/robot-simulator-test.roc index 8874979f..8b25c0e8 100644 --- a/exercises/practice/robot-simulator/robot-simulator-test.roc +++ b/exercises/practice/robot-simulator/robot-simulator-test.roc @@ -1,6 +1,6 @@ # These tests are auto-generated with test data from: # https://github.com/exercism/problem-specifications/tree/main/exercises/robot-simulator/canonical-data.json -# File last updated on 2025-01-04 +# File last updated on 2025-07-26 app [main!] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.19.0/Hj-J_zxz7V9YurCSTFcFdu6cQJie4guzsPMUi5kBYUk.tar.br", } @@ -8,7 +8,7 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line!("") + Stdout.line! "" import RobotSimulator exposing [create, move] @@ -18,12 +18,12 @@ import RobotSimulator exposing [create, move] # at origin facing north expect - result = create({}) + result = create {} result == { x: 0, y: 0, direction: North } # at negative position facing south expect - result = create({ x: -1, y: -1, direction: South }) + result = create { x: -1, y: -1, direction: South } result == { x: -1, y: -1, direction: South } ## @@ -32,26 +32,26 @@ expect # changes north to east expect - robot = create({}) - result = robot |> move("R") + robot = create {} + result = robot |> move "R" result == { x: 0, y: 0, direction: East } # changes east to south expect - robot = create({ direction: East }) - result = robot |> move("R") + robot = create { direction: East } + result = robot |> move "R" result == { x: 0, y: 0, direction: South } # changes south to west expect - robot = create({ direction: South }) - result = robot |> move("R") + robot = create { direction: South } + result = robot |> move "R" result == { x: 0, y: 0, direction: West } # changes west to north expect - robot = create({ direction: West }) - result = robot |> move("R") + robot = create { direction: West } + result = robot |> move "R" result == { x: 0, y: 0, direction: North } ## @@ -60,26 +60,26 @@ expect # changes north to west expect - robot = create({}) - result = robot |> move("L") + robot = create {} + result = robot |> move "L" result == { x: 0, y: 0, direction: West } # changes west to south expect - robot = create({ direction: West }) - result = robot |> move("L") + robot = create { direction: West } + result = robot |> move "L" result == { x: 0, y: 0, direction: South } # changes south to east expect - robot = create({ direction: South }) - result = robot |> move("L") + robot = create { direction: South } + result = robot |> move "L" result == { x: 0, y: 0, direction: East } # changes east to north expect - robot = create({ direction: East }) - result = robot |> move("L") + robot = create { direction: East } + result = robot |> move "L" result == { x: 0, y: 0, direction: North } ## @@ -88,26 +88,26 @@ expect # facing north increments Y expect - robot = create({}) - result = robot |> move("A") + robot = create {} + result = robot |> move "A" result == { x: 0, y: 1, direction: North } # facing south decrements Y expect - robot = create({ direction: South }) - result = robot |> move("A") + robot = create { direction: South } + result = robot |> move "A" result == { x: 0, y: -1, direction: South } # facing east increments X expect - robot = create({ direction: East }) - result = robot |> move("A") + robot = create { direction: East } + result = robot |> move "A" result == { x: 1, y: 0, direction: East } # facing west decrements X expect - robot = create({ direction: West }) - result = robot |> move("A") + robot = create { direction: West } + result = robot |> move "A" result == { x: -1, y: 0, direction: West } ## @@ -116,25 +116,25 @@ expect # moving east and north from README expect - robot = create({ x: 7, y: 3 }) - result = robot |> move("RAALAL") + robot = create { x: 7, y: 3 } + result = robot |> move "RAALAL" result == { x: 9, y: 4, direction: West } # moving west and north expect - robot = create({}) - result = robot |> move("LAAARALA") + robot = create {} + result = robot |> move "LAAARALA" result == { x: -4, y: 1, direction: West } # moving west and south expect - robot = create({ x: 2, y: -7, direction: East }) - result = robot |> move("RRAAAAALA") + robot = create { x: 2, y: -7, direction: East } + result = robot |> move "RRAAAAALA" result == { x: -3, y: -8, direction: South } # moving east and north expect - robot = create({ x: 8, y: 4, direction: South }) - result = robot |> move("LAAARRRALLLL") + robot = create { x: 8, y: 4, direction: South } + result = robot |> move "LAAARRRALLLL" result == { x: 11, y: 5, direction: North } diff --git a/exercises/practice/roman-numerals/roman-numerals-test.roc b/exercises/practice/roman-numerals/roman-numerals-test.roc index 9912d64e..b48a5c50 100644 --- a/exercises/practice/roman-numerals/roman-numerals-test.roc +++ b/exercises/practice/roman-numerals/roman-numerals-test.roc @@ -1,6 +1,6 @@ # These tests are auto-generated with test data from: # https://github.com/exercism/problem-specifications/tree/main/exercises/roman-numerals/canonical-data.json -# File last updated on 2025-01-04 +# File last updated on 2025-07-26 app [main!] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.19.0/Hj-J_zxz7V9YurCSTFcFdu6cQJie4guzsPMUi5kBYUk.tar.br", } @@ -8,142 +8,142 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line!("") + Stdout.line! "" import RomanNumerals exposing [roman] # 1 is I expect - result = roman(1) - result == Ok("I") + result = roman 1 + result == Ok "I" # 2 is II expect - result = roman(2) - result == Ok("II") + result = roman 2 + result == Ok "II" # 3 is III expect - result = roman(3) - result == Ok("III") + result = roman 3 + result == Ok "III" # 4 is IV expect - result = roman(4) - result == Ok("IV") + result = roman 4 + result == Ok "IV" # 5 is V expect - result = roman(5) - result == Ok("V") + result = roman 5 + result == Ok "V" # 6 is VI expect - result = roman(6) - result == Ok("VI") + result = roman 6 + result == Ok "VI" # 9 is IX expect - result = roman(9) - result == Ok("IX") + result = roman 9 + result == Ok "IX" # 16 is XVI expect - result = roman(16) - result == Ok("XVI") + result = roman 16 + result == Ok "XVI" # 27 is XXVII expect - result = roman(27) - result == Ok("XXVII") + result = roman 27 + result == Ok "XXVII" # 48 is XLVIII expect - result = roman(48) - result == Ok("XLVIII") + result = roman 48 + result == Ok "XLVIII" # 49 is XLIX expect - result = roman(49) - result == Ok("XLIX") + result = roman 49 + result == Ok "XLIX" # 59 is LIX expect - result = roman(59) - result == Ok("LIX") + result = roman 59 + result == Ok "LIX" # 66 is LXVI expect - result = roman(66) - result == Ok("LXVI") + result = roman 66 + result == Ok "LXVI" # 93 is XCIII expect - result = roman(93) - result == Ok("XCIII") + result = roman 93 + result == Ok "XCIII" # 141 is CXLI expect - result = roman(141) - result == Ok("CXLI") + result = roman 141 + result == Ok "CXLI" # 163 is CLXIII expect - result = roman(163) - result == Ok("CLXIII") + result = roman 163 + result == Ok "CLXIII" # 166 is CLXVI expect - result = roman(166) - result == Ok("CLXVI") + result = roman 166 + result == Ok "CLXVI" # 402 is CDII expect - result = roman(402) - result == Ok("CDII") + result = roman 402 + result == Ok "CDII" # 575 is DLXXV expect - result = roman(575) - result == Ok("DLXXV") + result = roman 575 + result == Ok "DLXXV" # 666 is DCLXVI expect - result = roman(666) - result == Ok("DCLXVI") + result = roman 666 + result == Ok "DCLXVI" # 911 is CMXI expect - result = roman(911) - result == Ok("CMXI") + result = roman 911 + result == Ok "CMXI" # 1024 is MXXIV expect - result = roman(1024) - result == Ok("MXXIV") + result = roman 1024 + result == Ok "MXXIV" # 1666 is MDCLXVI expect - result = roman(1666) - result == Ok("MDCLXVI") + result = roman 1666 + result == Ok "MDCLXVI" # 3000 is MMM expect - result = roman(3000) - result == Ok("MMM") + result = roman 3000 + result == Ok "MMM" # 3001 is MMMI expect - result = roman(3001) - result == Ok("MMMI") + result = roman 3001 + result == Ok "MMMI" # 3888 is MMMDCCCLXXXVIII expect - result = roman(3888) - result == Ok("MMMDCCCLXXXVIII") + result = roman 3888 + result == Ok "MMMDCCCLXXXVIII" # 3999 is MMMCMXCIX expect - result = roman(3999) - result == Ok("MMMCMXCIX") + result = roman 3999 + result == Ok "MMMCMXCIX" diff --git a/exercises/practice/rotational-cipher/rotational-cipher-test.roc b/exercises/practice/rotational-cipher/rotational-cipher-test.roc index 7ca8aad4..e652379a 100644 --- a/exercises/practice/rotational-cipher/rotational-cipher-test.roc +++ b/exercises/practice/rotational-cipher/rotational-cipher-test.roc @@ -1,6 +1,6 @@ # These tests are auto-generated with test data from: # https://github.com/exercism/problem-specifications/tree/main/exercises/rotational-cipher/canonical-data.json -# File last updated on 2025-01-04 +# File last updated on 2025-07-26 app [main!] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.19.0/Hj-J_zxz7V9YurCSTFcFdu6cQJie4guzsPMUi5kBYUk.tar.br", } @@ -8,57 +8,57 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line!("") + Stdout.line! "" import RotationalCipher exposing [rotate] # rotate a by 0, same output as input expect - result = rotate("a", 0) + result = rotate "a" 0 result == "a" # rotate a by 1 expect - result = rotate("a", 1) + result = rotate "a" 1 result == "b" # rotate a by 26, same output as input expect - result = rotate("a", 26) + result = rotate "a" 26 result == "a" # rotate m by 13 expect - result = rotate("m", 13) + result = rotate "m" 13 result == "z" # rotate n by 13 with wrap around alphabet expect - result = rotate("n", 13) + result = rotate "n" 13 result == "a" # rotate capital letters expect - result = rotate("OMG", 5) + result = rotate "OMG" 5 result == "TRL" # rotate spaces expect - result = rotate("O M G", 5) + result = rotate "O M G" 5 result == "T R L" # rotate numbers expect - result = rotate("Testing 1 2 3 testing", 4) + result = rotate "Testing 1 2 3 testing" 4 result == "Xiwxmrk 1 2 3 xiwxmrk" # rotate punctuation expect - result = rotate("Let's eat, Grandma!", 21) + result = rotate "Let's eat, Grandma!" 21 result == "Gzo'n zvo, Bmviyhv!" # rotate all letters expect - result = rotate("The quick brown fox jumps over the lazy dog.", 13) + result = rotate "The quick brown fox jumps over the lazy dog." 13 result == "Gur dhvpx oebja sbk whzcf bire gur ynml qbt." diff --git a/exercises/practice/run-length-encoding/run-length-encoding-test.roc b/exercises/practice/run-length-encoding/run-length-encoding-test.roc index 0edabfe2..81411606 100644 --- a/exercises/practice/run-length-encoding/run-length-encoding-test.roc +++ b/exercises/practice/run-length-encoding/run-length-encoding-test.roc @@ -1,6 +1,6 @@ # These tests are auto-generated with test data from: # https://github.com/exercism/problem-specifications/tree/main/exercises/run-length-encoding/canonical-data.json -# File last updated on 2025-01-04 +# File last updated on 2025-07-26 app [main!] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.19.0/Hj-J_zxz7V9YurCSTFcFdu6cQJie4guzsPMUi5kBYUk.tar.br", } @@ -8,7 +8,7 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line!("") + Stdout.line! "" import RunLengthEncoding exposing [encode, decode] @@ -21,42 +21,42 @@ expect string = "" result = string |> encode expected = "" - result == Ok(expected) + result == Ok expected # single characters only are encoded without count expect string = "XYZ" result = string |> encode expected = "XYZ" - result == Ok(expected) + result == Ok expected # string with no single characters expect string = "AABBBCCCC" result = string |> encode expected = "2A3B4C" - result == Ok(expected) + result == Ok expected # single characters mixed with repeated characters expect string = "WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWB" result = string |> encode expected = "12WB12W3B24WB" - result == Ok(expected) + result == Ok expected # multiple whitespace mixed in string expect string = " hsqq qww " result = string |> encode expected = "2 hs2q q2w2 " - result == Ok(expected) + result == Ok expected # lowercase characters expect string = "aabbbcccc" result = string |> encode expected = "2a3b4c" - result == Ok(expected) + result == Ok expected ## ## run-length decode a string @@ -67,42 +67,42 @@ expect string = "" result = string |> decode expected = "" - result == Ok(expected) + result == Ok expected # single characters only expect string = "XYZ" result = string |> decode expected = "XYZ" - result == Ok(expected) + result == Ok expected # string with no single characters expect string = "2A3B4C" result = string |> decode expected = "AABBBCCCC" - result == Ok(expected) + result == Ok expected # single characters with repeated characters expect string = "12WB12W3B24WB" result = string |> decode expected = "WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWB" - result == Ok(expected) + result == Ok expected # multiple whitespace mixed in string expect string = "2 hs2q q2w2 " result = string |> decode expected = " hsqq qww " - result == Ok(expected) + result == Ok expected # lowercase string expect string = "2a3b4c" result = string |> decode expected = "aabbbcccc" - result == Ok(expected) + result == Ok expected ## ## encode and then decode @@ -111,6 +111,6 @@ expect # encode followed by decode gives original string expect string = "zzz ZZ zZ" - result = string |> encode |> Result.try(decode) - result == Ok(string) + result = string |> encode |> Result.try decode + result == Ok string diff --git a/exercises/practice/saddle-points/saddle-points-test.roc b/exercises/practice/saddle-points/saddle-points-test.roc index 6c0750e7..3acbbd4f 100644 --- a/exercises/practice/saddle-points/saddle-points-test.roc +++ b/exercises/practice/saddle-points/saddle-points-test.roc @@ -1,6 +1,6 @@ # These tests are auto-generated with test data from: # https://github.com/exercism/problem-specifications/tree/main/exercises/saddle-points/canonical-data.json -# File last updated on 2025-01-04 +# File last updated on 2025-07-26 app [main!] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.19.0/Hj-J_zxz7V9YurCSTFcFdu6cQJie4guzsPMUi5kBYUk.tar.br", } @@ -8,143 +8,125 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line!("") + Stdout.line! "" import SaddlePoints exposing [saddle_points] # Can identify single saddle point expect - tree_heights = [ + treeHeights = [ [9, 8, 7], [5, 3, 2], [6, 6, 7], ] - result = tree_heights |> saddle_points - expected = Set.from_list( - [ - { row: 2, column: 1 }, - ], - ) + result = treeHeights |> saddle_points + expected = Set.from_list [ + { row: 2, column: 1 }, + ] result == expected # Can identify that empty matrix has no saddle points expect - tree_heights = [ + treeHeights = [ [], ] - result = tree_heights |> saddle_points - expected = Set.from_list( - [ - ], - ) + result = treeHeights |> saddle_points + expected = Set.from_list [ + ] result == expected # Can identify lack of saddle points when there are none expect - tree_heights = [ + treeHeights = [ [1, 2, 3], [3, 1, 2], [2, 3, 1], ] - result = tree_heights |> saddle_points - expected = Set.from_list( - [ - ], - ) + result = treeHeights |> saddle_points + expected = Set.from_list [ + ] result == expected # Can identify multiple saddle points in a column expect - tree_heights = [ + treeHeights = [ [4, 5, 4], [3, 5, 5], [1, 5, 4], ] - result = tree_heights |> saddle_points - expected = Set.from_list( - [ - { row: 1, column: 2 }, - { row: 2, column: 2 }, - { row: 3, column: 2 }, - ], - ) + result = treeHeights |> saddle_points + expected = Set.from_list [ + { row: 1, column: 2 }, + { row: 2, column: 2 }, + { row: 3, column: 2 }, + ] result == expected # Can identify multiple saddle points in a row expect - tree_heights = [ + treeHeights = [ [6, 7, 8], [5, 5, 5], [7, 5, 6], ] - result = tree_heights |> saddle_points - expected = Set.from_list( - [ - { row: 2, column: 1 }, - { row: 2, column: 2 }, - { row: 2, column: 3 }, - ], - ) + result = treeHeights |> saddle_points + expected = Set.from_list [ + { row: 2, column: 1 }, + { row: 2, column: 2 }, + { row: 2, column: 3 }, + ] result == expected # Can identify saddle point in bottom right corner expect - tree_heights = [ + treeHeights = [ [8, 7, 9], [6, 7, 6], [3, 2, 5], ] - result = tree_heights |> saddle_points - expected = Set.from_list( - [ - { row: 3, column: 3 }, - ], - ) + result = treeHeights |> saddle_points + expected = Set.from_list [ + { row: 3, column: 3 }, + ] result == expected # Can identify saddle points in a non square matrix expect - tree_heights = [ + treeHeights = [ [3, 1, 3], [3, 2, 4], ] - result = tree_heights |> saddle_points - expected = Set.from_list( - [ - { row: 1, column: 3 }, - { row: 1, column: 1 }, - ], - ) + result = treeHeights |> saddle_points + expected = Set.from_list [ + { row: 1, column: 3 }, + { row: 1, column: 1 }, + ] result == expected # Can identify that saddle points in a single column matrix are those with the minimum value expect - tree_heights = [ + treeHeights = [ [2], [1], [4], [1], ] - result = tree_heights |> saddle_points - expected = Set.from_list( - [ - { row: 2, column: 1 }, - { row: 4, column: 1 }, - ], - ) + result = treeHeights |> saddle_points + expected = Set.from_list [ + { row: 2, column: 1 }, + { row: 4, column: 1 }, + ] result == expected # Can identify that saddle points in a single row matrix are those with the maximum value expect - tree_heights = [ + treeHeights = [ [2, 5, 3, 5], ] - result = tree_heights |> saddle_points - expected = Set.from_list( - [ - { row: 1, column: 2 }, - { row: 1, column: 4 }, - ], - ) + result = treeHeights |> saddle_points + expected = Set.from_list [ + { row: 1, column: 2 }, + { row: 1, column: 4 }, + ] result == expected diff --git a/exercises/practice/say/say-test.roc b/exercises/practice/say/say-test.roc index c3c39a9c..90e939a4 100644 --- a/exercises/practice/say/say-test.roc +++ b/exercises/practice/say/say-test.roc @@ -1,6 +1,6 @@ # These tests are auto-generated with test data from: # https://github.com/exercism/problem-specifications/tree/main/exercises/say/canonical-data.json -# File last updated on 2025-01-04 +# File last updated on 2025-07-26 app [main!] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.19.0/Hj-J_zxz7V9YurCSTFcFdu6cQJie4guzsPMUi5kBYUk.tar.br", } @@ -8,97 +8,97 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line!("") + Stdout.line! "" import Say exposing [say] # zero expect - result = say(0) - result == Ok("zero") + result = say 0 + result == Ok "zero" # one expect - result = say(1) - result == Ok("one") + result = say 1 + result == Ok "one" # fourteen expect - result = say(14) - result == Ok("fourteen") + result = say 14 + result == Ok "fourteen" # twenty expect - result = say(20) - result == Ok("twenty") + result = say 20 + result == Ok "twenty" # twenty-two expect - result = say(22) - result == Ok("twenty-two") + result = say 22 + result == Ok "twenty-two" # thirty expect - result = say(30) - result == Ok("thirty") + result = say 30 + result == Ok "thirty" # ninety-nine expect - result = say(99) - result == Ok("ninety-nine") + result = say 99 + result == Ok "ninety-nine" # one hundred expect - result = say(100) - result == Ok("one hundred") + result = say 100 + result == Ok "one hundred" # one hundred twenty-three expect - result = say(123) - result == Ok("one hundred twenty-three") + result = say 123 + result == Ok "one hundred twenty-three" # two hundred expect - result = say(200) - result == Ok("two hundred") + result = say 200 + result == Ok "two hundred" # nine hundred ninety-nine expect - result = say(999) - result == Ok("nine hundred ninety-nine") + result = say 999 + result == Ok "nine hundred ninety-nine" # one thousand expect - result = say(1000) - result == Ok("one thousand") + result = say 1000 + result == Ok "one thousand" # one thousand two hundred thirty-four expect - result = say(1234) - result == Ok("one thousand two hundred thirty-four") + result = say 1234 + result == Ok "one thousand two hundred thirty-four" # one million expect - result = say(1000000) - result == Ok("one million") + result = say 1000000 + result == Ok "one million" # one million two thousand three hundred forty-five expect - result = say(1002345) - result == Ok("one million two thousand three hundred forty-five") + result = say 1002345 + result == Ok "one million two thousand three hundred forty-five" # one billion expect - result = say(1000000000) - result == Ok("one billion") + result = say 1000000000 + result == Ok "one billion" # a big number expect - result = say(987654321123) - result == Ok("nine hundred eighty-seven billion six hundred fifty-four million three hundred twenty-one thousand one hundred twenty-three") + result = say 987654321123 + result == Ok "nine hundred eighty-seven billion six hundred fifty-four million three hundred twenty-one thousand one hundred twenty-three" # numbers above 999,999,999,999 are out of range expect - result = say(1000000000000) + result = say 1000000000000 result |> Result.is_err diff --git a/exercises/practice/scrabble-score/scrabble-score-test.roc b/exercises/practice/scrabble-score/scrabble-score-test.roc index 6230e9c8..690b9b91 100644 --- a/exercises/practice/scrabble-score/scrabble-score-test.roc +++ b/exercises/practice/scrabble-score/scrabble-score-test.roc @@ -1,6 +1,6 @@ # These tests are auto-generated with test data from: # https://github.com/exercism/problem-specifications/tree/main/exercises/scrabble-score/canonical-data.json -# File last updated on 2025-01-04 +# File last updated on 2025-07-26 app [main!] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.19.0/Hj-J_zxz7V9YurCSTFcFdu6cQJie4guzsPMUi5kBYUk.tar.br", } @@ -8,62 +8,62 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line!("") + Stdout.line! "" import ScrabbleScore exposing [score] # lowercase letter expect - result = score("a") + result = score "a" result == 1 # uppercase letter expect - result = score("A") + result = score "A" result == 1 # valuable letter expect - result = score("f") + result = score "f" result == 4 # short word expect - result = score("at") + result = score "at" result == 2 # short, valuable word expect - result = score("zoo") + result = score "zoo" result == 12 # medium word expect - result = score("street") + result = score "street" result == 6 # medium, valuable word expect - result = score("quirky") + result = score "quirky" result == 22 # long, mixed-case word expect - result = score("OxyphenButazone") + result = score "OxyphenButazone" result == 41 # english-like word expect - result = score("pinata") + result = score "pinata" result == 8 # empty input expect - result = score("") + result = score "" result == 0 # entire alphabet available expect - result = score("abcdefghijklmnopqrstuvwxyz") + result = score "abcdefghijklmnopqrstuvwxyz" result == 87 diff --git a/exercises/practice/secret-handshake/secret-handshake-test.roc b/exercises/practice/secret-handshake/secret-handshake-test.roc index 73175d0d..2c599cd8 100644 --- a/exercises/practice/secret-handshake/secret-handshake-test.roc +++ b/exercises/practice/secret-handshake/secret-handshake-test.roc @@ -1,6 +1,6 @@ # These tests are auto-generated with test data from: # https://github.com/exercism/problem-specifications/tree/main/exercises/secret-handshake/canonical-data.json -# File last updated on 2025-01-04 +# File last updated on 2025-07-26 app [main!] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.19.0/Hj-J_zxz7V9YurCSTFcFdu6cQJie4guzsPMUi5kBYUk.tar.br", } @@ -8,62 +8,62 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line!("") + Stdout.line! "" import SecretHandshake exposing [commands] # wink for 1 expect - result = commands(1) + result = commands 1 result == ["wink"] # double blink for 10 expect - result = commands(2) + result = commands 2 result == ["double blink"] # close your eyes for 100 expect - result = commands(4) + result = commands 4 result == ["close your eyes"] # jump for 1000 expect - result = commands(8) + result = commands 8 result == ["jump"] # combine two actions expect - result = commands(3) + result = commands 3 result == ["wink", "double blink"] # reverse two actions expect - result = commands(19) + result = commands 19 result == ["double blink", "wink"] # reversing one action gives the same action expect - result = commands(24) + result = commands 24 result == ["jump"] # reversing no actions still gives no actions expect - result = commands(16) + result = commands 16 result == [] # all possible actions expect - result = commands(15) + result = commands 15 result == ["wink", "double blink", "close your eyes", "jump"] # reverse all possible actions expect - result = commands(31) + result = commands 31 result == ["jump", "close your eyes", "double blink", "wink"] # do nothing for zero expect - result = commands(0) + result = commands 0 result == [] diff --git a/exercises/practice/series/series-test.roc b/exercises/practice/series/series-test.roc index 5b2fc82b..49ed397e 100644 --- a/exercises/practice/series/series-test.roc +++ b/exercises/practice/series/series-test.roc @@ -1,6 +1,6 @@ # These tests are auto-generated with test data from: # https://github.com/exercism/problem-specifications/tree/main/exercises/series/canonical-data.json -# File last updated on 2025-01-04 +# File last updated on 2025-07-26 app [main!] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.19.0/Hj-J_zxz7V9YurCSTFcFdu6cQJie4guzsPMUi5kBYUk.tar.br", } @@ -8,57 +8,57 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line!("") + Stdout.line! "" import Series exposing [slices] # slices of one from one expect - result = "1" |> slices(1) + result = "1" |> slices 1 result == ["1"] # slices of one from two expect - result = "12" |> slices(1) + result = "12" |> slices 1 result == ["1", "2"] # slices of two expect - result = "35" |> slices(2) + result = "35" |> slices 2 result == ["35"] # slices of two overlap expect - result = "9142" |> slices(2) + result = "9142" |> slices 2 result == ["91", "14", "42"] # slices can include duplicates expect - result = "777777" |> slices(3) + result = "777777" |> slices 3 result == ["777", "777", "777", "777"] # slices of a long series expect - result = "918493904243" |> slices(5) + result = "918493904243" |> slices 5 result == ["91849", "18493", "84939", "49390", "93904", "39042", "90424", "04243"] # slice length is too large – just return an empty list expect - result = "12345" |> slices(6) + result = "12345" |> slices 6 result == [] # slice length is way too large – just return an empty list expect - result = "12345" |> slices(42) + result = "12345" |> slices 42 result == [] # slice length cannot be zero – just return an empty list expect - result = "12345" |> slices(0) + result = "12345" |> slices 0 result == [] # empty series is invalid – just return an empty list expect - result = "" |> slices(1) + result = "" |> slices 1 result == [] diff --git a/exercises/practice/sgf-parsing/sgf-parsing-test.roc b/exercises/practice/sgf-parsing/sgf-parsing-test.roc index 5f9d712b..82f301de 100644 --- a/exercises/practice/sgf-parsing/sgf-parsing-test.roc +++ b/exercises/practice/sgf-parsing/sgf-parsing-test.roc @@ -1,6 +1,6 @@ # These tests are auto-generated with test data from: # https://github.com/exercism/problem-specifications/tree/main/exercises/sgf-parsing/canonical-data.json -# File last updated on 2025-01-04 +# File last updated on 2025-07-26 app [main!] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.19.0/Hj-J_zxz7V9YurCSTFcFdu6cQJie4guzsPMUi5kBYUk.tar.br", parser: "https://github.com/lukewilliamboswell/roc-parser/releases/download/0.10.0/6eZYaXkrakq9fJ4oUc0VfdxU1Fap2iTuAN18q9OgQss.tar.br", @@ -9,397 +9,307 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line!("") + Stdout.line! "" import SgfParsing exposing [parse] # empty input expect sgf = "" - result = parse(sgf) + result = parse sgf result |> Result.is_err # tree with no nodes expect sgf = "()" - result = parse(sgf) + result = parse sgf result |> Result.is_err # node without tree expect sgf = ";" - result = parse(sgf) + result = parse sgf result |> Result.is_err # node without properties expect sgf = "(;)" - result = parse(sgf) + result = parse sgf expected = - GameNode( - { - properties: Dict.from_list([]), - children: [], - }, - ) - result == Ok(expected) + GameNode { + properties: Dict.from_list [], + children: [], + } + result == Ok expected # single node tree expect sgf = "(;A[B])" - result = parse(sgf) + result = parse sgf expected = - GameNode( - { - properties: Dict.from_list( - [ - ("A", ["B"]), - ], - ), - children: [], - }, - ) - result == Ok(expected) + GameNode { + properties: Dict.from_list [ + ("A", ["B"]), + ], + children: [], + } + result == Ok expected # multiple properties expect sgf = "(;A[b]C[d])" - result = parse(sgf) + result = parse sgf expected = - GameNode( - { - properties: Dict.from_list( - [ - ("A", ["b"]), - ("C", ["d"]), - ], - ), - children: [], - }, - ) - result == Ok(expected) + GameNode { + properties: Dict.from_list [ + ("A", ["b"]), + ("C", ["d"]), + ], + children: [], + } + result == Ok expected # properties without delimiter expect sgf = "(;A)" - result = parse(sgf) + result = parse sgf result |> Result.is_err # all lowercase property expect sgf = "(;a[b])" - result = parse(sgf) + result = parse sgf result |> Result.is_err # upper and lowercase property expect sgf = "(;Aa[b])" - result = parse(sgf) + result = parse sgf result |> Result.is_err # two nodes expect sgf = "(;A[B];B[C])" - result = parse(sgf) + result = parse sgf expected = - GameNode( - { - properties: Dict.from_list( - [ - ("A", ["B"]), + GameNode { + properties: Dict.from_list [ + ("A", ["B"]), + ], + children: [ + GameNode { + properties: Dict.from_list [ + ("B", ["C"]), ], - ), - children: [ - GameNode( - { - properties: Dict.from_list( - [ - ("B", ["C"]), - ], - ), - children: [], - }, - ), - ], - }, - ) - result == Ok(expected) + children: [], + }, + ], + } + result == Ok expected # two child trees expect sgf = "(;A[B](;B[C])(;C[D]))" - result = parse(sgf) + result = parse sgf expected = - GameNode( - { - properties: Dict.from_list( - [ - ("A", ["B"]), + GameNode { + properties: Dict.from_list [ + ("A", ["B"]), + ], + children: [ + GameNode { + properties: Dict.from_list [ + ("B", ["C"]), + ], + children: [], + }, + GameNode { + properties: Dict.from_list [ + ("C", ["D"]), ], - ), - children: [ - GameNode( - { - properties: Dict.from_list( - [ - ("B", ["C"]), - ], - ), - children: [], - }, - ), - GameNode( - { - properties: Dict.from_list( - [ - ("C", ["D"]), - ], - ), - children: [], - }, - ), - ], - }, - ) - result == Ok(expected) + children: [], + }, + ], + } + result == Ok expected # multiple property values expect sgf = "(;A[b][c][d])" - result = parse(sgf) + result = parse sgf expected = - GameNode( - { - properties: Dict.from_list( - [ - ("A", ["b", "c", "d"]), - ], - ), - children: [], - }, - ) - result == Ok(expected) + GameNode { + properties: Dict.from_list [ + ("A", ["b", "c", "d"]), + ], + children: [], + } + result == Ok expected # within property values, whitespace characters such as tab are converted to spaces expect sgf = "(;A[hello\t\tworld])" - result = parse(sgf) + result = parse sgf expected = - GameNode( - { - properties: Dict.from_list( - [ - ("A", ["hello world"]), - ], - ), - children: [], - }, - ) - result == Ok(expected) + GameNode { + properties: Dict.from_list [ + ("A", ["hello world"]), + ], + children: [], + } + result == Ok expected # within property values, newlines remain as newlines expect sgf = "(;A[hello\n\nworld])" - result = parse(sgf) + result = parse sgf expected = - GameNode( - { - properties: Dict.from_list( - [ - ("A", ["hello\n\nworld"]), - ], - ), - children: [], - }, - ) - result == Ok(expected) + GameNode { + properties: Dict.from_list [ + ("A", ["hello\n\nworld"]), + ], + children: [], + } + result == Ok expected # escaped closing bracket within property value becomes just a closing bracket expect sgf = "(;A[\\]])" - result = parse(sgf) + result = parse sgf expected = - GameNode( - { - properties: Dict.from_list( - [ - ("A", ["]"]), - ], - ), - children: [], - }, - ) - result == Ok(expected) + GameNode { + properties: Dict.from_list [ + ("A", ["]"]), + ], + children: [], + } + result == Ok expected # escaped backslash in property value becomes just a backslash expect sgf = "(;A[\\\\])" - result = parse(sgf) + result = parse sgf expected = - GameNode( - { - properties: Dict.from_list( - [ - ("A", ["\\"]), - ], - ), - children: [], - }, - ) - result == Ok(expected) + GameNode { + properties: Dict.from_list [ + ("A", ["\\"]), + ], + children: [], + } + result == Ok expected # opening bracket within property value doesn't need to be escaped expect sgf = "(;A[x[y\\]z][foo]B[bar];C[baz])" - result = parse(sgf) + result = parse sgf expected = - GameNode( - { - properties: Dict.from_list( - [ - ("A", ["x[y]z", "foo"]), - ("B", ["bar"]), + GameNode { + properties: Dict.from_list [ + ("A", ["x[y]z", "foo"]), + ("B", ["bar"]), + ], + children: [ + GameNode { + properties: Dict.from_list [ + ("C", ["baz"]), ], - ), - children: [ - GameNode( - { - properties: Dict.from_list( - [ - ("C", ["baz"]), - ], - ), - children: [], - }, - ), - ], - }, - ) - result == Ok(expected) + children: [], + }, + ], + } + result == Ok expected # semicolon in property value doesn't need to be escaped expect sgf = "(;A[a;b][foo]B[bar];C[baz])" - result = parse(sgf) + result = parse sgf expected = - GameNode( - { - properties: Dict.from_list( - [ - ("A", ["a;b", "foo"]), - ("B", ["bar"]), + GameNode { + properties: Dict.from_list [ + ("A", ["a;b", "foo"]), + ("B", ["bar"]), + ], + children: [ + GameNode { + properties: Dict.from_list [ + ("C", ["baz"]), ], - ), - children: [ - GameNode( - { - properties: Dict.from_list( - [ - ("C", ["baz"]), - ], - ), - children: [], - }, - ), - ], - }, - ) - result == Ok(expected) + children: [], + }, + ], + } + result == Ok expected # parentheses in property value don't need to be escaped expect sgf = "(;A[x(y)z][foo]B[bar];C[baz])" - result = parse(sgf) + result = parse sgf expected = - GameNode( - { - properties: Dict.from_list( - [ - ("A", ["x(y)z", "foo"]), - ("B", ["bar"]), + GameNode { + properties: Dict.from_list [ + ("A", ["x(y)z", "foo"]), + ("B", ["bar"]), + ], + children: [ + GameNode { + properties: Dict.from_list [ + ("C", ["baz"]), ], - ), - children: [ - GameNode( - { - properties: Dict.from_list( - [ - ("C", ["baz"]), - ], - ), - children: [], - }, - ), - ], - }, - ) - result == Ok(expected) + children: [], + }, + ], + } + result == Ok expected # escaped tab in property value is converted to space expect sgf = "(;A[hello\\\tworld])" - result = parse(sgf) + result = parse sgf expected = - GameNode( - { - properties: Dict.from_list( - [ - ("A", ["hello world"]), - ], - ), - children: [], - }, - ) - result == Ok(expected) + GameNode { + properties: Dict.from_list [ + ("A", ["hello world"]), + ], + children: [], + } + result == Ok expected # escaped newline in property value is converted to nothing at all expect sgf = "(;A[hello\\\nworld])" - result = parse(sgf) + result = parse sgf expected = - GameNode( - { - properties: Dict.from_list( - [ - ("A", ["helloworld"]), - ], - ), - children: [], - }, - ) - result == Ok(expected) + GameNode { + properties: Dict.from_list [ + ("A", ["helloworld"]), + ], + children: [], + } + result == Ok expected # escaped t and n in property value are just letters, not whitespace expect sgf = "(;A[\\t = t and \\n = n])" - result = parse(sgf) + result = parse sgf expected = - GameNode( - { - properties: Dict.from_list( - [ - ("A", ["t = t and n = n"]), - ], - ), - children: [], - }, - ) - result == Ok(expected) + GameNode { + properties: Dict.from_list [ + ("A", ["t = t and n = n"]), + ], + children: [], + } + result == Ok expected # mixing various kinds of whitespace and escaped characters in property value expect sgf = "(;A[\\]b\nc\\\nd\t\te\\\\ \\\n\\]])" - result = parse(sgf) + result = parse sgf expected = - GameNode( - { - properties: Dict.from_list( - [ - ("A", ["]b\ncd e\\ ]"]), - ], - ), - children: [], - }, - ) - result == Ok(expected) + GameNode { + properties: Dict.from_list [ + ("A", ["]b\ncd e\\ ]"]), + ], + children: [], + } + result == Ok expected diff --git a/exercises/practice/sieve/sieve-test.roc b/exercises/practice/sieve/sieve-test.roc index 9f4e5001..68208ce9 100644 --- a/exercises/practice/sieve/sieve-test.roc +++ b/exercises/practice/sieve/sieve-test.roc @@ -1,6 +1,6 @@ # These tests are auto-generated with test data from: # https://github.com/exercism/problem-specifications/tree/main/exercises/sieve/canonical-data.json -# File last updated on 2025-01-04 +# File last updated on 2025-07-26 app [main!] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.19.0/Hj-J_zxz7V9YurCSTFcFdu6cQJie4guzsPMUi5kBYUk.tar.br", } @@ -8,32 +8,32 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line!("") + Stdout.line! "" import Sieve exposing [primes] # no primes under two expect - result = primes(1) + result = primes 1 result == [] # find first prime expect - result = primes(2) + result = primes 2 result == [2] # find primes up to 10 expect - result = primes(10) + result = primes 10 result == [2, 3, 5, 7] # limit is prime expect - result = primes(13) + result = primes 13 result == [2, 3, 5, 7, 11, 13] # find primes up to 1000 expect - result = primes(1000) + result = primes 1000 result == [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997] diff --git a/exercises/practice/space-age/space-age-test.roc b/exercises/practice/space-age/space-age-test.roc index c89046e0..108f184e 100644 --- a/exercises/practice/space-age/space-age-test.roc +++ b/exercises/practice/space-age/space-age-test.roc @@ -1,6 +1,6 @@ # These tests are auto-generated with test data from: # https://github.com/exercism/problem-specifications/tree/main/exercises/space-age/canonical-data.json -# File last updated on 2025-01-04 +# File last updated on 2025-07-26 app [main!] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.19.0/Hj-J_zxz7V9YurCSTFcFdu6cQJie4guzsPMUi5kBYUk.tar.br", } @@ -8,47 +8,47 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line!("") + Stdout.line! "" import SpaceAge exposing [age] # age on Earth expect - result = age(Earth, 1000000000) - Num.is_approx_eq(result, 31.69, { atol: 0.01 }) + result = age Earth 1000000000 + Num.is_approx_eq result 31.69 { atol: 0.01 } # age on Mercury expect - result = age(Mercury, 2134835688) - Num.is_approx_eq(result, 280.88, { atol: 0.01 }) + result = age Mercury 2134835688 + Num.is_approx_eq result 280.88 { atol: 0.01 } # age on Venus expect - result = age(Venus, 189839836) - Num.is_approx_eq(result, 9.78, { atol: 0.01 }) + result = age Venus 189839836 + Num.is_approx_eq result 9.78 { atol: 0.01 } # age on Mars expect - result = age(Mars, 2129871239) - Num.is_approx_eq(result, 35.88, { atol: 0.01 }) + result = age Mars 2129871239 + Num.is_approx_eq result 35.88 { atol: 0.01 } # age on Jupiter expect - result = age(Jupiter, 901876382) - Num.is_approx_eq(result, 2.41, { atol: 0.01 }) + result = age Jupiter 901876382 + Num.is_approx_eq result 2.41 { atol: 0.01 } # age on Saturn expect - result = age(Saturn, 2000000000) - Num.is_approx_eq(result, 2.15, { atol: 0.01 }) + result = age Saturn 2000000000 + Num.is_approx_eq result 2.15 { atol: 0.01 } # age on Uranus expect - result = age(Uranus, 1210123456) - Num.is_approx_eq(result, 0.46, { atol: 0.01 }) + result = age Uranus 1210123456 + Num.is_approx_eq result 0.46 { atol: 0.01 } # age on Neptune expect - result = age(Neptune, 1821023456) - Num.is_approx_eq(result, 0.35, { atol: 0.01 }) + result = age Neptune 1821023456 + Num.is_approx_eq result 0.35 { atol: 0.01 } diff --git a/exercises/practice/spiral-matrix/spiral-matrix-test.roc b/exercises/practice/spiral-matrix/spiral-matrix-test.roc index 55347033..cd99fb25 100644 --- a/exercises/practice/spiral-matrix/spiral-matrix-test.roc +++ b/exercises/practice/spiral-matrix/spiral-matrix-test.roc @@ -1,6 +1,6 @@ # These tests are auto-generated with test data from: # https://github.com/exercism/problem-specifications/tree/main/exercises/spiral-matrix/canonical-data.json -# File last updated on 2025-01-04 +# File last updated on 2025-07-26 app [main!] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.19.0/Hj-J_zxz7V9YurCSTFcFdu6cQJie4guzsPMUi5kBYUk.tar.br", } @@ -8,18 +8,18 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line!("") + Stdout.line! "" import SpiralMatrix exposing [spiral_matrix] # empty spiral expect - result = spiral_matrix(0) + result = spiral_matrix 0 result == [] # trivial spiral expect - result = spiral_matrix(1) + result = spiral_matrix 1 expected = [ [1], ] @@ -27,7 +27,7 @@ expect # spiral of size 2 expect - result = spiral_matrix(2) + result = spiral_matrix 2 expected = [ [1, 2], [4, 3], @@ -36,7 +36,7 @@ expect # spiral of size 3 expect - result = spiral_matrix(3) + result = spiral_matrix 3 expected = [ [1, 2, 3], [8, 9, 4], @@ -46,7 +46,7 @@ expect # spiral of size 4 expect - result = spiral_matrix(4) + result = spiral_matrix 4 expected = [ [1, 2, 3, 4], [12, 13, 14, 5], @@ -57,7 +57,7 @@ expect # spiral of size 5 expect - result = spiral_matrix(5) + result = spiral_matrix 5 expected = [ [1, 2, 3, 4, 5], [16, 17, 18, 19, 6], diff --git a/exercises/practice/square-root/square-root-test.roc b/exercises/practice/square-root/square-root-test.roc index 626f055f..d3645245 100644 --- a/exercises/practice/square-root/square-root-test.roc +++ b/exercises/practice/square-root/square-root-test.roc @@ -1,6 +1,6 @@ # These tests are auto-generated with test data from: # https://github.com/exercism/problem-specifications/tree/main/exercises/square-root/canonical-data.json -# File last updated on 2025-01-04 +# File last updated on 2025-07-26 app [main!] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.19.0/Hj-J_zxz7V9YurCSTFcFdu6cQJie4guzsPMUi5kBYUk.tar.br", } @@ -8,37 +8,37 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line!("") + Stdout.line! "" import SquareRoot exposing [square_root] # root of 1 expect - result = square_root(1) + result = square_root 1 result == 1 # root of 4 expect - result = square_root(4) + result = square_root 4 result == 2 # root of 25 expect - result = square_root(25) + result = square_root 25 result == 5 # root of 81 expect - result = square_root(81) + result = square_root 81 result == 9 # root of 196 expect - result = square_root(196) + result = square_root 196 result == 14 # root of 65025 expect - result = square_root(65025) + result = square_root 65025 result == 255 diff --git a/exercises/practice/strain/strain-test.roc b/exercises/practice/strain/strain-test.roc index 5b2bfcbb..b0e544be 100644 --- a/exercises/practice/strain/strain-test.roc +++ b/exercises/practice/strain/strain-test.roc @@ -1,6 +1,6 @@ # These tests are auto-generated with test data from: # https://github.com/exercism/problem-specifications/tree/main/exercises/strain/canonical-data.json -# File last updated on 2025-01-04 +# File last updated on 2025-07-26 app [main!] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.19.0/Hj-J_zxz7V9YurCSTFcFdu6cQJie4guzsPMUi5kBYUk.tar.br", } @@ -8,105 +8,105 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line!("") + Stdout.line! "" import Strain exposing [keep, discard] # keep on empty list returns empty list expect list = [] - result = list |> keep(|_| Bool.true) + result = list |> keep |_| Bool.true expected = [] result == expected # keeps everything expect list = [1, 3, 5] - result = list |> keep(|_| Bool.true) + result = list |> keep |_| Bool.true expected = [1, 3, 5] result == expected # keeps nothing expect list = [1, 3, 5] - result = list |> keep(|_| Bool.false) + result = list |> keep |_| Bool.false expected = [] result == expected # keeps first and last expect list = [1, 2, 3] - result = list |> keep(|x| x % 2 == 1) + result = list |> keep |x| x % 2 == 1 expected = [1, 3] result == expected # keeps neither first nor last expect list = [1, 2, 3] - result = list |> keep(|x| x % 2 == 0) + result = list |> keep |x| x % 2 == 0 expected = [2] result == expected # keeps strings expect list = ["apple", "zebra", "banana", "zombies", "cherimoya", "zealot"] - result = list |> keep(|x| x |> Str.starts_with("z")) + result = list |> keep |x| x |> Str.starts_with "z" expected = ["zebra", "zombies", "zealot"] result == expected # keeps lists expect list = [[1, 2, 3], [5, 5, 5], [5, 1, 2], [2, 1, 2], [1, 5, 2], [2, 2, 1], [1, 2, 5]] - result = list |> keep(|x| x |> List.contains(5)) + result = list |> keep |x| x |> List.contains 5 expected = [[5, 5, 5], [5, 1, 2], [1, 5, 2], [1, 2, 5]] result == expected # discard on empty list returns empty list expect list = [] - result = list |> discard(|_| Bool.true) + result = list |> discard |_| Bool.true expected = [] result == expected # discards everything expect list = [1, 3, 5] - result = list |> discard(|_| Bool.true) + result = list |> discard |_| Bool.true expected = [] result == expected # discards nothing expect list = [1, 3, 5] - result = list |> discard(|_| Bool.false) + result = list |> discard |_| Bool.false expected = [1, 3, 5] result == expected # discards first and last expect list = [1, 2, 3] - result = list |> discard(|x| x % 2 == 1) + result = list |> discard |x| x % 2 == 1 expected = [2] result == expected # discards neither first nor last expect list = [1, 2, 3] - result = list |> discard(|x| x % 2 == 0) + result = list |> discard |x| x % 2 == 0 expected = [1, 3] result == expected # discards strings expect list = ["apple", "zebra", "banana", "zombies", "cherimoya", "zealot"] - result = list |> discard(|x| x |> Str.starts_with("z")) + result = list |> discard |x| x |> Str.starts_with "z" expected = ["apple", "banana", "cherimoya"] result == expected # discards lists expect list = [[1, 2, 3], [5, 5, 5], [5, 1, 2], [2, 1, 2], [1, 5, 2], [2, 2, 1], [1, 2, 5]] - result = list |> discard(|x| x |> List.contains(5)) + result = list |> discard |x| x |> List.contains 5 expected = [[1, 2, 3], [2, 1, 2], [2, 2, 1]] result == expected diff --git a/exercises/practice/sublist/sublist-test.roc b/exercises/practice/sublist/sublist-test.roc index d9081869..c4481739 100644 --- a/exercises/practice/sublist/sublist-test.roc +++ b/exercises/practice/sublist/sublist-test.roc @@ -1,6 +1,6 @@ # These tests are auto-generated with test data from: # https://github.com/exercism/problem-specifications/tree/main/exercises/sublist/canonical-data.json -# File last updated on 2025-01-04 +# File last updated on 2025-07-26 app [main!] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.19.0/Hj-J_zxz7V9YurCSTFcFdu6cQJie4guzsPMUi5kBYUk.tar.br", } @@ -8,97 +8,97 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line!("") + Stdout.line! "" import Sublist exposing [sublist] # empty lists expect - result = [] |> sublist([]) + result = [] |> sublist [] result == Equal # empty list within non empty list expect - result = [] |> sublist([1, 2, 3]) + result = [] |> sublist [1, 2, 3] result == Sublist # non empty list contains empty list expect - result = [1, 2, 3] |> sublist([]) + result = [1, 2, 3] |> sublist [] result == Superlist # list equals itself expect - result = [1, 2, 3] |> sublist([1, 2, 3]) + result = [1, 2, 3] |> sublist [1, 2, 3] result == Equal # different lists expect - result = [1, 2, 3] |> sublist([2, 3, 4]) + result = [1, 2, 3] |> sublist [2, 3, 4] result == Unequal # false start expect - result = [1, 2, 5] |> sublist([0, 1, 2, 3, 1, 2, 5, 6]) + result = [1, 2, 5] |> sublist [0, 1, 2, 3, 1, 2, 5, 6] result == Sublist # consecutive expect - result = [1, 1, 2] |> sublist([0, 1, 1, 1, 2, 1, 2]) + result = [1, 1, 2] |> sublist [0, 1, 1, 1, 2, 1, 2] result == Sublist # sublist at start expect - result = [0, 1, 2] |> sublist([0, 1, 2, 3, 4, 5]) + result = [0, 1, 2] |> sublist [0, 1, 2, 3, 4, 5] result == Sublist # sublist in middle expect - result = [2, 3, 4] |> sublist([0, 1, 2, 3, 4, 5]) + result = [2, 3, 4] |> sublist [0, 1, 2, 3, 4, 5] result == Sublist # sublist at end expect - result = [3, 4, 5] |> sublist([0, 1, 2, 3, 4, 5]) + result = [3, 4, 5] |> sublist [0, 1, 2, 3, 4, 5] result == Sublist # at start of superlist expect - result = [0, 1, 2, 3, 4, 5] |> sublist([0, 1, 2]) + result = [0, 1, 2, 3, 4, 5] |> sublist [0, 1, 2] result == Superlist # in middle of superlist expect - result = [0, 1, 2, 3, 4, 5] |> sublist([2, 3]) + result = [0, 1, 2, 3, 4, 5] |> sublist [2, 3] result == Superlist # at end of superlist expect - result = [0, 1, 2, 3, 4, 5] |> sublist([3, 4, 5]) + result = [0, 1, 2, 3, 4, 5] |> sublist [3, 4, 5] result == Superlist # first list missing element from second list expect - result = [1, 3] |> sublist([1, 2, 3]) + result = [1, 3] |> sublist [1, 2, 3] result == Unequal # second list missing element from first list expect - result = [1, 2, 3] |> sublist([1, 3]) + result = [1, 2, 3] |> sublist [1, 3] result == Unequal # first list missing additional digits from second list expect - result = [1, 2] |> sublist([1, 22]) + result = [1, 2] |> sublist [1, 22] result == Unequal # order matters to a list expect - result = [1, 2, 3] |> sublist([3, 2, 1]) + result = [1, 2, 3] |> sublist [3, 2, 1] result == Unequal # same digits but different numbers expect - result = [1, 0, 1] |> sublist([10, 1]) + result = [1, 0, 1] |> sublist [10, 1] result == Unequal diff --git a/exercises/practice/sum-of-multiples/sum-of-multiples-test.roc b/exercises/practice/sum-of-multiples/sum-of-multiples-test.roc index eb89ca60..c03131cf 100644 --- a/exercises/practice/sum-of-multiples/sum-of-multiples-test.roc +++ b/exercises/practice/sum-of-multiples/sum-of-multiples-test.roc @@ -1,6 +1,6 @@ # These tests are auto-generated with test data from: # https://github.com/exercism/problem-specifications/tree/main/exercises/sum-of-multiples/canonical-data.json -# File last updated on 2025-01-04 +# File last updated on 2025-07-26 app [main!] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.19.0/Hj-J_zxz7V9YurCSTFcFdu6cQJie4guzsPMUi5kBYUk.tar.br", } @@ -8,87 +8,87 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line!("") + Stdout.line! "" import SumOfMultiples exposing [sum_of_multiples] # no multiples within limit expect - result = [3, 5] |> sum_of_multiples(1) + result = [3, 5] |> sum_of_multiples 1 result == 0 # one factor has multiples within limit expect - result = [3, 5] |> sum_of_multiples(4) + result = [3, 5] |> sum_of_multiples 4 result == 3 # more than one multiple within limit expect - result = [3] |> sum_of_multiples(7) + result = [3] |> sum_of_multiples 7 result == 9 # more than one factor with multiples within limit expect - result = [3, 5] |> sum_of_multiples(10) + result = [3, 5] |> sum_of_multiples 10 result == 23 # each multiple is only counted once expect - result = [3, 5] |> sum_of_multiples(100) + result = [3, 5] |> sum_of_multiples 100 result == 2318 # a much larger limit expect - result = [3, 5] |> sum_of_multiples(1000) + result = [3, 5] |> sum_of_multiples 1000 result == 233168 # three factors expect - result = [7, 13, 17] |> sum_of_multiples(20) + result = [7, 13, 17] |> sum_of_multiples 20 result == 51 # factors not relatively prime expect - result = [4, 6] |> sum_of_multiples(15) + result = [4, 6] |> sum_of_multiples 15 result == 30 # some pairs of factors relatively prime and some not expect - result = [5, 6, 8] |> sum_of_multiples(150) + result = [5, 6, 8] |> sum_of_multiples 150 result == 4419 # one factor is a multiple of another expect - result = [5, 25] |> sum_of_multiples(51) + result = [5, 25] |> sum_of_multiples 51 result == 275 # much larger factors expect - result = [43, 47] |> sum_of_multiples(10000) + result = [43, 47] |> sum_of_multiples 10000 result == 2203160 # all numbers are multiples of 1 expect - result = [1] |> sum_of_multiples(100) + result = [1] |> sum_of_multiples 100 result == 4950 # no factors means an empty sum expect - result = [] |> sum_of_multiples(10000) + result = [] |> sum_of_multiples 10000 result == 0 # the only multiple of 0 is 0 expect - result = [0] |> sum_of_multiples(1) + result = [0] |> sum_of_multiples 1 result == 0 # the factor 0 does not affect the sum of multiples of other factors expect - result = [3, 0] |> sum_of_multiples(4) + result = [3, 0] |> sum_of_multiples 4 result == 3 # solutions using include-exclude must extend to cardinality greater than 3 expect - result = [2, 3, 5, 7, 11] |> sum_of_multiples(10000) + result = [2, 3, 5, 7, 11] |> sum_of_multiples 10000 result == 39614537 diff --git a/exercises/practice/tournament/tournament-test.roc b/exercises/practice/tournament/tournament-test.roc index 45f8b357..a3b3f7ad 100644 --- a/exercises/practice/tournament/tournament-test.roc +++ b/exercises/practice/tournament/tournament-test.roc @@ -1,6 +1,6 @@ # These tests are auto-generated with test data from: # https://github.com/exercism/problem-specifications/tree/main/exercises/tournament/canonical-data.json -# File last updated on 2025-01-04 +# File last updated on 2025-07-26 app [main!] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.19.0/Hj-J_zxz7V9YurCSTFcFdu6cQJie4guzsPMUi5kBYUk.tar.br", } @@ -8,67 +8,63 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line!("") + Stdout.line! "" import Tournament exposing [tally] # just the header if no input expect table = "" - result = tally(table) - expected = Ok("Team | MP | W | D | L | P") + result = tally table + expected = Ok "Team | MP | W | D | L | P" result == expected # a win is three points, a loss is zero points expect table = "Allegoric Alaskans;Blithering Badgers;win" - result = tally(table) - expected = Ok( + result = tally table + expected = Ok """ Team | MP | W | D | L | P Allegoric Alaskans | 1 | 1 | 0 | 0 | 3 Blithering Badgers | 1 | 0 | 0 | 1 | 0 - """, - ) + """ result == expected # a win can also be expressed as a loss expect table = "Blithering Badgers;Allegoric Alaskans;loss" - result = tally(table) - expected = Ok( + result = tally table + expected = Ok """ Team | MP | W | D | L | P Allegoric Alaskans | 1 | 1 | 0 | 0 | 3 Blithering Badgers | 1 | 0 | 0 | 1 | 0 - """, - ) + """ result == expected # a different team can win expect table = "Blithering Badgers;Allegoric Alaskans;win" - result = tally(table) - expected = Ok( + result = tally table + expected = Ok """ Team | MP | W | D | L | P Blithering Badgers | 1 | 1 | 0 | 0 | 3 Allegoric Alaskans | 1 | 0 | 0 | 1 | 0 - """, - ) + """ result == expected # a draw is one point each expect table = "Allegoric Alaskans;Blithering Badgers;draw" - result = tally(table) - expected = Ok( + result = tally table + expected = Ok """ Team | MP | W | D | L | P Allegoric Alaskans | 1 | 0 | 1 | 0 | 1 Blithering Badgers | 1 | 0 | 1 | 0 | 1 - """, - ) + """ result == expected # There can be more than one match @@ -78,14 +74,13 @@ expect Allegoric Alaskans;Blithering Badgers;win Allegoric Alaskans;Blithering Badgers;win """ - result = tally(table) - expected = Ok( + result = tally table + expected = Ok """ Team | MP | W | D | L | P Allegoric Alaskans | 2 | 2 | 0 | 0 | 6 Blithering Badgers | 2 | 0 | 0 | 2 | 0 - """, - ) + """ result == expected # There can be more than one winner @@ -95,14 +90,13 @@ expect Allegoric Alaskans;Blithering Badgers;loss Allegoric Alaskans;Blithering Badgers;win """ - result = tally(table) - expected = Ok( + result = tally table + expected = Ok """ Team | MP | W | D | L | P Allegoric Alaskans | 2 | 1 | 0 | 1 | 3 Blithering Badgers | 2 | 1 | 0 | 1 | 3 - """, - ) + """ result == expected # There can be more than two teams @@ -113,15 +107,14 @@ expect Blithering Badgers;Courageous Californians;win Courageous Californians;Allegoric Alaskans;loss """ - result = tally(table) - expected = Ok( + result = tally table + expected = Ok """ Team | MP | W | D | L | P Allegoric Alaskans | 2 | 2 | 0 | 0 | 6 Blithering Badgers | 2 | 1 | 0 | 1 | 3 Courageous Californians | 2 | 0 | 0 | 2 | 0 - """, - ) + """ result == expected # typical input @@ -135,16 +128,15 @@ expect Blithering Badgers;Devastating Donkeys;loss Allegoric Alaskans;Courageous Californians;win """ - result = tally(table) - expected = Ok( + result = tally table + expected = Ok """ Team | MP | W | D | L | P Devastating Donkeys | 3 | 2 | 1 | 0 | 7 Allegoric Alaskans | 3 | 2 | 0 | 1 | 6 Blithering Badgers | 3 | 1 | 0 | 2 | 3 Courageous Californians | 3 | 0 | 1 | 2 | 1 - """, - ) + """ result == expected # incomplete competition (not all pairs have played) @@ -156,16 +148,15 @@ expect Courageous Californians;Blithering Badgers;draw Allegoric Alaskans;Courageous Californians;win """ - result = tally(table) - expected = Ok( + result = tally table + expected = Ok """ Team | MP | W | D | L | P Allegoric Alaskans | 3 | 2 | 0 | 1 | 6 Blithering Badgers | 2 | 1 | 1 | 0 | 4 Courageous Californians | 2 | 0 | 1 | 1 | 1 Devastating Donkeys | 1 | 0 | 0 | 1 | 0 - """, - ) + """ result == expected # ties broken alphabetically @@ -179,16 +170,15 @@ expect Blithering Badgers;Devastating Donkeys;draw Allegoric Alaskans;Courageous Californians;draw """ - result = tally(table) - expected = Ok( + result = tally table + expected = Ok """ Team | MP | W | D | L | P Allegoric Alaskans | 3 | 2 | 1 | 0 | 7 Courageous Californians | 3 | 2 | 1 | 0 | 7 Blithering Badgers | 3 | 0 | 1 | 2 | 1 Devastating Donkeys | 3 | 0 | 1 | 2 | 1 - """, - ) + """ result == expected # ensure points sorted numerically @@ -201,13 +191,12 @@ expect Devastating Donkeys;Blithering Badgers;win Blithering Badgers;Devastating Donkeys;win """ - result = tally(table) - expected = Ok( + result = tally table + expected = Ok """ Team | MP | W | D | L | P Devastating Donkeys | 5 | 4 | 0 | 1 | 12 Blithering Badgers | 5 | 1 | 0 | 4 | 3 - """, - ) + """ result == expected diff --git a/exercises/practice/transpose/transpose-test.roc b/exercises/practice/transpose/transpose-test.roc index fcf7aa42..278239f8 100644 --- a/exercises/practice/transpose/transpose-test.roc +++ b/exercises/practice/transpose/transpose-test.roc @@ -1,6 +1,6 @@ # These tests are auto-generated with test data from: # https://github.com/exercism/problem-specifications/tree/main/exercises/transpose/canonical-data.json -# File last updated on 2025-01-04 +# File last updated on 2025-07-26 app [main!] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.19.0/Hj-J_zxz7V9YurCSTFcFdu6cQJie4guzsPMUi5kBYUk.tar.br", } @@ -8,21 +8,21 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line!("") + Stdout.line! "" import Transpose exposing [transpose] # empty string expect - input = "" |> Str.replace_each("□", " ") - result = transpose(input) |> Str.replace_each(" ", "□") + input = "" |> Str.replace_each "□" " " + result = transpose input |> Str.replace_each " " "□" expected = "" result == expected # two characters in a row expect - input = "A1" |> Str.replace_each("□", " ") - result = transpose(input) |> Str.replace_each(" ", "□") + input = "A1" |> Str.replace_each "□" " " + result = transpose input |> Str.replace_each " " "□" expected = """ A @@ -37,8 +37,8 @@ expect A 1 """ - |> Str.replace_each("□", " ") - result = transpose(input) |> Str.replace_each(" ", "□") + |> Str.replace_each "□" " " + result = transpose input |> Str.replace_each " " "□" expected = "A1" result == expected @@ -49,8 +49,8 @@ expect ABC 123 """ - |> Str.replace_each("□", " ") - result = transpose(input) |> Str.replace_each(" ", "□") + |> Str.replace_each "□" " " + result = transpose input |> Str.replace_each " " "□" expected = """ A1 @@ -61,8 +61,8 @@ expect # single line expect - input = "Single□line." |> Str.replace_each("□", " ") - result = transpose(input) |> Str.replace_each(" ", "□") + input = "Single□line." |> Str.replace_each "□" " " + result = transpose input |> Str.replace_each " " "□" expected = """ S @@ -87,8 +87,8 @@ expect The□fourth□line. The□fifth□line. """ - |> Str.replace_each("□", " ") - result = transpose(input) |> Str.replace_each(" ", "□") + |> Str.replace_each "□" " " + result = transpose input |> Str.replace_each " " "□" expected = """ TT @@ -117,8 +117,8 @@ expect The□first□line. The□second□line. """ - |> Str.replace_each("□", " ") - result = transpose(input) |> Str.replace_each(" ", "□") + |> Str.replace_each "□" " " + result = transpose input |> Str.replace_each " " "□" expected = """ TT @@ -149,8 +149,8 @@ expect A□longer□line. A□line. """ - |> Str.replace_each("□", " ") - result = transpose(input) |> Str.replace_each(" ", "□") + |> Str.replace_each "□" " " + result = transpose input |> Str.replace_each " " "□" expected = """ TAAA @@ -183,8 +183,8 @@ expect RESIN TREND """ - |> Str.replace_each("□", " ") - result = transpose(input) |> Str.replace_each(" ", "□") + |> Str.replace_each "□" " " + result = transpose input |> Str.replace_each " " "□" expected = """ HEART @@ -204,8 +204,8 @@ expect BLOOMING SEPTETTE """ - |> Str.replace_each("□", " ") - result = transpose(input) |> Str.replace_each(" ", "□") + |> Str.replace_each "□" " " + result = transpose input |> Str.replace_each " " "□" expected = """ FOBS @@ -230,8 +230,8 @@ expect EEEEE RRRRRR """ - |> Str.replace_each("□", " ") - result = transpose(input) |> Str.replace_each(" ", "□") + |> Str.replace_each "□" " " + result = transpose input |> Str.replace_each " " "□" expected = """ TEASER @@ -254,8 +254,8 @@ expect 555555 66666 """ - |> Str.replace_each("□", " ") - result = transpose(input) |> Str.replace_each(" ", "□") + |> Str.replace_each "□" " " + result = transpose input |> Str.replace_each " " "□" expected = """ 123456 diff --git a/exercises/practice/triangle/triangle-test.roc b/exercises/practice/triangle/triangle-test.roc index 6b4f0e65..18bee26d 100644 --- a/exercises/practice/triangle/triangle-test.roc +++ b/exercises/practice/triangle/triangle-test.roc @@ -1,6 +1,6 @@ # These tests are auto-generated with test data from: # https://github.com/exercism/problem-specifications/tree/main/exercises/triangle/canonical-data.json -# File last updated on 2025-01-04 +# File last updated on 2025-07-26 app [main!] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.19.0/Hj-J_zxz7V9YurCSTFcFdu6cQJie4guzsPMUi5kBYUk.tar.br", } @@ -8,7 +8,7 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line!("") + Stdout.line! "" import Triangle exposing [is_equilateral, is_isosceles, is_scalene] @@ -18,27 +18,27 @@ import Triangle exposing [is_equilateral, is_isosceles, is_scalene] # all sides are equal expect - result = is_equilateral((2, 2, 2)) + result = is_equilateral (2, 2, 2) result == Bool.true # any side is unequal expect - result = is_equilateral((2, 3, 2)) + result = is_equilateral (2, 3, 2) result == Bool.false # no sides are equal expect - result = is_equilateral((5, 4, 6)) + result = is_equilateral (5, 4, 6) result == Bool.false # all zero sides is not a triangle expect - result = is_equilateral((0, 0, 0)) + result = is_equilateral (0, 0, 0) result == Bool.false # sides may be floats expect - result = is_equilateral((0.5f64, 0.5f64, 0.5f64)) + result = is_equilateral (0.5f64, 0.5f64, 0.5f64) result == Bool.true ## @@ -47,47 +47,47 @@ expect # last two sides are equal expect - result = is_isosceles((3, 4, 4)) + result = is_isosceles (3, 4, 4) result == Bool.true # first two sides are equal expect - result = is_isosceles((4, 4, 3)) + result = is_isosceles (4, 4, 3) result == Bool.true # first and last sides are equal expect - result = is_isosceles((4, 3, 4)) + result = is_isosceles (4, 3, 4) result == Bool.true # equilateral triangles are also isosceles expect - result = is_isosceles((4, 4, 4)) + result = is_isosceles (4, 4, 4) result == Bool.true # no sides are equal expect - result = is_isosceles((2, 3, 4)) + result = is_isosceles (2, 3, 4) result == Bool.false # first triangle inequality violation expect - result = is_isosceles((1, 1, 3)) + result = is_isosceles (1, 1, 3) result == Bool.false # second triangle inequality violation expect - result = is_isosceles((1, 3, 1)) + result = is_isosceles (1, 3, 1) result == Bool.false # third triangle inequality violation expect - result = is_isosceles((3, 1, 1)) + result = is_isosceles (3, 1, 1) result == Bool.false # sides may be floats expect - result = is_isosceles((0.5f64, 0.4f64, 0.5f64)) + result = is_isosceles (0.5f64, 0.4f64, 0.5f64) result == Bool.true ## @@ -96,36 +96,36 @@ expect # no sides are equal expect - result = is_scalene((5, 4, 6)) + result = is_scalene (5, 4, 6) result == Bool.true # all sides are equal expect - result = is_scalene((4, 4, 4)) + result = is_scalene (4, 4, 4) result == Bool.false # first and second sides are equal expect - result = is_scalene((4, 4, 3)) + result = is_scalene (4, 4, 3) result == Bool.false # first and third sides are equal expect - result = is_scalene((3, 4, 3)) + result = is_scalene (3, 4, 3) result == Bool.false # second and third sides are equal expect - result = is_scalene((4, 3, 3)) + result = is_scalene (4, 3, 3) result == Bool.false # may not violate triangle inequality expect - result = is_scalene((7, 3, 2)) + result = is_scalene (7, 3, 2) result == Bool.false # sides may be floats expect - result = is_scalene((0.5f64, 0.4f64, 0.6f64)) + result = is_scalene (0.5f64, 0.4f64, 0.6f64) result == Bool.true diff --git a/exercises/practice/two-bucket/two-bucket-test.roc b/exercises/practice/two-bucket/two-bucket-test.roc index a92ab69a..ec41d6d7 100644 --- a/exercises/practice/two-bucket/two-bucket-test.roc +++ b/exercises/practice/two-bucket/two-bucket-test.roc @@ -1,6 +1,6 @@ # These tests are auto-generated with test data from: # https://github.com/exercism/problem-specifications/tree/main/exercises/two-bucket/canonical-data.json -# File last updated on 2025-01-04 +# File last updated on 2025-07-26 app [main!] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.19.0/Hj-J_zxz7V9YurCSTFcFdu6cQJie4guzsPMUi5kBYUk.tar.br", } @@ -8,164 +8,132 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line!("") + Stdout.line! "" import TwoBucket exposing [measure] # Measure using bucket one of size 3 and bucket two of size 5 - start with bucket one expect - result = measure( - { - bucket_one: 3, - bucket_two: 5, - goal: 1, - start_bucket: One, - }, - ) - expected = Ok( - { - moves: 4, - goal_bucket: One, - other_bucket: 5, - }, - ) + result = measure { + bucket_one: 3, + bucket_two: 5, + goal: 1, + start_bucket: One, + } + expected = Ok { + moves: 4, + goal_bucket: One, + other_bucket: 5, + } result == expected # Measure using bucket one of size 3 and bucket two of size 5 - start with bucket two expect - result = measure( - { - bucket_one: 3, - bucket_two: 5, - goal: 1, - start_bucket: Two, - }, - ) - expected = Ok( - { - moves: 8, - goal_bucket: Two, - other_bucket: 3, - }, - ) + result = measure { + bucket_one: 3, + bucket_two: 5, + goal: 1, + start_bucket: Two, + } + expected = Ok { + moves: 8, + goal_bucket: Two, + other_bucket: 3, + } result == expected # Measure using bucket one of size 7 and bucket two of size 11 - start with bucket one expect - result = measure( - { - bucket_one: 7, - bucket_two: 11, - goal: 2, - start_bucket: One, - }, - ) - expected = Ok( - { - moves: 14, - goal_bucket: One, - other_bucket: 11, - }, - ) + result = measure { + bucket_one: 7, + bucket_two: 11, + goal: 2, + start_bucket: One, + } + expected = Ok { + moves: 14, + goal_bucket: One, + other_bucket: 11, + } result == expected # Measure using bucket one of size 7 and bucket two of size 11 - start with bucket two expect - result = measure( - { - bucket_one: 7, - bucket_two: 11, - goal: 2, - start_bucket: Two, - }, - ) - expected = Ok( - { - moves: 18, - goal_bucket: Two, - other_bucket: 7, - }, - ) + result = measure { + bucket_one: 7, + bucket_two: 11, + goal: 2, + start_bucket: Two, + } + expected = Ok { + moves: 18, + goal_bucket: Two, + other_bucket: 7, + } result == expected # Measure one step using bucket one of size 1 and bucket two of size 3 - start with bucket two expect - result = measure( - { - bucket_one: 1, - bucket_two: 3, - goal: 3, - start_bucket: Two, - }, - ) - expected = Ok( - { - moves: 1, - goal_bucket: Two, - other_bucket: 0, - }, - ) + result = measure { + bucket_one: 1, + bucket_two: 3, + goal: 3, + start_bucket: Two, + } + expected = Ok { + moves: 1, + goal_bucket: Two, + other_bucket: 0, + } result == expected # Measure using bucket one of size 2 and bucket two of size 3 - start with bucket one and end with bucket two expect - result = measure( - { - bucket_one: 2, - bucket_two: 3, - goal: 3, - start_bucket: One, - }, - ) - expected = Ok( - { - moves: 2, - goal_bucket: Two, - other_bucket: 2, - }, - ) + result = measure { + bucket_one: 2, + bucket_two: 3, + goal: 3, + start_bucket: One, + } + expected = Ok { + moves: 2, + goal_bucket: Two, + other_bucket: 2, + } result == expected # Not possible to reach the goal expect - result = measure( - { - bucket_one: 6, - bucket_two: 15, - goal: 5, - start_bucket: One, - }, - ) + result = measure { + bucket_one: 6, + bucket_two: 15, + goal: 5, + start_bucket: One, + } result |> Result.is_err # With the same buckets but a different goal, then it is possible expect - result = measure( - { - bucket_one: 6, - bucket_two: 15, - goal: 9, - start_bucket: One, - }, - ) - expected = Ok( - { - moves: 10, - goal_bucket: Two, - other_bucket: 0, - }, - ) + result = measure { + bucket_one: 6, + bucket_two: 15, + goal: 9, + start_bucket: One, + } + expected = Ok { + moves: 10, + goal_bucket: Two, + other_bucket: 0, + } result == expected # Goal larger than both buckets is impossible expect - result = measure( - { - bucket_one: 5, - bucket_two: 7, - goal: 8, - start_bucket: One, - }, - ) + result = measure { + bucket_one: 5, + bucket_two: 7, + goal: 8, + start_bucket: One, + } result |> Result.is_err diff --git a/exercises/practice/two-fer/two-fer-test.roc b/exercises/practice/two-fer/two-fer-test.roc index 110915da..c17b71d2 100644 --- a/exercises/practice/two-fer/two-fer-test.roc +++ b/exercises/practice/two-fer/two-fer-test.roc @@ -1,6 +1,6 @@ # These tests are auto-generated with test data from: # https://github.com/exercism/problem-specifications/tree/main/exercises/two-fer/canonical-data.json -# File last updated on 2025-01-04 +# File last updated on 2025-07-26 app [main!] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.19.0/Hj-J_zxz7V9YurCSTFcFdu6cQJie4guzsPMUi5kBYUk.tar.br", } @@ -8,22 +8,22 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line!("") + Stdout.line! "" import TwoFer exposing [two_fer] # no name given expect - result = two_fer(Anonymous) + result = two_fer Anonymous result == "One for you, one for me." # a name given expect - result = two_fer(Name("Alice")) + result = two_fer (Name "Alice") result == "One for Alice, one for me." # another name given expect - result = two_fer(Name("Bob")) + result = two_fer (Name "Bob") result == "One for Bob, one for me." diff --git a/exercises/practice/variable-length-quantity/variable-length-quantity-test.roc b/exercises/practice/variable-length-quantity/variable-length-quantity-test.roc index 2cce6f62..8b56ef85 100644 --- a/exercises/practice/variable-length-quantity/variable-length-quantity-test.roc +++ b/exercises/practice/variable-length-quantity/variable-length-quantity-test.roc @@ -1,6 +1,6 @@ # These tests are auto-generated with test data from: # https://github.com/exercism/problem-specifications/tree/main/exercises/variable-length-quantity/canonical-data.json -# File last updated on 2025-01-04 +# File last updated on 2025-07-26 app [main!] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.19.0/Hj-J_zxz7V9YurCSTFcFdu6cQJie4guzsPMUi5kBYUk.tar.br", } @@ -8,7 +8,7 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line!("") + Stdout.line! "" import VariableLengthQuantity exposing [encode, decode] @@ -19,126 +19,161 @@ import VariableLengthQuantity exposing [encode, decode] # zero expect integers = [0] - result = encode(integers) + result = encode integers expected = [0] result == expected # arbitrary single byte expect integers = [64] - result = encode(integers) + result = encode integers expected = [64] result == expected +# asymmetric single byte +expect + integers = [83] + result = encode integers + expected = [83] + result == expected + # largest single byte expect integers = [127] - result = encode(integers) + result = encode integers expected = [127] result == expected # smallest double byte expect integers = [128] - result = encode(integers) + result = encode integers expected = [129, 0] result == expected # arbitrary double byte expect integers = [8192] - result = encode(integers) + result = encode integers expected = [192, 0] result == expected +# asymmetric double byte +expect + integers = [173] + result = encode integers + expected = [129, 45] + result == expected + # largest double byte expect integers = [16383] - result = encode(integers) + result = encode integers expected = [255, 127] result == expected # smallest triple byte expect integers = [16384] - result = encode(integers) + result = encode integers expected = [129, 128, 0] result == expected # arbitrary triple byte expect integers = [1048576] - result = encode(integers) + result = encode integers expected = [192, 128, 0] result == expected +# asymmetric triple byte +expect + integers = [120220] + result = encode integers + expected = [135, 171, 28] + result == expected + # largest triple byte expect integers = [2097151] - result = encode(integers) + result = encode integers expected = [255, 255, 127] result == expected # smallest quadruple byte expect integers = [2097152] - result = encode(integers) + result = encode integers expected = [129, 128, 128, 0] result == expected # arbitrary quadruple byte expect integers = [134217728] - result = encode(integers) + result = encode integers expected = [192, 128, 128, 0] result == expected +# asymmetric quadruple byte +expect + integers = [3503876] + result = encode integers + expected = [129, 213, 238, 4] + result == expected + # largest quadruple byte expect integers = [268435455] - result = encode(integers) + result = encode integers expected = [255, 255, 255, 127] result == expected # smallest quintuple byte expect integers = [268435456] - result = encode(integers) + result = encode integers expected = [129, 128, 128, 128, 0] result == expected # arbitrary quintuple byte expect integers = [4278190080] - result = encode(integers) + result = encode integers expected = [143, 248, 128, 128, 0] result == expected +# asymmetric quintuple byte +expect + integers = [2254790917] + result = encode integers + expected = [136, 179, 149, 194, 5] + result == expected + # maximum 32-bit integer input expect integers = [4294967295] - result = encode(integers) + result = encode integers expected = [143, 255, 255, 255, 127] result == expected # two single-byte values expect integers = [64, 127] - result = encode(integers) + result = encode integers expected = [64, 127] result == expected # two multi-byte values expect integers = [16384, 1193046] - result = encode(integers) + result = encode integers expected = [129, 128, 0, 200, 232, 86] result == expected # many multi-byte values expect integers = [8192, 1193046, 268435455, 0, 16383, 16384] - result = encode(integers) + result = encode integers expected = [192, 0, 200, 232, 86, 255, 255, 255, 127, 0, 255, 127, 129, 128, 0] result == expected @@ -149,54 +184,54 @@ expect # one byte expect bytes = [127] - result = decode(bytes) - expected = Ok([127]) + result = decode bytes + expected = Ok [127] result == expected # two bytes expect bytes = [192, 0] - result = decode(bytes) - expected = Ok([8192]) + result = decode bytes + expected = Ok [8192] result == expected # three bytes expect bytes = [255, 255, 127] - result = decode(bytes) - expected = Ok([2097151]) + result = decode bytes + expected = Ok [2097151] result == expected # four bytes expect bytes = [129, 128, 128, 0] - result = decode(bytes) - expected = Ok([2097152]) + result = decode bytes + expected = Ok [2097152] result == expected # maximum 32-bit integer expect bytes = [143, 255, 255, 255, 127] - result = decode(bytes) - expected = Ok([4294967295]) + result = decode bytes + expected = Ok [4294967295] result == expected # incomplete sequence causes error expect bytes = [255] - result = decode(bytes) + result = decode bytes result |> Result.is_err # incomplete sequence causes error, even if value is zero expect bytes = [128] - result = decode(bytes) + result = decode bytes result |> Result.is_err # multiple values expect bytes = [192, 0, 200, 232, 86, 255, 255, 255, 127, 0, 255, 127, 129, 128, 0] - result = decode(bytes) - expected = Ok([8192, 1193046, 268435455, 0, 16383, 16384]) + result = decode bytes + expected = Ok [8192, 1193046, 268435455, 0, 16383, 16384] result == expected diff --git a/exercises/practice/word-count/word-count-test.roc b/exercises/practice/word-count/word-count-test.roc index b4aa0a5c..52fd46bb 100644 --- a/exercises/practice/word-count/word-count-test.roc +++ b/exercises/practice/word-count/word-count-test.roc @@ -1,6 +1,6 @@ # These tests are auto-generated with test data from: # https://github.com/exercism/problem-specifications/tree/main/exercises/word-count/canonical-data.json -# File last updated on 2025-01-04 +# File last updated on 2025-07-26 app [main!] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.19.0/Hj-J_zxz7V9YurCSTFcFdu6cQJie4guzsPMUi5kBYUk.tar.br", } @@ -8,187 +8,159 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line!("") + Stdout.line! "" import WordCount exposing [count_words] # count one word expect - result = count_words("word") - expected = Dict.from_list( - [ - ("word", 1), - ], - ) + result = count_words "word" + expected = Dict.from_list [ + ("word", 1), + ] result == expected # count one of each word expect - result = count_words("one of each") - expected = Dict.from_list( - [ - ("one", 1), - ("of", 1), - ("each", 1), - ], - ) + result = count_words "one of each" + expected = Dict.from_list [ + ("one", 1), + ("of", 1), + ("each", 1), + ] result == expected # multiple occurrences of a word expect - result = count_words("one fish two fish red fish blue fish") - expected = Dict.from_list( - [ - ("one", 1), - ("fish", 4), - ("two", 1), - ("red", 1), - ("blue", 1), - ], - ) + result = count_words "one fish two fish red fish blue fish" + expected = Dict.from_list [ + ("one", 1), + ("fish", 4), + ("two", 1), + ("red", 1), + ("blue", 1), + ] result == expected # handles cramped lists expect - result = count_words("one,two,three") - expected = Dict.from_list( - [ - ("one", 1), - ("two", 1), - ("three", 1), - ], - ) + result = count_words "one,two,three" + expected = Dict.from_list [ + ("one", 1), + ("two", 1), + ("three", 1), + ] result == expected # handles expanded lists expect - result = count_words("one,\ntwo,\nthree") - expected = Dict.from_list( - [ - ("one", 1), - ("two", 1), - ("three", 1), - ], - ) + result = count_words "one,\ntwo,\nthree" + expected = Dict.from_list [ + ("one", 1), + ("two", 1), + ("three", 1), + ] result == expected # ignore punctuation expect - result = count_words("car: carpet as java: javascript!!&@$%^&") - expected = Dict.from_list( - [ - ("car", 1), - ("carpet", 1), - ("as", 1), - ("java", 1), - ("javascript", 1), - ], - ) + result = count_words "car: carpet as java: javascript!!&@$%^&" + expected = Dict.from_list [ + ("car", 1), + ("carpet", 1), + ("as", 1), + ("java", 1), + ("javascript", 1), + ] result == expected # include numbers expect - result = count_words("testing, 1, 2 testing") - expected = Dict.from_list( - [ - ("testing", 2), - ("1", 1), - ("2", 1), - ], - ) + result = count_words "testing, 1, 2 testing" + expected = Dict.from_list [ + ("testing", 2), + ("1", 1), + ("2", 1), + ] result == expected # normalize case expect - result = count_words("go Go GO Stop stop") - expected = Dict.from_list( - [ - ("go", 3), - ("stop", 2), - ], - ) + result = count_words "go Go GO Stop stop" + expected = Dict.from_list [ + ("go", 3), + ("stop", 2), + ] result == expected # with apostrophes expect - result = count_words("'First: don't laugh. Then: don't cry. You're getting it.'") - expected = Dict.from_list( - [ - ("first", 1), - ("don't", 2), - ("laugh", 1), - ("then", 1), - ("cry", 1), - ("you're", 1), - ("getting", 1), - ("it", 1), - ], - ) + result = count_words "'First: don't laugh. Then: don't cry. You're getting it.'" + expected = Dict.from_list [ + ("first", 1), + ("don't", 2), + ("laugh", 1), + ("then", 1), + ("cry", 1), + ("you're", 1), + ("getting", 1), + ("it", 1), + ] result == expected # with quotations expect - result = count_words("Joe can't tell between 'large' and large.") - expected = Dict.from_list( - [ - ("joe", 1), - ("can't", 1), - ("tell", 1), - ("between", 1), - ("large", 2), - ("and", 1), - ], - ) + result = count_words "Joe can't tell between 'large' and large." + expected = Dict.from_list [ + ("joe", 1), + ("can't", 1), + ("tell", 1), + ("between", 1), + ("large", 2), + ("and", 1), + ] result == expected # substrings from the beginning expect - result = count_words("Joe can't tell between app, apple and a.") - expected = Dict.from_list( - [ - ("joe", 1), - ("can't", 1), - ("tell", 1), - ("between", 1), - ("app", 1), - ("apple", 1), - ("and", 1), - ("a", 1), - ], - ) + result = count_words "Joe can't tell between app, apple and a." + expected = Dict.from_list [ + ("joe", 1), + ("can't", 1), + ("tell", 1), + ("between", 1), + ("app", 1), + ("apple", 1), + ("and", 1), + ("a", 1), + ] result == expected # multiple spaces not detected as a word expect - result = count_words(" multiple whitespaces") - expected = Dict.from_list( - [ - ("multiple", 1), - ("whitespaces", 1), - ], - ) + result = count_words " multiple whitespaces" + expected = Dict.from_list [ + ("multiple", 1), + ("whitespaces", 1), + ] result == expected # alternating word separators not detected as a word expect - result = count_words(",\n,one,\n ,two \n 'three'") - expected = Dict.from_list( - [ - ("one", 1), - ("two", 1), - ("three", 1), - ], - ) + result = count_words ",\n,one,\n ,two \n 'three'" + expected = Dict.from_list [ + ("one", 1), + ("two", 1), + ("three", 1), + ] result == expected # quotation for word with apostrophe expect - result = count_words("can, can't, 'can't'") - expected = Dict.from_list( - [ - ("can", 1), - ("can't", 2), - ], - ) + result = count_words "can, can't, 'can't'" + expected = Dict.from_list [ + ("can", 1), + ("can't", 2), + ] result == expected diff --git a/exercises/practice/word-search/word-search-test.roc b/exercises/practice/word-search/word-search-test.roc index bd565ae7..7a7bc632 100644 --- a/exercises/practice/word-search/word-search-test.roc +++ b/exercises/practice/word-search/word-search-test.roc @@ -1,6 +1,6 @@ # These tests are auto-generated with test data from: # https://github.com/exercism/problem-specifications/tree/main/exercises/word-search/canonical-data.json -# File last updated on 2025-01-04 +# File last updated on 2025-07-26 app [main!] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.19.0/Hj-J_zxz7V9YurCSTFcFdu6cQJie4guzsPMUi5kBYUk.tar.br", } @@ -8,7 +8,7 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line!("") + Stdout.line! "" import WordSearch exposing [search] @@ -16,60 +16,50 @@ import WordSearch exposing [search] expect grid = "jefblpepre" words_to_search_for = ["clojure"] - result = grid |> search(words_to_search_for) - expected = Dict.from_list( - [ - # "clojure" is not in the grid - ], - ) + result = grid |> search words_to_search_for + expected = Dict.from_list [ + # "clojure" is not in the grid + ] result == expected # Should locate one word written left to right expect grid = "clojurermt" words_to_search_for = ["clojure"] - result = grid |> search(words_to_search_for) - expected = Dict.from_list( - [ - ("clojure", { start: { column: 1, row: 1 }, end: { column: 7, row: 1 } }), - ], - ) + result = grid |> search words_to_search_for + expected = Dict.from_list [ + ("clojure", { start: { column: 1, row: 1 }, end: { column: 7, row: 1 } }), + ] result == expected # Should locate the same word written left to right in a different position expect grid = "mtclojurer" words_to_search_for = ["clojure"] - result = grid |> search(words_to_search_for) - expected = Dict.from_list( - [ - ("clojure", { start: { column: 3, row: 1 }, end: { column: 9, row: 1 } }), - ], - ) + result = grid |> search words_to_search_for + expected = Dict.from_list [ + ("clojure", { start: { column: 3, row: 1 }, end: { column: 9, row: 1 } }), + ] result == expected # Should locate a different left to right word expect grid = "coffeelplx" words_to_search_for = ["coffee"] - result = grid |> search(words_to_search_for) - expected = Dict.from_list( - [ - ("coffee", { start: { column: 1, row: 1 }, end: { column: 6, row: 1 } }), - ], - ) + result = grid |> search words_to_search_for + expected = Dict.from_list [ + ("coffee", { start: { column: 1, row: 1 }, end: { column: 6, row: 1 } }), + ] result == expected # Should locate that different left to right word in a different position expect grid = "xcoffeezlp" words_to_search_for = ["coffee"] - result = grid |> search(words_to_search_for) - expected = Dict.from_list( - [ - ("coffee", { start: { column: 2, row: 1 }, end: { column: 7, row: 1 } }), - ], - ) + result = grid |> search words_to_search_for + expected = Dict.from_list [ + ("coffee", { start: { column: 2, row: 1 }, end: { column: 7, row: 1 } }), + ] result == expected # Should locate a left to right word in two line grid @@ -80,12 +70,10 @@ expect tclojurerm """ words_to_search_for = ["clojure"] - result = grid |> search(words_to_search_for) - expected = Dict.from_list( - [ - ("clojure", { start: { column: 2, row: 2 }, end: { column: 8, row: 2 } }), - ], - ) + result = grid |> search words_to_search_for + expected = Dict.from_list [ + ("clojure", { start: { column: 2, row: 2 }, end: { column: 8, row: 2 } }), + ] result == expected # Should locate a left to right word in three line grid @@ -97,12 +85,10 @@ expect clojurermt """ words_to_search_for = ["clojure"] - result = grid |> search(words_to_search_for) - expected = Dict.from_list( - [ - ("clojure", { start: { column: 1, row: 3 }, end: { column: 7, row: 3 } }), - ], - ) + result = grid |> search words_to_search_for + expected = Dict.from_list [ + ("clojure", { start: { column: 1, row: 3 }, end: { column: 7, row: 3 } }), + ] result == expected # Should locate a left to right word in ten line grid @@ -121,12 +107,10 @@ expect clojurermt """ words_to_search_for = ["clojure"] - result = grid |> search(words_to_search_for) - expected = Dict.from_list( - [ - ("clojure", { start: { column: 1, row: 10 }, end: { column: 7, row: 10 } }), - ], - ) + result = grid |> search words_to_search_for + expected = Dict.from_list [ + ("clojure", { start: { column: 1, row: 10 }, end: { column: 7, row: 10 } }), + ] result == expected # Should locate that left to right word in a different position in a ten line grid @@ -145,12 +129,10 @@ expect jalaycalmp """ words_to_search_for = ["clojure"] - result = grid |> search(words_to_search_for) - expected = Dict.from_list( - [ - ("clojure", { start: { column: 1, row: 9 }, end: { column: 7, row: 9 } }), - ], - ) + result = grid |> search words_to_search_for + expected = Dict.from_list [ + ("clojure", { start: { column: 1, row: 9 }, end: { column: 7, row: 9 } }), + ] result == expected # Should locate a different left to right word in a ten line grid @@ -169,12 +151,10 @@ expect jalaycalmp """ words_to_search_for = ["fortran"] - result = grid |> search(words_to_search_for) - expected = Dict.from_list( - [ - ("fortran", { start: { column: 1, row: 7 }, end: { column: 7, row: 7 } }), - ], - ) + result = grid |> search words_to_search_for + expected = Dict.from_list [ + ("fortran", { start: { column: 1, row: 7 }, end: { column: 7, row: 7 } }), + ] result == expected # Should locate multiple words @@ -193,25 +173,21 @@ expect clojurermt """ words_to_search_for = ["fortran", "clojure"] - result = grid |> search(words_to_search_for) - expected = Dict.from_list( - [ - ("clojure", { start: { column: 1, row: 10 }, end: { column: 7, row: 10 } }), - ("fortran", { start: { column: 1, row: 7 }, end: { column: 7, row: 7 } }), - ], - ) + result = grid |> search words_to_search_for + expected = Dict.from_list [ + ("clojure", { start: { column: 1, row: 10 }, end: { column: 7, row: 10 } }), + ("fortran", { start: { column: 1, row: 7 }, end: { column: 7, row: 7 } }), + ] result == expected # Should locate a single word written right to left expect grid = "rixilelhrs" words_to_search_for = ["elixir"] - result = grid |> search(words_to_search_for) - expected = Dict.from_list( - [ - ("elixir", { start: { column: 6, row: 1 }, end: { column: 1, row: 1 } }), - ], - ) + result = grid |> search words_to_search_for + expected = Dict.from_list [ + ("elixir", { start: { column: 6, row: 1 }, end: { column: 1, row: 1 } }), + ] result == expected # Should locate multiple words written in different horizontal directions @@ -230,13 +206,11 @@ expect clojurermt """ words_to_search_for = ["elixir", "clojure"] - result = grid |> search(words_to_search_for) - expected = Dict.from_list( - [ - ("clojure", { start: { column: 1, row: 10 }, end: { column: 7, row: 10 } }), - ("elixir", { start: { column: 6, row: 5 }, end: { column: 1, row: 5 } }), - ], - ) + result = grid |> search words_to_search_for + expected = Dict.from_list [ + ("clojure", { start: { column: 1, row: 10 }, end: { column: 7, row: 10 } }), + ("elixir", { start: { column: 6, row: 5 }, end: { column: 1, row: 5 } }), + ] result == expected # Should locate words written top to bottom @@ -255,14 +229,12 @@ expect clojurermt """ words_to_search_for = ["clojure", "elixir", "ecmascript"] - result = grid |> search(words_to_search_for) - expected = Dict.from_list( - [ - ("clojure", { start: { column: 1, row: 10 }, end: { column: 7, row: 10 } }), - ("elixir", { start: { column: 6, row: 5 }, end: { column: 1, row: 5 } }), - ("ecmascript", { start: { column: 10, row: 1 }, end: { column: 10, row: 10 } }), - ], - ) + result = grid |> search words_to_search_for + expected = Dict.from_list [ + ("clojure", { start: { column: 1, row: 10 }, end: { column: 7, row: 10 } }), + ("elixir", { start: { column: 6, row: 5 }, end: { column: 1, row: 5 } }), + ("ecmascript", { start: { column: 10, row: 1 }, end: { column: 10, row: 10 } }), + ] result == expected # Should locate words written bottom to top @@ -281,15 +253,13 @@ expect clojurermt """ words_to_search_for = ["clojure", "elixir", "ecmascript", "rust"] - result = grid |> search(words_to_search_for) - expected = Dict.from_list( - [ - ("clojure", { start: { column: 1, row: 10 }, end: { column: 7, row: 10 } }), - ("elixir", { start: { column: 6, row: 5 }, end: { column: 1, row: 5 } }), - ("ecmascript", { start: { column: 10, row: 1 }, end: { column: 10, row: 10 } }), - ("rust", { start: { column: 9, row: 5 }, end: { column: 9, row: 2 } }), - ], - ) + result = grid |> search words_to_search_for + expected = Dict.from_list [ + ("clojure", { start: { column: 1, row: 10 }, end: { column: 7, row: 10 } }), + ("elixir", { start: { column: 6, row: 5 }, end: { column: 1, row: 5 } }), + ("ecmascript", { start: { column: 10, row: 1 }, end: { column: 10, row: 10 } }), + ("rust", { start: { column: 9, row: 5 }, end: { column: 9, row: 2 } }), + ] result == expected # Should locate words written top left to bottom right @@ -308,16 +278,14 @@ expect clojurermt """ words_to_search_for = ["clojure", "elixir", "ecmascript", "rust", "java"] - result = grid |> search(words_to_search_for) - expected = Dict.from_list( - [ - ("clojure", { start: { column: 1, row: 10 }, end: { column: 7, row: 10 } }), - ("elixir", { start: { column: 6, row: 5 }, end: { column: 1, row: 5 } }), - ("ecmascript", { start: { column: 10, row: 1 }, end: { column: 10, row: 10 } }), - ("rust", { start: { column: 9, row: 5 }, end: { column: 9, row: 2 } }), - ("java", { start: { column: 1, row: 1 }, end: { column: 4, row: 4 } }), - ], - ) + result = grid |> search words_to_search_for + expected = Dict.from_list [ + ("clojure", { start: { column: 1, row: 10 }, end: { column: 7, row: 10 } }), + ("elixir", { start: { column: 6, row: 5 }, end: { column: 1, row: 5 } }), + ("ecmascript", { start: { column: 10, row: 1 }, end: { column: 10, row: 10 } }), + ("rust", { start: { column: 9, row: 5 }, end: { column: 9, row: 2 } }), + ("java", { start: { column: 1, row: 1 }, end: { column: 4, row: 4 } }), + ] result == expected # Should locate words written bottom right to top left @@ -336,17 +304,15 @@ expect clojurermt """ words_to_search_for = ["clojure", "elixir", "ecmascript", "rust", "java", "lua"] - result = grid |> search(words_to_search_for) - expected = Dict.from_list( - [ - ("clojure", { start: { column: 1, row: 10 }, end: { column: 7, row: 10 } }), - ("elixir", { start: { column: 6, row: 5 }, end: { column: 1, row: 5 } }), - ("ecmascript", { start: { column: 10, row: 1 }, end: { column: 10, row: 10 } }), - ("rust", { start: { column: 9, row: 5 }, end: { column: 9, row: 2 } }), - ("java", { start: { column: 1, row: 1 }, end: { column: 4, row: 4 } }), - ("lua", { start: { column: 8, row: 9 }, end: { column: 6, row: 7 } }), - ], - ) + result = grid |> search words_to_search_for + expected = Dict.from_list [ + ("clojure", { start: { column: 1, row: 10 }, end: { column: 7, row: 10 } }), + ("elixir", { start: { column: 6, row: 5 }, end: { column: 1, row: 5 } }), + ("ecmascript", { start: { column: 10, row: 1 }, end: { column: 10, row: 10 } }), + ("rust", { start: { column: 9, row: 5 }, end: { column: 9, row: 2 } }), + ("java", { start: { column: 1, row: 1 }, end: { column: 4, row: 4 } }), + ("lua", { start: { column: 8, row: 9 }, end: { column: 6, row: 7 } }), + ] result == expected # Should locate words written bottom left to top right @@ -365,18 +331,16 @@ expect clojurermt """ words_to_search_for = ["clojure", "elixir", "ecmascript", "rust", "java", "lua", "lisp"] - result = grid |> search(words_to_search_for) - expected = Dict.from_list( - [ - ("clojure", { start: { column: 1, row: 10 }, end: { column: 7, row: 10 } }), - ("elixir", { start: { column: 6, row: 5 }, end: { column: 1, row: 5 } }), - ("ecmascript", { start: { column: 10, row: 1 }, end: { column: 10, row: 10 } }), - ("rust", { start: { column: 9, row: 5 }, end: { column: 9, row: 2 } }), - ("java", { start: { column: 1, row: 1 }, end: { column: 4, row: 4 } }), - ("lua", { start: { column: 8, row: 9 }, end: { column: 6, row: 7 } }), - ("lisp", { start: { column: 3, row: 6 }, end: { column: 6, row: 3 } }), - ], - ) + result = grid |> search words_to_search_for + expected = Dict.from_list [ + ("clojure", { start: { column: 1, row: 10 }, end: { column: 7, row: 10 } }), + ("elixir", { start: { column: 6, row: 5 }, end: { column: 1, row: 5 } }), + ("ecmascript", { start: { column: 10, row: 1 }, end: { column: 10, row: 10 } }), + ("rust", { start: { column: 9, row: 5 }, end: { column: 9, row: 2 } }), + ("java", { start: { column: 1, row: 1 }, end: { column: 4, row: 4 } }), + ("lua", { start: { column: 8, row: 9 }, end: { column: 6, row: 7 } }), + ("lisp", { start: { column: 3, row: 6 }, end: { column: 6, row: 3 } }), + ] result == expected # Should locate words written top right to bottom left @@ -395,19 +359,17 @@ expect clojurermt """ words_to_search_for = ["clojure", "elixir", "ecmascript", "rust", "java", "lua", "lisp", "ruby"] - result = grid |> search(words_to_search_for) - expected = Dict.from_list( - [ - ("clojure", { start: { column: 1, row: 10 }, end: { column: 7, row: 10 } }), - ("elixir", { start: { column: 6, row: 5 }, end: { column: 1, row: 5 } }), - ("ecmascript", { start: { column: 10, row: 1 }, end: { column: 10, row: 10 } }), - ("rust", { start: { column: 9, row: 5 }, end: { column: 9, row: 2 } }), - ("java", { start: { column: 1, row: 1 }, end: { column: 4, row: 4 } }), - ("lua", { start: { column: 8, row: 9 }, end: { column: 6, row: 7 } }), - ("lisp", { start: { column: 3, row: 6 }, end: { column: 6, row: 3 } }), - ("ruby", { start: { column: 8, row: 6 }, end: { column: 5, row: 9 } }), - ], - ) + result = grid |> search words_to_search_for + expected = Dict.from_list [ + ("clojure", { start: { column: 1, row: 10 }, end: { column: 7, row: 10 } }), + ("elixir", { start: { column: 6, row: 5 }, end: { column: 1, row: 5 } }), + ("ecmascript", { start: { column: 10, row: 1 }, end: { column: 10, row: 10 } }), + ("rust", { start: { column: 9, row: 5 }, end: { column: 9, row: 2 } }), + ("java", { start: { column: 1, row: 1 }, end: { column: 4, row: 4 } }), + ("lua", { start: { column: 8, row: 9 }, end: { column: 6, row: 7 } }), + ("lisp", { start: { column: 3, row: 6 }, end: { column: 6, row: 3 } }), + ("ruby", { start: { column: 8, row: 6 }, end: { column: 5, row: 9 } }), + ] result == expected # Should fail to locate a word that is not in the puzzle @@ -426,20 +388,18 @@ expect clojurermt """ words_to_search_for = ["clojure", "elixir", "ecmascript", "rust", "java", "lua", "lisp", "ruby", "haskell"] - result = grid |> search(words_to_search_for) - expected = Dict.from_list( - [ - ("clojure", { start: { column: 1, row: 10 }, end: { column: 7, row: 10 } }), - ("elixir", { start: { column: 6, row: 5 }, end: { column: 1, row: 5 } }), - ("ecmascript", { start: { column: 10, row: 1 }, end: { column: 10, row: 10 } }), - ("rust", { start: { column: 9, row: 5 }, end: { column: 9, row: 2 } }), - ("java", { start: { column: 1, row: 1 }, end: { column: 4, row: 4 } }), - ("lua", { start: { column: 8, row: 9 }, end: { column: 6, row: 7 } }), - ("lisp", { start: { column: 3, row: 6 }, end: { column: 6, row: 3 } }), - ("ruby", { start: { column: 8, row: 6 }, end: { column: 5, row: 9 } }), - # "haskell" is not in the grid - ], - ) + result = grid |> search words_to_search_for + expected = Dict.from_list [ + ("clojure", { start: { column: 1, row: 10 }, end: { column: 7, row: 10 } }), + ("elixir", { start: { column: 6, row: 5 }, end: { column: 1, row: 5 } }), + ("ecmascript", { start: { column: 10, row: 1 }, end: { column: 10, row: 10 } }), + ("rust", { start: { column: 9, row: 5 }, end: { column: 9, row: 2 } }), + ("java", { start: { column: 1, row: 1 }, end: { column: 4, row: 4 } }), + ("lua", { start: { column: 8, row: 9 }, end: { column: 6, row: 7 } }), + ("lisp", { start: { column: 3, row: 6 }, end: { column: 6, row: 3 } }), + ("ruby", { start: { column: 8, row: 6 }, end: { column: 5, row: 9 } }), + # "haskell" is not in the grid + ] result == expected # Should fail to locate words that are not on horizontal, vertical, or diagonal lines @@ -450,15 +410,13 @@ expect def """ words_to_search_for = ["aef", "ced", "abf", "cbd"] - result = grid |> search(words_to_search_for) - expected = Dict.from_list( - [ - # "aef" is not in the grid - # "ced" is not in the grid - # "abf" is not in the grid - # "cbd" is not in the grid - ], - ) + result = grid |> search words_to_search_for + expected = Dict.from_list [ + # "aef" is not in the grid + # "ced" is not in the grid + # "abf" is not in the grid + # "cbd" is not in the grid + ] result == expected # Should not concatenate different lines to find a horizontal word @@ -469,24 +427,20 @@ expect xirdfg """ words_to_search_for = ["elixir"] - result = grid |> search(words_to_search_for) - expected = Dict.from_list( - [ - # "elixir" is not in the grid - ], - ) + result = grid |> search words_to_search_for + expected = Dict.from_list [ + # "elixir" is not in the grid + ] result == expected # Should not wrap around horizontally to find a word expect grid = "silabcdefp" words_to_search_for = ["lisp"] - result = grid |> search(words_to_search_for) - expected = Dict.from_list( - [ - # "lisp" is not in the grid - ], - ) + result = grid |> search words_to_search_for + expected = Dict.from_list [ + # "lisp" is not in the grid + ] result == expected # Should not wrap around vertically to find a word @@ -502,11 +456,9 @@ expect t """ words_to_search_for = ["rust"] - result = grid |> search(words_to_search_for) - expected = Dict.from_list( - [ - # "rust" is not in the grid - ], - ) + result = grid |> search words_to_search_for + expected = Dict.from_list [ + # "rust" is not in the grid + ] result == expected diff --git a/exercises/practice/wordy/wordy-test.roc b/exercises/practice/wordy/wordy-test.roc index 75ac7e10..e556470d 100644 --- a/exercises/practice/wordy/wordy-test.roc +++ b/exercises/practice/wordy/wordy-test.roc @@ -1,6 +1,6 @@ # These tests are auto-generated with test data from: # https://github.com/exercism/problem-specifications/tree/main/exercises/wordy/canonical-data.json -# File last updated on 2025-01-04 +# File last updated on 2025-07-26 app [main!] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.19.0/Hj-J_zxz7V9YurCSTFcFdu6cQJie4guzsPMUi5kBYUk.tar.br", } @@ -8,122 +8,142 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line!("") + Stdout.line! "" import Wordy exposing [answer] # just a number expect - result = answer("What is 5?") - result == Ok(5) + result = answer "What is 5?" + result == Ok 5 + +# just a zero +expect + result = answer "What is 0?" + result == Ok 0 + +# just a negative number +expect + result = answer "What is -123?" + result == Ok -123 # addition expect - result = answer("What is 1 plus 1?") - result == Ok(2) + result = answer "What is 1 plus 1?" + result == Ok 2 + +# addition with a left hand zero +expect + result = answer "What is 0 plus 2?" + result == Ok 2 + +# addition with a right hand zero +expect + result = answer "What is 3 plus 0?" + result == Ok 3 # more addition expect - result = answer("What is 53 plus 2?") - result == Ok(55) + result = answer "What is 53 plus 2?" + result == Ok 55 # addition with negative numbers expect - result = answer("What is -1 plus -10?") - result == Ok(-11) + result = answer "What is -1 plus -10?" + result == Ok -11 # large addition expect - result = answer("What is 123 plus 45678?") - result == Ok(45801) + result = answer "What is 123 plus 45678?" + result == Ok 45801 # subtraction expect - result = answer("What is 4 minus -12?") - result == Ok(16) + result = answer "What is 4 minus -12?" + result == Ok 16 # multiplication expect - result = answer("What is -3 multiplied by 25?") - result == Ok(-75) + result = answer "What is -3 multiplied by 25?" + result == Ok -75 # division expect - result = answer("What is 33 divided by -3?") - result == Ok(-11) + result = answer "What is 33 divided by -3?" + result == Ok -11 # multiple additions expect - result = answer("What is 1 plus 1 plus 1?") - result == Ok(3) + result = answer "What is 1 plus 1 plus 1?" + result == Ok 3 # addition and subtraction expect - result = answer("What is 1 plus 5 minus -2?") - result == Ok(8) + result = answer "What is 1 plus 5 minus -2?" + result == Ok 8 # multiple subtraction expect - result = answer("What is 20 minus 4 minus 13?") - result == Ok(3) + result = answer "What is 20 minus 4 minus 13?" + result == Ok 3 # subtraction then addition expect - result = answer("What is 17 minus 6 plus 3?") - result == Ok(14) + result = answer "What is 17 minus 6 plus 3?" + result == Ok 14 # multiple multiplication expect - result = answer("What is 2 multiplied by -2 multiplied by 3?") - result == Ok(-12) + result = answer "What is 2 multiplied by -2 multiplied by 3?" + result == Ok -12 # addition and multiplication expect - result = answer("What is -3 plus 7 multiplied by -2?") - result == Ok(-8) + result = answer "What is -3 plus 7 multiplied by -2?" + result == Ok -8 # multiple division expect - result = answer("What is -12 divided by 2 divided by -3?") - result == Ok(2) + result = answer "What is -12 divided by 2 divided by -3?" + result == Ok 2 # unknown operation expect - result = answer("What is 52 cubed?") - Result.is_err(result) + result = answer "What is 52 cubed?" + Result.is_err result # Non math question expect - result = answer("Who is the President of the United States?") - Result.is_err(result) + result = answer "Who is the President of the United States?" + Result.is_err result # reject problem missing an operand expect - result = answer("What is 1 plus?") - Result.is_err(result) + result = answer "What is 1 plus?" + Result.is_err result # reject problem with no operands or operators expect - result = answer("What is?") - Result.is_err(result) + result = answer "What is?" + Result.is_err result # reject two operations in a row expect - result = answer("What is 1 plus plus 2?") - Result.is_err(result) + result = answer "What is 1 plus plus 2?" + Result.is_err result # reject two numbers in a row expect - result = answer("What is 1 plus 2 1?") - Result.is_err(result) + result = answer "What is 1 plus 2 1?" + Result.is_err result # reject postfix notation expect - result = answer("What is 1 2 plus?") - Result.is_err(result) + result = answer "What is 1 2 plus?" + Result.is_err result # reject prefix notation expect - result = answer("What is plus 1 2?") - Result.is_err(result) + result = answer "What is plus 1 2?" + Result.is_err result diff --git a/exercises/practice/yacht/yacht-test.roc b/exercises/practice/yacht/yacht-test.roc index 1b86e9c6..c51a9066 100644 --- a/exercises/practice/yacht/yacht-test.roc +++ b/exercises/practice/yacht/yacht-test.roc @@ -1,6 +1,6 @@ # These tests are auto-generated with test data from: # https://github.com/exercism/problem-specifications/tree/main/exercises/yacht/canonical-data.json -# File last updated on 2025-01-04 +# File last updated on 2025-07-26 app [main!] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.19.0/Hj-J_zxz7V9YurCSTFcFdu6cQJie4guzsPMUi5kBYUk.tar.br", } @@ -8,152 +8,152 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line!("") + Stdout.line! "" import Yacht exposing [score] # Yacht expect - result = [5, 5, 5, 5, 5] |> score(Yacht) + result = [5, 5, 5, 5, 5] |> score Yacht result == 50 # Not Yacht expect - result = [1, 3, 3, 2, 5] |> score(Yacht) + result = [1, 3, 3, 2, 5] |> score Yacht result == 0 # Ones expect - result = [1, 1, 1, 3, 5] |> score(Ones) + result = [1, 1, 1, 3, 5] |> score Ones result == 3 # Ones, out of order expect - result = [3, 1, 1, 5, 1] |> score(Ones) + result = [3, 1, 1, 5, 1] |> score Ones result == 3 # No ones expect - result = [4, 3, 6, 5, 5] |> score(Ones) + result = [4, 3, 6, 5, 5] |> score Ones result == 0 # Twos expect - result = [2, 3, 4, 5, 6] |> score(Twos) + result = [2, 3, 4, 5, 6] |> score Twos result == 2 # Fours expect - result = [1, 4, 1, 4, 1] |> score(Fours) + result = [1, 4, 1, 4, 1] |> score Fours result == 8 # Yacht counted as threes expect - result = [3, 3, 3, 3, 3] |> score(Threes) + result = [3, 3, 3, 3, 3] |> score Threes result == 15 # Yacht of 3s counted as fives expect - result = [3, 3, 3, 3, 3] |> score(Fives) + result = [3, 3, 3, 3, 3] |> score Fives result == 0 # Fives expect - result = [1, 5, 3, 5, 3] |> score(Fives) + result = [1, 5, 3, 5, 3] |> score Fives result == 10 # Sixes expect - result = [2, 3, 4, 5, 6] |> score(Sixes) + result = [2, 3, 4, 5, 6] |> score Sixes result == 6 # Full house two small, three big expect - result = [2, 2, 4, 4, 4] |> score(FullHouse) + result = [2, 2, 4, 4, 4] |> score FullHouse result == 16 # Full house three small, two big expect - result = [5, 3, 3, 5, 3] |> score(FullHouse) + result = [5, 3, 3, 5, 3] |> score FullHouse result == 19 # Two pair is not a full house expect - result = [2, 2, 4, 4, 5] |> score(FullHouse) + result = [2, 2, 4, 4, 5] |> score FullHouse result == 0 # Four of a kind is not a full house expect - result = [1, 4, 4, 4, 4] |> score(FullHouse) + result = [1, 4, 4, 4, 4] |> score FullHouse result == 0 # Yacht is not a full house expect - result = [2, 2, 2, 2, 2] |> score(FullHouse) + result = [2, 2, 2, 2, 2] |> score FullHouse result == 0 # Four of a Kind expect - result = [6, 6, 4, 6, 6] |> score(FourOfAKind) + result = [6, 6, 4, 6, 6] |> score FourOfAKind result == 24 # Yacht can be scored as Four of a Kind expect - result = [3, 3, 3, 3, 3] |> score(FourOfAKind) + result = [3, 3, 3, 3, 3] |> score FourOfAKind result == 12 # Full house is not Four of a Kind expect - result = [3, 3, 3, 5, 5] |> score(FourOfAKind) + result = [3, 3, 3, 5, 5] |> score FourOfAKind result == 0 # Little Straight expect - result = [3, 5, 4, 1, 2] |> score(LittleStraight) + result = [3, 5, 4, 1, 2] |> score LittleStraight result == 30 # Little Straight as Big Straight expect - result = [1, 2, 3, 4, 5] |> score(BigStraight) + result = [1, 2, 3, 4, 5] |> score BigStraight result == 0 # Four in order but not a little straight expect - result = [1, 1, 2, 3, 4] |> score(LittleStraight) + result = [1, 1, 2, 3, 4] |> score LittleStraight result == 0 # No pairs but not a little straight expect - result = [1, 2, 3, 4, 6] |> score(LittleStraight) + result = [1, 2, 3, 4, 6] |> score LittleStraight result == 0 # Minimum is 1, maximum is 5, but not a little straight expect - result = [1, 1, 3, 4, 5] |> score(LittleStraight) + result = [1, 1, 3, 4, 5] |> score LittleStraight result == 0 # Big Straight expect - result = [4, 6, 2, 5, 3] |> score(BigStraight) + result = [4, 6, 2, 5, 3] |> score BigStraight result == 30 # Big Straight as little straight expect - result = [6, 5, 4, 3, 2] |> score(LittleStraight) + result = [6, 5, 4, 3, 2] |> score LittleStraight result == 0 # No pairs but not a big straight expect - result = [6, 5, 4, 3, 1] |> score(BigStraight) + result = [6, 5, 4, 3, 1] |> score BigStraight result == 0 # Choice expect - result = [3, 3, 5, 6, 6] |> score(Choice) + result = [3, 3, 5, 6, 6] |> score Choice result == 23 # Yacht as choice expect - result = [2, 2, 2, 2, 2] |> score(Choice) + result = [2, 2, 2, 2, 2] |> score Choice result == 10 diff --git a/exercises/practice/zebra-puzzle/zebra-puzzle-test.roc b/exercises/practice/zebra-puzzle/zebra-puzzle-test.roc index 984e556a..ac83904a 100644 --- a/exercises/practice/zebra-puzzle/zebra-puzzle-test.roc +++ b/exercises/practice/zebra-puzzle/zebra-puzzle-test.roc @@ -1,6 +1,6 @@ # These tests are auto-generated with test data from: # https://github.com/exercism/problem-specifications/tree/main/exercises/zebra-puzzle/canonical-data.json -# File last updated on 2025-01-04 +# File last updated on 2025-07-26 app [main!] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.19.0/Hj-J_zxz7V9YurCSTFcFdu6cQJie4guzsPMUi5kBYUk.tar.br", } @@ -8,17 +8,17 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line!("") + Stdout.line! "" import ZebraPuzzle exposing [owns_zebra, drinks_water] # resident who drinks water expect result = drinks_water - result == Ok(Norwegian) + result == Ok Norwegian # resident who owns zebra expect result = owns_zebra - result == Ok(Japanese) + result == Ok Japanese From dbcdc055e292fe38ee8e5df0108bc830fbbe7dbc Mon Sep 17 00:00:00 2001 From: Anton-4 <17049058+Anton-4@users.noreply.github.com> Date: Sat, 26 Jul 2025 18:18:04 +0200 Subject: [PATCH 3/8] corrections + syntax updates --- bin/add-exercise | 2 +- config/generator_macros.j2 | 2 +- .../practice/accumulate/.meta/template.j2 | 10 +- .../practice/accumulate/accumulate-test.roc | 31 +- exercises/practice/acronym/.meta/template.j2 | 2 +- exercises/practice/acronym/acronym-test.roc | 20 +- .../affine-cipher/affine-cipher-test.roc | 2 +- .../practice/all-your-base/.meta/template.j2 | 4 +- .../all-your-base/all-your-base-test.roc | 60 +- .../practice/allergies/allergies-test.roc | 2 +- .../practice/alphametics/.meta/template.j2 | 2 +- .../practice/alphametics/alphametics-test.roc | 22 +- exercises/practice/anagram/.meta/template.j2 | 2 +- exercises/practice/anagram/anagram-test.roc | 36 +- .../armstrong-numbers/.meta/template.j2 | 2 +- .../armstrong-numbers-test.roc | 20 +- .../atbash-cipher/atbash-cipher-test.roc | 2 +- .../binary-search-tree-test.roc | 2 +- .../practice/binary-search/.meta/template.j2 | 2 +- .../binary-search/binary-search-test.roc | 24 +- exercises/practice/binary/.meta/template.j2 | 2 +- exercises/practice/binary/binary-test.roc | 32 +- exercises/practice/bob/.meta/template.j2 | 2 +- exercises/practice/bob/bob-test.roc | 52 +- exercises/practice/bowling/.meta/template.j2 | 8 +- exercises/practice/bowling/bowling-test.roc | 94 +- exercises/practice/change/.meta/template.j2 | 2 +- exercises/practice/change/change-test.roc | 26 +- .../circular-buffer/.meta/template.j2 | 4 +- .../circular-buffer/circular-buffer-test.roc | 2 +- exercises/practice/clock/.meta/template.j2 | 2 +- exercises/practice/clock/clock-test.roc | 42 +- .../collatz-conjecture/.meta/template.j2 | 2 +- .../collatz-conjecture-test.roc | 12 +- .../complex-numbers/complex-numbers-test.roc | 2 +- exercises/practice/connect/connect-test.roc | 2 +- .../practice/crypto-square/.meta/template.j2 | 4 +- .../crypto-square/crypto-square-test.roc | 34 +- .../practice/custom-set/custom-set-test.roc | 2 +- exercises/practice/darts/.meta/template.j2 | 2 +- exercises/practice/darts/darts-test.roc | 28 +- exercises/practice/diamond/.meta/template.j2 | 4 +- exercises/practice/diamond/diamond-test.roc | 22 +- .../difference-of-squares/.meta/template.j2 | 2 +- .../difference-of-squares-test.roc | 20 +- exercises/practice/dominoes/dominoes-test.roc | 2 +- .../practice/eliuds-eggs/.meta/template.j2 | 2 +- .../practice/eliuds-eggs/eliuds-eggs-test.roc | 10 +- exercises/practice/etl/etl-test.roc | 2 +- .../practice/flatten-array/.meta/template.j2 | 2 +- .../flatten-array/flatten-array-test.roc | 239 ++- .../practice/flower-field/.meta/template.j2 | 6 +- .../flower-field/flower-field-test.roc | 74 +- .../practice/food-chain/.meta/template.j2 | 2 +- .../practice/food-chain/food-chain-test.roc | 22 +- exercises/practice/forth/forth-test.roc | 2 +- .../practice/gigasecond/.meta/template.j2 | 2 +- .../practice/gigasecond/gigasecond-test.roc | 12 +- .../practice/go-counting/go-counting-test.roc | 2 +- exercises/practice/grains/grains-test.roc | 2 +- exercises/practice/grep/.meta/template.j2 | 4 +- exercises/practice/grep/grep-test.roc | 138 +- exercises/practice/hamming/.meta/template.j2 | 6 +- exercises/practice/hamming/hamming-test.roc | 38 +- .../practice/hello-world/hello-world-test.roc | 2 +- .../practice/high-scores/.meta/template.j2 | 2 +- .../practice/high-scores/high-scores-test.roc | 16 +- exercises/practice/house/.meta/template.j2 | 2 +- exercises/practice/house/house-test.roc | 30 +- .../practice/isbn-verifier/.meta/template.j2 | 2 +- .../isbn-verifier/isbn-verifier-test.roc | 40 +- exercises/practice/isogram/.meta/template.j2 | 2 +- exercises/practice/isogram/isogram-test.roc | 30 +- .../killer-sudoku-helper-test.roc | 2 +- .../kindergarten-garden/.meta/template.j2 | 2 +- .../kindergarten-garden-test.roc | 36 +- exercises/practice/knapsack/.meta/template.j2 | 2 +- exercises/practice/knapsack/knapsack-test.roc | 16 +- .../largest-series-product/.meta/template.j2 | 2 +- .../largest-series-product-test.roc | 30 +- exercises/practice/leap/leap-test.roc | 2 +- exercises/practice/list-ops/.meta/template.j2 | 14 +- exercises/practice/list-ops/list-ops-test.roc | 46 +- exercises/practice/luhn/.meta/template.j2 | 2 +- exercises/practice/luhn/luhn-test.roc | 46 +- .../matching-brackets-test.roc | 2 +- exercises/practice/matrix/.meta/template.j2 | 2 +- exercises/practice/matrix/matrix-test.roc | 18 +- exercises/practice/meetup/.meta/template.j2 | 6 +- exercises/practice/meetup/meetup-test.roc | 1522 +++++++++-------- .../practice/micro-blog/.meta/template.j2 | 2 +- .../practice/micro-blog/micro-blog-test.roc | 26 +- .../practice/minesweeper/.meta/template.j2 | 6 +- .../practice/minesweeper/minesweeper-test.roc | 74 +- .../practice/nth-prime/.meta/template.j2 | 2 +- .../practice/nth-prime/nth-prime-test.roc | 12 +- .../nucleotide-count/.meta/template.j2 | 2 +- .../nucleotide-count-test.roc | 12 +- .../practice/ocr-numbers/ocr-numbers-test.roc | 2 +- .../palindrome-products/.meta/template.j2 | 8 +- .../palindrome-products-test.roc | 182 +- exercises/practice/pangram/.meta/template.j2 | 2 +- exercises/practice/pangram/pangram-test.roc | 22 +- .../pascals-triangle-test.roc | 2 +- .../perfect-numbers/.meta/template.j2 | 2 +- .../perfect-numbers/perfect-numbers-test.roc | 26 +- .../practice/phone-number/.meta/template.j2 | 2 +- .../phone-number/phone-number-test.roc | 38 +- .../practice/pig-latin/.meta/template.j2 | 2 +- .../practice/pig-latin/pig-latin-test.roc | 48 +- exercises/practice/poker/.meta/template.j2 | 4 +- exercises/practice/poker/poker-test.roc | 150 +- .../practice/prime-factors/.meta/template.j2 | 2 +- .../prime-factors/prime-factors-test.roc | 26 +- .../protein-translation/.meta/template.j2 | 2 +- .../protein-translation-test.roc | 58 +- exercises/practice/proverb/.meta/template.j2 | 2 +- exercises/practice/proverb/proverb-test.roc | 14 +- .../pythagorean-triplet/.meta/template.j2 | 2 +- .../pythagorean-triplet-test.roc | 16 +- .../practice/queen-attack/.meta/template.j2 | 20 +- .../queen-attack/queen-attack-test.roc | 60 +- .../rail-fence-cipher/.meta/template.j2 | 2 +- .../rail-fence-cipher-test.roc | 14 +- .../practice/raindrops/.meta/template.j2 | 2 +- .../practice/raindrops/raindrops-test.roc | 38 +- .../rational-numbers/.meta/template.j2 | 6 +- .../rational-numbers-test.roc | 62 +- .../practice/rectangles/.meta/template.j2 | 2 +- .../practice/rectangles/rectangles-test.roc | 63 +- .../resistor-color-duo/.meta/template.j2 | 2 +- .../resistor-color-duo-test.roc | 14 +- .../practice/resistor-color/.meta/template.j2 | 2 +- .../resistor-color/resistor-color-test.roc | 8 +- exercises/practice/rest-api/.meta/template.j2 | 10 +- exercises/practice/rest-api/rest-api-test.roc | 112 +- .../practice/reverse-string/.meta/template.j2 | 2 +- .../reverse-string/reverse-string-test.roc | 20 +- .../rna-transcription/.meta/template.j2 | 2 +- .../rna-transcription-test.roc | 14 +- .../robot-simulator/robot-simulator-test.roc | 2 +- .../practice/roman-numerals/.meta/template.j2 | 2 +- .../roman-numerals/roman-numerals-test.roc | 56 +- .../rotational-cipher/.meta/template.j2 | 2 +- .../rotational-cipher-test.roc | 22 +- .../run-length-encoding/.meta/template.j2 | 6 +- .../run-length-encoding-test.roc | 30 +- .../saddle-points/saddle-points-test.roc | 2 +- exercises/practice/say/.meta/template.j2 | 2 +- exercises/practice/say/say-test.roc | 38 +- .../practice/scrabble-score/.meta/template.j2 | 2 +- .../scrabble-score/scrabble-score-test.roc | 24 +- .../secret-handshake/.meta/template.j2 | 2 +- .../secret-handshake-test.roc | 24 +- exercises/practice/series/.meta/template.j2 | 2 +- exercises/practice/series/series-test.roc | 22 +- .../practice/sgf-parsing/sgf-parsing-test.roc | 2 +- exercises/practice/sieve/.meta/template.j2 | 2 +- exercises/practice/sieve/sieve-test.roc | 12 +- .../practice/space-age/.meta/template.j2 | 4 +- .../practice/space-age/space-age-test.roc | 34 +- .../practice/spiral-matrix/.meta/template.j2 | 2 +- .../spiral-matrix/spiral-matrix-test.roc | 14 +- .../practice/square-root/.meta/template.j2 | 2 +- .../practice/square-root/square-root-test.roc | 14 +- exercises/practice/strain/.meta/template.j2 | 2 +- exercises/practice/strain/strain-test.roc | 30 +- exercises/practice/sublist/.meta/template.j2 | 2 +- exercises/practice/sublist/sublist-test.roc | 38 +- .../sum-of-multiples/.meta/template.j2 | 2 +- .../sum-of-multiples-test.roc | 34 +- .../practice/tournament/.meta/template.j2 | 4 +- .../practice/tournament/tournament-test.roc | 83 +- .../practice/transpose/.meta/template.j2 | 4 +- .../practice/transpose/transpose-test.roc | 50 +- exercises/practice/triangle/triangle-test.roc | 2 +- .../practice/two-bucket/.meta/template.j2 | 8 +- .../practice/two-bucket/two-bucket-test.roc | 212 ++- exercises/practice/two-fer/.meta/template.j2 | 2 +- exercises/practice/two-fer/two-fer-test.roc | 6 +- .../variable-length-quantity-test.roc | 2 +- .../practice/word-count/.meta/template.j2 | 2 +- .../practice/word-count/word-count-test.roc | 30 +- .../practice/word-search/word-search-test.roc | 2 +- exercises/practice/wordy/.meta/template.j2 | 2 +- exercises/practice/wordy/wordy-test.roc | 56 +- exercises/practice/yacht/.meta/template.j2 | 2 +- exercises/practice/yacht/yacht-test.roc | 60 +- .../zebra-puzzle/zebra-puzzle-test.roc | 2 +- 189 files changed, 2777 insertions(+), 2483 deletions(-) diff --git a/bin/add-exercise b/bin/add-exercise index 921a5fa5..b813d0ab 100755 --- a/bin/add-exercise +++ b/bin/add-exercise @@ -68,7 +68,7 @@ import {{ exercise | to_pascal }} exposing [{{ cases[0]["property"] | to_snake } {% for case in cases -%} # {{ case["description"] }} expect - result = {{ case["property"] | to_snake }} {{ case["input"]["myArg"] | to_roc }} + result = {{ case["property"] | to_snake }}({{ case["input"]["myArg"] | to_roc }}) result == {{ case["expected"] | to_roc }} {% endfor %} diff --git a/config/generator_macros.j2 b/config/generator_macros.j2 index 97b1cf4f..287a587e 100644 --- a/config/generator_macros.j2 +++ b/config/generator_macros.j2 @@ -37,7 +37,7 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line! "" + Stdout.line!("") {%- endmacro %} diff --git a/exercises/practice/accumulate/.meta/template.j2 b/exercises/practice/accumulate/.meta/template.j2 index 7532eb0e..f3225606 100644 --- a/exercises/practice/accumulate/.meta/template.j2 +++ b/exercises/practice/accumulate/.meta/template.j2 @@ -5,16 +5,16 @@ import {{ exercise | to_pascal }} exposing [{{ cases[0]["property"] | to_snake }}] {% set accumulators = { - "(x) => x * x": "\\x ->\n x * x", + "(x) => x * x": "|x|\n x * x", "(x) => upcase(x)": "to_upper", "(x) => reverse(x)": "reverse", - "(x) => accumulate([\"1\", \"2\", \"3\"], (y) => x + y)": "\\x ->\n accumulate [\"1\", \"2\", \"3\"] (\\y -> Str.concat x y)" + "(x) => accumulate([\"1\", \"2\", \"3\"], (y) => x + y)": "|x|\n accumulate [\"1\", \"2\", \"3\"] (\\y -> Str.concat x y)" } -%} {% for case in cases -%} # {{ case["description"] }} expect - result = {{ case["property"] | to_snake }} {{ case["input"]["list"] | to_roc }} {{ accumulators[case["input"]["accumulator"]] }} + result = {{ case["property"] | to_snake }}({{ case["input"]["list"] | to_roc }}, {{ accumulators[case["input"]["accumulator"]] }}) result == {{ case["expected"] | to_roc }} {% endfor %} @@ -24,7 +24,7 @@ reverse = |str| Str.to_utf8 str |> List.reverse |> Str.from_utf8 - |> Result.with_default "" + |> Result.with_default("") to_upper : Str -> Str to_upper = |str| @@ -35,4 +35,4 @@ to_upper = |str| else byte |> Str.from_utf8 - |> Result.with_default "" + |> Result.with_default("") diff --git a/exercises/practice/accumulate/accumulate-test.roc b/exercises/practice/accumulate/accumulate-test.roc index f33abb39..678a6373 100644 --- a/exercises/practice/accumulate/accumulate-test.roc +++ b/exercises/practice/accumulate/accumulate-test.roc @@ -8,36 +8,45 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line! "" + Stdout.line!("") import Accumulate exposing [accumulate] # accumulate empty expect - result = accumulate [] |x| - x * x + result = accumulate( + [], + |x| + x * x, + ) result == [] # accumulate squares expect - result = accumulate [1, 2, 3] |x| - x * x + result = accumulate( + [1, 2, 3], + |x| + x * x, + ) result == [1, 4, 9] # accumulate upcases expect - result = accumulate ["Hello", "world"] to_upper + result = accumulate(["Hello", "world"], to_upper) result == ["HELLO", "WORLD"] # accumulate reversed strings expect - result = accumulate ["the", "quick", "brown", "fox", "etc"] reverse + result = accumulate(["the", "quick", "brown", "fox", "etc"], reverse) result == ["eht", "kciuq", "nworb", "xof", "cte"] # accumulate recursively expect - result = accumulate ["a", "b", "c"] |x| - accumulate ["1", "2", "3"] (|y| Str.concat x y) + result = accumulate( + ["a", "b", "c"], + |x| + accumulate ["1", "2", "3"] (|y| Str.concat x y), + ) result == [["a1", "a2", "a3"], ["b1", "b2", "b3"], ["c1", "c2", "c3"]] reverse : Str -> Str @@ -45,7 +54,7 @@ reverse = |str| Str.to_utf8 str |> List.reverse |> Str.from_utf8 - |> Result.with_default "" + |> Result.with_default("") to_upper : Str -> Str to_upper = |str| @@ -56,4 +65,4 @@ to_upper = |str| else byte |> Str.from_utf8 - |> Result.with_default "" + |> Result.with_default("") diff --git a/exercises/practice/acronym/.meta/template.j2 b/exercises/practice/acronym/.meta/template.j2 index 6c2dcdea..c49cadb6 100644 --- a/exercises/practice/acronym/.meta/template.j2 +++ b/exercises/practice/acronym/.meta/template.j2 @@ -7,7 +7,7 @@ import {{ exercise | to_pascal }} exposing [abbreviate] {% for case in cases -%} # {{ case["description"] }} expect - result = {{ case["property"] | to_snake }} {{ case["input"]["phrase"] | to_roc }} + result = {{ case["property"] | to_snake }}({{ case["input"]["phrase"] | to_roc }}) result == {{ case["expected"] | to_roc }} {% endfor %} diff --git a/exercises/practice/acronym/acronym-test.roc b/exercises/practice/acronym/acronym-test.roc index 1597c144..cf6e011e 100644 --- a/exercises/practice/acronym/acronym-test.roc +++ b/exercises/practice/acronym/acronym-test.roc @@ -8,52 +8,52 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line! "" + Stdout.line!("") import Acronym exposing [abbreviate] # basic expect - result = abbreviate "Portable Network Graphics" + result = abbreviate("Portable Network Graphics") result == "PNG" # lowercase words expect - result = abbreviate "Ruby on Rails" + result = abbreviate("Ruby on Rails") result == "ROR" # punctuation expect - result = abbreviate "First In, First Out" + result = abbreviate("First In, First Out") result == "FIFO" # all caps word expect - result = abbreviate "GNU Image Manipulation Program" + result = abbreviate("GNU Image Manipulation Program") result == "GIMP" # punctuation without whitespace expect - result = abbreviate "Complementary metal-oxide semiconductor" + result = abbreviate("Complementary metal-oxide semiconductor") result == "CMOS" # very long abbreviation expect - result = abbreviate "Rolling On The Floor Laughing So Hard That My Dogs Came Over And Licked Me" + result = abbreviate("Rolling On The Floor Laughing So Hard That My Dogs Came Over And Licked Me") result == "ROTFLSHTMDCOALM" # consecutive delimiters expect - result = abbreviate "Something - I made up from thin air" + result = abbreviate("Something - I made up from thin air") result == "SIMUFTA" # apostrophes expect - result = abbreviate "Halley's Comet" + result = abbreviate("Halley's Comet") result == "HC" # underscore emphasis expect - result = abbreviate "The Road _Not_ Taken" + result = abbreviate("The Road _Not_ Taken") result == "TRNT" diff --git a/exercises/practice/affine-cipher/affine-cipher-test.roc b/exercises/practice/affine-cipher/affine-cipher-test.roc index a04c48a6..4a99d7a2 100644 --- a/exercises/practice/affine-cipher/affine-cipher-test.roc +++ b/exercises/practice/affine-cipher/affine-cipher-test.roc @@ -8,7 +8,7 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line! "" + Stdout.line!("") import AffineCipher exposing [encode, decode] diff --git a/exercises/practice/all-your-base/.meta/template.j2 b/exercises/practice/all-your-base/.meta/template.j2 index c028fa90..dbba8591 100644 --- a/exercises/practice/all-your-base/.meta/template.j2 +++ b/exercises/practice/all-your-base/.meta/template.j2 @@ -7,11 +7,11 @@ import {{ exercise | to_pascal }} exposing [{{ cases[0]["property"] | to_snake } {% for case in cases -%} # {{ case["description"] }} expect - result = {{ case["property"] | to_snake }} { input_base: {{ case["input"]["inputBase"] | to_roc }}, output_base: {{ case["input"]["outputBase"] | to_roc }}, digits: {{ case["input"]["digits"] | to_roc }} } + result = {{ case["property"] | to_snake }}({ input_base: {{ case["input"]["inputBase"] | to_roc }}, output_base: {{ case["input"]["outputBase"] | to_roc }}, digits: {{ case["input"]["digits"] | to_roc }} }) {%- if case["expected"]["error"] %} result |> Result.is_err {%- else %} - result == Ok {{ case["expected"] }} + result == Ok({{ case["expected"] }}) {%- endif %} {% endfor %} \ No newline at end of file diff --git a/exercises/practice/all-your-base/all-your-base-test.roc b/exercises/practice/all-your-base/all-your-base-test.roc index 02b626b8..8ea2795a 100644 --- a/exercises/practice/all-your-base/all-your-base-test.roc +++ b/exercises/practice/all-your-base/all-your-base-test.roc @@ -8,92 +8,92 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line! "" + Stdout.line!("") import AllYourBase exposing [rebase] # single bit one to decimal expect - result = rebase { input_base: 2, output_base: 10, digits: [1] } - result == Ok [1] + result = rebase({ input_base: 2, output_base: 10, digits: [1] }) + result == Ok([1]) # binary to single decimal expect - result = rebase { input_base: 2, output_base: 10, digits: [1, 0, 1] } - result == Ok [5] + result = rebase({ input_base: 2, output_base: 10, digits: [1, 0, 1] }) + result == Ok([5]) # single decimal to binary expect - result = rebase { input_base: 10, output_base: 2, digits: [5] } - result == Ok [1, 0, 1] + result = rebase({ input_base: 10, output_base: 2, digits: [5] }) + result == Ok([1, 0, 1]) # binary to multiple decimal expect - result = rebase { input_base: 2, output_base: 10, digits: [1, 0, 1, 0, 1, 0] } - result == Ok [4, 2] + result = rebase({ input_base: 2, output_base: 10, digits: [1, 0, 1, 0, 1, 0] }) + result == Ok([4, 2]) # decimal to binary expect - result = rebase { input_base: 10, output_base: 2, digits: [4, 2] } - result == Ok [1, 0, 1, 0, 1, 0] + result = rebase({ input_base: 10, output_base: 2, digits: [4, 2] }) + result == Ok([1, 0, 1, 0, 1, 0]) # trinary to hexadecimal expect - result = rebase { input_base: 3, output_base: 16, digits: [1, 1, 2, 0] } - result == Ok [2, 10] + result = rebase({ input_base: 3, output_base: 16, digits: [1, 1, 2, 0] }) + result == Ok([2, 10]) # hexadecimal to trinary expect - result = rebase { input_base: 16, output_base: 3, digits: [2, 10] } - result == Ok [1, 1, 2, 0] + result = rebase({ input_base: 16, output_base: 3, digits: [2, 10] }) + result == Ok([1, 1, 2, 0]) # 15-bit integer expect - result = rebase { input_base: 97, output_base: 73, digits: [3, 46, 60] } - result == Ok [6, 10, 45] + result = rebase({ input_base: 97, output_base: 73, digits: [3, 46, 60] }) + result == Ok([6, 10, 45]) # empty list expect - result = rebase { input_base: 2, output_base: 10, digits: [] } - result == Ok [0] + result = rebase({ input_base: 2, output_base: 10, digits: [] }) + result == Ok([0]) # single zero expect - result = rebase { input_base: 10, output_base: 2, digits: [0] } - result == Ok [0] + result = rebase({ input_base: 10, output_base: 2, digits: [0] }) + result == Ok([0]) # multiple zeros expect - result = rebase { input_base: 10, output_base: 2, digits: [0, 0, 0] } - result == Ok [0] + result = rebase({ input_base: 10, output_base: 2, digits: [0, 0, 0] }) + result == Ok([0]) # leading zeros expect - result = rebase { input_base: 7, output_base: 10, digits: [0, 6, 0] } - result == Ok [4, 2] + result = rebase({ input_base: 7, output_base: 10, digits: [0, 6, 0] }) + result == Ok([4, 2]) # input base is one expect - result = rebase { input_base: 1, output_base: 10, digits: [0] } + result = rebase({ input_base: 1, output_base: 10, digits: [0] }) result |> Result.is_err # input base is zero expect - result = rebase { input_base: 0, output_base: 10, digits: [] } + result = rebase({ input_base: 0, output_base: 10, digits: [] }) result |> Result.is_err # invalid positive digit expect - result = rebase { input_base: 2, output_base: 10, digits: [1, 2, 1, 0, 1, 0] } + result = rebase({ input_base: 2, output_base: 10, digits: [1, 2, 1, 0, 1, 0] }) result |> Result.is_err # output base is one expect - result = rebase { input_base: 2, output_base: 1, digits: [1, 0, 1, 0, 1, 0] } + result = rebase({ input_base: 2, output_base: 1, digits: [1, 0, 1, 0, 1, 0] }) result |> Result.is_err # output base is zero expect - result = rebase { input_base: 10, output_base: 0, digits: [7] } + result = rebase({ input_base: 10, output_base: 0, digits: [7] }) result |> Result.is_err diff --git a/exercises/practice/allergies/allergies-test.roc b/exercises/practice/allergies/allergies-test.roc index cda6fa47..9207f7cf 100644 --- a/exercises/practice/allergies/allergies-test.roc +++ b/exercises/practice/allergies/allergies-test.roc @@ -8,7 +8,7 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line! "" + Stdout.line!("") import Allergies exposing [allergic_to, set] diff --git a/exercises/practice/alphametics/.meta/template.j2 b/exercises/practice/alphametics/.meta/template.j2 index d46f8ef5..f4f34165 100644 --- a/exercises/practice/alphametics/.meta/template.j2 +++ b/exercises/practice/alphametics/.meta/template.j2 @@ -7,7 +7,7 @@ import {{ exercise | to_pascal }} exposing [{{ cases[0]["property"] | to_snake } {% for case in cases -%} # {{ case["description"] }} expect - result = {{ case["property"] | to_snake }} {{ case["input"]["puzzle"] | to_roc }} + result = {{ case["property"] | to_snake }}({{ case["input"]["puzzle"] | to_roc }}) {%- if case["expected"] %} Result.with_default result [] |> Set.from_list == Set.from_list [ {%- for letter, value in case["expected"].items() %} diff --git a/exercises/practice/alphametics/alphametics-test.roc b/exercises/practice/alphametics/alphametics-test.roc index bc40c6ea..a8379de9 100644 --- a/exercises/practice/alphametics/alphametics-test.roc +++ b/exercises/practice/alphametics/alphametics-test.roc @@ -8,13 +8,13 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line! "" + Stdout.line!("") import Alphametics exposing [solve] # puzzle with three letters expect - result = solve "I + BB == ILL" + result = solve("I + BB == ILL") Result.with_default result [] |> Set.from_list == Set.from_list [ @@ -25,17 +25,17 @@ expect # solution must have unique value for each letter expect - result = solve "A == B" + result = solve("A == B") Result.is_err result # leading zero solution is invalid expect - result = solve "ACA + DD == BD" + result = solve("ACA + DD == BD") Result.is_err result # puzzle with two digits final carry expect - result = solve "A + A + A + A + A + A + A + A + A + A + A + B == BCC" + result = solve("A + A + A + A + A + A + A + A + A + A + A + B == BCC") Result.with_default result [] |> Set.from_list == Set.from_list [ @@ -46,7 +46,7 @@ expect # puzzle with four letters expect - result = solve "AS + A == MOM" + result = solve("AS + A == MOM") Result.with_default result [] |> Set.from_list == Set.from_list [ @@ -58,7 +58,7 @@ expect # puzzle with six letters expect - result = solve "NO + NO + TOO == LATE" + result = solve("NO + NO + TOO == LATE") Result.with_default result [] |> Set.from_list == Set.from_list [ @@ -72,7 +72,7 @@ expect # puzzle with seven letters expect - result = solve "HE + SEES + THE == LIGHT" + result = solve("HE + SEES + THE == LIGHT") Result.with_default result [] |> Set.from_list == Set.from_list [ @@ -87,7 +87,7 @@ expect # puzzle with eight letters expect - result = solve "SEND + MORE == MONEY" + result = solve("SEND + MORE == MONEY") Result.with_default result [] |> Set.from_list == Set.from_list [ @@ -103,7 +103,7 @@ expect # puzzle with ten letters expect - result = solve "AND + A + STRONG + OFFENSE + AS + A + GOOD == DEFENSE" + result = solve("AND + A + STRONG + OFFENSE + AS + A + GOOD == DEFENSE") Result.with_default result [] |> Set.from_list == Set.from_list [ @@ -121,7 +121,7 @@ expect # puzzle with ten letters and 199 addends expect - result = solve "THIS + A + FIRE + THEREFORE + FOR + ALL + HISTORIES + I + TELL + A + TALE + THAT + FALSIFIES + ITS + TITLE + TIS + A + LIE + THE + TALE + OF + THE + LAST + FIRE + HORSES + LATE + AFTER + THE + FIRST + FATHERS + FORESEE + THE + HORRORS + THE + LAST + FREE + TROLL + TERRIFIES + THE + HORSES + OF + FIRE + THE + TROLL + RESTS + AT + THE + HOLE + OF + LOSSES + IT + IS + THERE + THAT + SHE + STORES + ROLES + OF + LEATHERS + AFTER + SHE + SATISFIES + HER + HATE + OFF + THOSE + FEARS + A + TASTE + RISES + AS + SHE + HEARS + THE + LEAST + FAR + HORSE + THOSE + FAST + HORSES + THAT + FIRST + HEAR + THE + TROLL + FLEE + OFF + TO + THE + FOREST + THE + HORSES + THAT + ALERTS + RAISE + THE + STARES + OF + THE + OTHERS + AS + THE + TROLL + ASSAILS + AT + THE + TOTAL + SHIFT + HER + TEETH + TEAR + HOOF + OFF + TORSO + AS + THE + LAST + HORSE + FORFEITS + ITS + LIFE + THE + FIRST + FATHERS + HEAR + OF + THE + HORRORS + THEIR + FEARS + THAT + THE + FIRES + FOR + THEIR + FEASTS + ARREST + AS + THE + FIRST + FATHERS + RESETTLE + THE + LAST + OF + THE + FIRE + HORSES + THE + LAST + TROLL + HARASSES + THE + FOREST + HEART + FREE + AT + LAST + OF + THE + LAST + TROLL + ALL + OFFER + THEIR + FIRE + HEAT + TO + THE + ASSISTERS + FAR + OFF + THE + TROLL + FASTS + ITS + LIFE + SHORTER + AS + STARS + RISE + THE + HORSES + REST + SAFE + AFTER + ALL + SHARE + HOT + FISH + AS + THEIR + AFFILIATES + TAILOR + A + ROOFS + FOR + THEIR + SAFE == FORTRESSES" + result = solve("THIS + A + FIRE + THEREFORE + FOR + ALL + HISTORIES + I + TELL + A + TALE + THAT + FALSIFIES + ITS + TITLE + TIS + A + LIE + THE + TALE + OF + THE + LAST + FIRE + HORSES + LATE + AFTER + THE + FIRST + FATHERS + FORESEE + THE + HORRORS + THE + LAST + FREE + TROLL + TERRIFIES + THE + HORSES + OF + FIRE + THE + TROLL + RESTS + AT + THE + HOLE + OF + LOSSES + IT + IS + THERE + THAT + SHE + STORES + ROLES + OF + LEATHERS + AFTER + SHE + SATISFIES + HER + HATE + OFF + THOSE + FEARS + A + TASTE + RISES + AS + SHE + HEARS + THE + LEAST + FAR + HORSE + THOSE + FAST + HORSES + THAT + FIRST + HEAR + THE + TROLL + FLEE + OFF + TO + THE + FOREST + THE + HORSES + THAT + ALERTS + RAISE + THE + STARES + OF + THE + OTHERS + AS + THE + TROLL + ASSAILS + AT + THE + TOTAL + SHIFT + HER + TEETH + TEAR + HOOF + OFF + TORSO + AS + THE + LAST + HORSE + FORFEITS + ITS + LIFE + THE + FIRST + FATHERS + HEAR + OF + THE + HORRORS + THEIR + FEARS + THAT + THE + FIRES + FOR + THEIR + FEASTS + ARREST + AS + THE + FIRST + FATHERS + RESETTLE + THE + LAST + OF + THE + FIRE + HORSES + THE + LAST + TROLL + HARASSES + THE + FOREST + HEART + FREE + AT + LAST + OF + THE + LAST + TROLL + ALL + OFFER + THEIR + FIRE + HEAT + TO + THE + ASSISTERS + FAR + OFF + THE + TROLL + FASTS + ITS + LIFE + SHORTER + AS + STARS + RISE + THE + HORSES + REST + SAFE + AFTER + ALL + SHARE + HOT + FISH + AS + THEIR + AFFILIATES + TAILOR + A + ROOFS + FOR + THEIR + SAFE == FORTRESSES") Result.with_default result [] |> Set.from_list == Set.from_list [ diff --git a/exercises/practice/anagram/.meta/template.j2 b/exercises/practice/anagram/.meta/template.j2 index 89654c9b..3af1c1ad 100644 --- a/exercises/practice/anagram/.meta/template.j2 +++ b/exercises/practice/anagram/.meta/template.j2 @@ -7,7 +7,7 @@ import {{ exercise | to_pascal }} exposing [{{ cases[0]["property"] | to_snake } {% for case in cases -%} # {{ case["description"] }} expect - result = {{ case["property"] | to_snake }} {{ case["input"]["subject"] | to_roc }} {{ case["input"]["candidates"] | to_roc }} + result = {{ case["property"] | to_snake }}({{ case["input"]["subject"] | to_roc }}, {{ case["input"]["candidates"] | to_roc }}) result == {{ case["expected"] | to_roc }} {% endfor %} diff --git a/exercises/practice/anagram/anagram-test.roc b/exercises/practice/anagram/anagram-test.roc index 4ae057e6..1b4f2225 100644 --- a/exercises/practice/anagram/anagram-test.roc +++ b/exercises/practice/anagram/anagram-test.roc @@ -9,92 +9,92 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line! "" + Stdout.line!("") import Anagram exposing [find_anagrams] # no matches expect - result = find_anagrams "diaper" ["hello", "world", "zombies", "pants"] + result = find_anagrams("diaper", ["hello", "world", "zombies", "pants"]) result == [] # detects two anagrams expect - result = find_anagrams "solemn" ["lemons", "cherry", "melons"] + result = find_anagrams("solemn", ["lemons", "cherry", "melons"]) result == ["lemons", "melons"] # does not detect anagram subsets expect - result = find_anagrams "good" ["dog", "goody"] + result = find_anagrams("good", ["dog", "goody"]) result == [] # detects anagram expect - result = find_anagrams "listen" ["enlists", "google", "inlets", "banana"] + result = find_anagrams("listen", ["enlists", "google", "inlets", "banana"]) result == ["inlets"] # detects three anagrams expect - result = find_anagrams "allergy" ["gallery", "ballerina", "regally", "clergy", "largely", "leading"] + result = find_anagrams("allergy", ["gallery", "ballerina", "regally", "clergy", "largely", "leading"]) result == ["gallery", "regally", "largely"] # detects multiple anagrams with different case expect - result = find_anagrams "nose" ["Eons", "ONES"] + result = find_anagrams("nose", ["Eons", "ONES"]) result == ["Eons", "ONES"] # does not detect non-anagrams with identical checksum expect - result = find_anagrams "mass" ["last"] + result = find_anagrams("mass", ["last"]) result == [] # detects anagrams case-insensitively expect - result = find_anagrams "Orchestra" ["cashregister", "Carthorse", "radishes"] + result = find_anagrams("Orchestra", ["cashregister", "Carthorse", "radishes"]) result == ["Carthorse"] # detects anagrams using case-insensitive subject expect - result = find_anagrams "Orchestra" ["cashregister", "carthorse", "radishes"] + result = find_anagrams("Orchestra", ["cashregister", "carthorse", "radishes"]) result == ["carthorse"] # detects anagrams using case-insensitive possible matches expect - result = find_anagrams "orchestra" ["cashregister", "Carthorse", "radishes"] + result = find_anagrams("orchestra", ["cashregister", "Carthorse", "radishes"]) result == ["Carthorse"] # does not detect an anagram if the original word is repeated expect - result = find_anagrams "go" ["goGoGO"] + result = find_anagrams("go", ["goGoGO"]) result == [] # anagrams must use all letters exactly once expect - result = find_anagrams "tapper" ["patter"] + result = find_anagrams("tapper", ["patter"]) result == [] # words are not anagrams of themselves expect - result = find_anagrams "BANANA" ["BANANA"] + result = find_anagrams("BANANA", ["BANANA"]) result == [] # words are not anagrams of themselves even if letter case is partially different expect - result = find_anagrams "BANANA" ["Banana"] + result = find_anagrams("BANANA", ["Banana"]) result == [] # words are not anagrams of themselves even if letter case is completely different expect - result = find_anagrams "BANANA" ["banana"] + result = find_anagrams("BANANA", ["banana"]) result == [] # words other than themselves can be anagrams expect - result = find_anagrams "LISTEN" ["LISTEN", "Silent"] + result = find_anagrams("LISTEN", ["LISTEN", "Silent"]) result == ["Silent"] # different characters may have the same bytes expect - result = find_anagrams "a⬂" ["€a"] + result = find_anagrams("a⬂", ["€a"]) result == [] diff --git a/exercises/practice/armstrong-numbers/.meta/template.j2 b/exercises/practice/armstrong-numbers/.meta/template.j2 index e9e45470..3bb36c52 100644 --- a/exercises/practice/armstrong-numbers/.meta/template.j2 +++ b/exercises/practice/armstrong-numbers/.meta/template.j2 @@ -7,7 +7,7 @@ import {{ exercise | to_pascal }} exposing [is_armstrong_number] {% for case in cases -%} # {{ case["description"] }} expect - result = {{ case["property"] | to_snake }} {{ case["input"]["number"] }} + result = {{ case["property"] | to_snake }}({{ case["input"]["number"] }}) result == {{ case["expected"] | to_roc }} {% endfor %} diff --git a/exercises/practice/armstrong-numbers/armstrong-numbers-test.roc b/exercises/practice/armstrong-numbers/armstrong-numbers-test.roc index 41b75b7d..01d9ff5a 100644 --- a/exercises/practice/armstrong-numbers/armstrong-numbers-test.roc +++ b/exercises/practice/armstrong-numbers/armstrong-numbers-test.roc @@ -8,52 +8,52 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line! "" + Stdout.line!("") import ArmstrongNumbers exposing [is_armstrong_number] # Zero is an Armstrong number expect - result = is_armstrong_number 0 + result = is_armstrong_number(0) result == Bool.true # Single-digit numbers are Armstrong numbers expect - result = is_armstrong_number 5 + result = is_armstrong_number(5) result == Bool.true # There are no two-digit Armstrong numbers expect - result = is_armstrong_number 10 + result = is_armstrong_number(10) result == Bool.false # Three-digit number that is an Armstrong number expect - result = is_armstrong_number 153 + result = is_armstrong_number(153) result == Bool.true # Three-digit number that is not an Armstrong number expect - result = is_armstrong_number 100 + result = is_armstrong_number(100) result == Bool.false # Four-digit number that is an Armstrong number expect - result = is_armstrong_number 9474 + result = is_armstrong_number(9474) result == Bool.true # Four-digit number that is not an Armstrong number expect - result = is_armstrong_number 9475 + result = is_armstrong_number(9475) result == Bool.false # Seven-digit number that is an Armstrong number expect - result = is_armstrong_number 9926315 + result = is_armstrong_number(9926315) result == Bool.true # Seven-digit number that is not an Armstrong number expect - result = is_armstrong_number 9926314 + result = is_armstrong_number(9926314) result == Bool.false diff --git a/exercises/practice/atbash-cipher/atbash-cipher-test.roc b/exercises/practice/atbash-cipher/atbash-cipher-test.roc index fb8e8be0..1faad3e4 100644 --- a/exercises/practice/atbash-cipher/atbash-cipher-test.roc +++ b/exercises/practice/atbash-cipher/atbash-cipher-test.roc @@ -8,7 +8,7 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line! "" + Stdout.line!("") import AtbashCipher exposing [encode, decode] diff --git a/exercises/practice/binary-search-tree/binary-search-tree-test.roc b/exercises/practice/binary-search-tree/binary-search-tree-test.roc index 17057c70..4503312c 100644 --- a/exercises/practice/binary-search-tree/binary-search-tree-test.roc +++ b/exercises/practice/binary-search-tree/binary-search-tree-test.roc @@ -8,7 +8,7 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line! "" + Stdout.line!("") import BinarySearchTree exposing [from_list, to_list] diff --git a/exercises/practice/binary-search/.meta/template.j2 b/exercises/practice/binary-search/.meta/template.j2 index 04ba2d3d..edb9f6d2 100644 --- a/exercises/practice/binary-search/.meta/template.j2 +++ b/exercises/practice/binary-search/.meta/template.j2 @@ -7,7 +7,7 @@ import {{ exercise | to_pascal }} exposing [{{ cases[0]["property"] | to_snake } {% for case in cases -%} # {{ case["description"] }} expect - result = {{ case["input"]["array"] | to_roc }} |> {{ case["property"] | to_snake }} {{ case["input"]["value"] }} + result = {{ case["input"]["array"] | to_roc }} |> {{ case["property"] | to_snake }}({{ case["input"]["value"] }}) {%- if case["expected"]["error"] %} Result.is_err result {%- else %} diff --git a/exercises/practice/binary-search/binary-search-test.roc b/exercises/practice/binary-search/binary-search-test.roc index 8e181ae9..1d62a912 100644 --- a/exercises/practice/binary-search/binary-search-test.roc +++ b/exercises/practice/binary-search/binary-search-test.roc @@ -8,62 +8,62 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line! "" + Stdout.line!("") import BinarySearch exposing [find] # finds a value in an array with one element expect - result = [6] |> find 6 + result = [6] |> find(6) result == Ok 0 # finds a value in the middle of an array expect - result = [1, 3, 4, 6, 8, 9, 11] |> find 6 + result = [1, 3, 4, 6, 8, 9, 11] |> find(6) result == Ok 3 # finds a value at the beginning of an array expect - result = [1, 3, 4, 6, 8, 9, 11] |> find 1 + result = [1, 3, 4, 6, 8, 9, 11] |> find(1) result == Ok 0 # finds a value at the end of an array expect - result = [1, 3, 4, 6, 8, 9, 11] |> find 11 + result = [1, 3, 4, 6, 8, 9, 11] |> find(11) result == Ok 6 # finds a value in an array of odd length expect - result = [1, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 634] |> find 144 + result = [1, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 634] |> find(144) result == Ok 9 # finds a value in an array of even length expect - result = [1, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377] |> find 21 + result = [1, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377] |> find(21) result == Ok 5 # identifies that a value is not included in the array expect - result = [1, 3, 4, 6, 8, 9, 11] |> find 7 + result = [1, 3, 4, 6, 8, 9, 11] |> find(7) Result.is_err result # a value smaller than the array's smallest value is not found expect - result = [1, 3, 4, 6, 8, 9, 11] |> find 0 + result = [1, 3, 4, 6, 8, 9, 11] |> find(0) Result.is_err result # a value larger than the array's largest value is not found expect - result = [1, 3, 4, 6, 8, 9, 11] |> find 13 + result = [1, 3, 4, 6, 8, 9, 11] |> find(13) Result.is_err result # nothing is found in an empty array expect - result = [] |> find 1 + result = [] |> find(1) Result.is_err result # nothing is found when the left and right bounds cross expect - result = [1, 2] |> find 0 + result = [1, 2] |> find(0) Result.is_err result diff --git a/exercises/practice/binary/.meta/template.j2 b/exercises/practice/binary/.meta/template.j2 index c60a6475..b06b884c 100644 --- a/exercises/practice/binary/.meta/template.j2 +++ b/exercises/practice/binary/.meta/template.j2 @@ -7,7 +7,7 @@ import {{ exercise | to_pascal }} exposing [{{ cases[0]["property"] | to_snake } {% for case in cases -%} # {{ case["description"] }} expect - result = {{ case["property"] | to_snake }} {{ case["input"]["binary"] | to_roc }} + result = {{ case["property"] | to_snake }}({{ case["input"]["binary"] | to_roc }}) {%- if case["expected"] is not none %} result == Ok {{ case["expected"] | to_roc }} {%- else %} diff --git a/exercises/practice/binary/binary-test.roc b/exercises/practice/binary/binary-test.roc index 664033d5..a9c9115f 100644 --- a/exercises/practice/binary/binary-test.roc +++ b/exercises/practice/binary/binary-test.roc @@ -8,82 +8,82 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line! "" + Stdout.line!("") import Binary exposing [decimal] # binary 0 is decimal 0 expect - result = decimal "0" + result = decimal("0") result == Ok 0 # binary 1 is decimal 1 expect - result = decimal "1" + result = decimal("1") result == Ok 1 # binary 10 is decimal 2 expect - result = decimal "10" + result = decimal("10") result == Ok 2 # binary 11 is decimal 3 expect - result = decimal "11" + result = decimal("11") result == Ok 3 # binary 100 is decimal 4 expect - result = decimal "100" + result = decimal("100") result == Ok 4 # binary 1001 is decimal 9 expect - result = decimal "1001" + result = decimal("1001") result == Ok 9 # binary 11010 is decimal 26 expect - result = decimal "11010" + result = decimal("11010") result == Ok 26 # binary 10001101000 is decimal 1128 expect - result = decimal "10001101000" + result = decimal("10001101000") result == Ok 1128 # binary ignores leading zeros expect - result = decimal "000011111" + result = decimal("000011111") result == Ok 31 # 2 is not a valid binary digit expect - result = decimal "2" + result = decimal("2") result |> Result.is_err # a number containing a non-binary digit is invalid expect - result = decimal "01201" + result = decimal("01201") result |> Result.is_err # a number with trailing non-binary characters is invalid expect - result = decimal "10nope" + result = decimal("10nope") result |> Result.is_err # a number with leading non-binary characters is invalid expect - result = decimal "nope10" + result = decimal("nope10") result |> Result.is_err # a number with internal non-binary characters is invalid expect - result = decimal "10nope10" + result = decimal("10nope10") result |> Result.is_err # a number and a word whitespace separated is invalid expect - result = decimal "001 nope" + result = decimal("001 nope") result |> Result.is_err diff --git a/exercises/practice/bob/.meta/template.j2 b/exercises/practice/bob/.meta/template.j2 index fe5df14b..9995b77c 100644 --- a/exercises/practice/bob/.meta/template.j2 +++ b/exercises/practice/bob/.meta/template.j2 @@ -7,7 +7,7 @@ import {{ exercise | to_pascal }} exposing [response] {% for case in cases -%} # {{ case["description"] }} expect - result = {{ case["property"] | to_snake }} {{ case["input"]["heyBob"] | to_roc }} + result = {{ case["property"] | to_snake }}({{ case["input"]["heyBob"] | to_roc }}) result == {{ case["expected"] | to_roc }} {% endfor %} \ No newline at end of file diff --git a/exercises/practice/bob/bob-test.roc b/exercises/practice/bob/bob-test.roc index d7d70186..65a21f94 100644 --- a/exercises/practice/bob/bob-test.roc +++ b/exercises/practice/bob/bob-test.roc @@ -8,132 +8,132 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line! "" + Stdout.line!("") import Bob exposing [response] # stating something expect - result = response "Tom-ay-to, tom-aaaah-to." + result = response("Tom-ay-to, tom-aaaah-to.") result == "Whatever." # shouting expect - result = response "WATCH OUT!" + result = response("WATCH OUT!") result == "Whoa, chill out!" # shouting gibberish expect - result = response "FCECDFCAAB" + result = response("FCECDFCAAB") result == "Whoa, chill out!" # asking a question expect - result = response "Does this cryogenic chamber make me look fat?" + result = response("Does this cryogenic chamber make me look fat?") result == "Sure." # asking a numeric question expect - result = response "You are, what, like 15?" + result = response("You are, what, like 15?") result == "Sure." # asking gibberish expect - result = response "fffbbcbeab?" + result = response("fffbbcbeab?") result == "Sure." # talking forcefully expect - result = response "Hi there!" + result = response("Hi there!") result == "Whatever." # using acronyms in regular speech expect - result = response "It's OK if you don't want to go work for NASA." + result = response("It's OK if you don't want to go work for NASA.") result == "Whatever." # forceful question expect - result = response "WHAT'S GOING ON?" + result = response("WHAT'S GOING ON?") result == "Calm down, I know what I'm doing!" # shouting numbers expect - result = response "1, 2, 3 GO!" + result = response("1, 2, 3 GO!") result == "Whoa, chill out!" # no letters expect - result = response "1, 2, 3" + result = response("1, 2, 3") result == "Whatever." # question with no letters expect - result = response "4?" + result = response("4?") result == "Sure." # shouting with special characters expect - result = response "ZOMG THE %^*@#\$(*^ ZOMBIES ARE COMING!!11!!1!" + result = response("ZOMG THE %^*@#\$(*^ ZOMBIES ARE COMING!!11!!1!") result == "Whoa, chill out!" # shouting with no exclamation mark expect - result = response "I HATE THE DENTIST" + result = response("I HATE THE DENTIST") result == "Whoa, chill out!" # statement containing question mark expect - result = response "Ending with ? means a question." + result = response("Ending with ? means a question.") result == "Whatever." # non-letters with question expect - result = response ":) ?" + result = response(":) ?") result == "Sure." # prattling on expect - result = response "Wait! Hang on. Are you going to be OK?" + result = response("Wait! Hang on. Are you going to be OK?") result == "Sure." # silence expect - result = response "" + result = response("") result == "Fine. Be that way!" # prolonged silence expect - result = response " " + result = response(" ") result == "Fine. Be that way!" # alternate silence expect - result = response "\t\t\t\t\t\t\t\t\t\t" + result = response("\t\t\t\t\t\t\t\t\t\t") result == "Fine. Be that way!" # starting with whitespace expect - result = response " hmmmmmmm..." + result = response(" hmmmmmmm...") result == "Whatever." # ending with whitespace expect - result = response "Okay if like my spacebar quite a bit? " + result = response("Okay if like my spacebar quite a bit? ") result == "Sure." # other whitespace expect - result = response "\n\r \t" + result = response("\n\r \t") result == "Fine. Be that way!" # non-question ending with whitespace expect - result = response "This is a statement ending with whitespace " + result = response("This is a statement ending with whitespace ") result == "Whatever." # multiple line question expect - result = response "\nDoes this cryogenic chamber make\n me look fat?" + result = response("\nDoes this cryogenic chamber make\n me look fat?") result == "Sure." diff --git a/exercises/practice/bowling/.meta/template.j2 b/exercises/practice/bowling/.meta/template.j2 index e5f6da01..48cd54d8 100644 --- a/exercises/practice/bowling/.meta/template.j2 +++ b/exercises/practice/bowling/.meta/template.j2 @@ -23,15 +23,15 @@ replay_game = |rolls| expect maybe_game = create { previous_rolls : {{ case["input"]["previousRolls"] | to_roc }} } {%- if case["property"] == "score" %} - result = maybe_game |> Result.try \game -> score game + result = maybe_game |> Result.try |game| score(game) {%- else %} - result = maybe_game |> Result.try \game -> - game |> {{ case["property"] | to_snake }} {{ case["input"]["roll"] }} + result = maybe_game |> Result.try |game| + game |> {{ case["property"] | to_snake }}({{ case["input"]["roll"] }}) {%- endif %} {%- if case["expected"]["error"] %} result |> Result.is_err {%- else %} - result == Ok {{ case["expected"] | to_roc }} + result == Ok({{ case["expected"] | to_roc }}) {%- endif %} {%- if case["property"] == "score" and not case["expected"]["error"] %} diff --git a/exercises/practice/bowling/bowling-test.roc b/exercises/practice/bowling/bowling-test.roc index 6b9c05bf..0ced72ec 100644 --- a/exercises/practice/bowling/bowling-test.roc +++ b/exercises/practice/bowling/bowling-test.roc @@ -8,7 +8,7 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line! "" + Stdout.line!("") import Bowling exposing [Game, create, roll, score] @@ -28,8 +28,8 @@ replay_game = |rolls| # should be able to score a game with all zeros expect maybe_game = create { previous_rolls: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] } - result = maybe_game |> Result.try |game| score game - result == Ok 0 + result = maybe_game |> Result.try |game| score(game) + result == Ok(0) # should be able to replay this finished game from the start expect @@ -40,8 +40,8 @@ expect # should be able to score a game with no strikes or spares expect maybe_game = create { previous_rolls: [3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6] } - result = maybe_game |> Result.try |game| score game - result == Ok 90 + result = maybe_game |> Result.try |game| score(game) + result == Ok(90) # should be able to replay this finished game from the start expect @@ -52,8 +52,8 @@ expect # a spare followed by zeros is worth ten points expect maybe_game = create { previous_rolls: [6, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] } - result = maybe_game |> Result.try |game| score game - result == Ok 10 + result = maybe_game |> Result.try |game| score(game) + result == Ok(10) # should be able to replay this finished game from the start expect @@ -64,8 +64,8 @@ expect # points scored in the roll after a spare are counted twice expect maybe_game = create { previous_rolls: [6, 4, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] } - result = maybe_game |> Result.try |game| score game - result == Ok 16 + result = maybe_game |> Result.try |game| score(game) + result == Ok(16) # should be able to replay this finished game from the start expect @@ -76,8 +76,8 @@ expect # consecutive spares each get a one roll bonus expect maybe_game = create { previous_rolls: [5, 5, 3, 7, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] } - result = maybe_game |> Result.try |game| score game - result == Ok 31 + result = maybe_game |> Result.try |game| score(game) + result == Ok(31) # should be able to replay this finished game from the start expect @@ -88,8 +88,8 @@ expect # a spare in the last frame gets a one roll bonus that is counted once expect maybe_game = create { previous_rolls: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 3, 7] } - result = maybe_game |> Result.try |game| score game - result == Ok 17 + result = maybe_game |> Result.try |game| score(game) + result == Ok(17) # should be able to replay this finished game from the start expect @@ -100,8 +100,8 @@ expect # a strike earns ten points in a frame with a single roll expect maybe_game = create { previous_rolls: [10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] } - result = maybe_game |> Result.try |game| score game - result == Ok 10 + result = maybe_game |> Result.try |game| score(game) + result == Ok(10) # should be able to replay this finished game from the start expect @@ -112,8 +112,8 @@ expect # points scored in the two rolls after a strike are counted twice as a bonus expect maybe_game = create { previous_rolls: [10, 5, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] } - result = maybe_game |> Result.try |game| score game - result == Ok 26 + result = maybe_game |> Result.try |game| score(game) + result == Ok(26) # should be able to replay this finished game from the start expect @@ -124,8 +124,8 @@ expect # consecutive strikes each get the two roll bonus expect maybe_game = create { previous_rolls: [10, 10, 10, 5, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] } - result = maybe_game |> Result.try |game| score game - result == Ok 81 + result = maybe_game |> Result.try |game| score(game) + result == Ok(81) # should be able to replay this finished game from the start expect @@ -136,8 +136,8 @@ expect # a strike in the last frame gets a two roll bonus that is counted once expect maybe_game = create { previous_rolls: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 7, 1] } - result = maybe_game |> Result.try |game| score game - result == Ok 18 + result = maybe_game |> Result.try |game| score(game) + result == Ok(18) # should be able to replay this finished game from the start expect @@ -148,8 +148,8 @@ expect # rolling a spare with the two roll bonus does not get a bonus roll expect maybe_game = create { previous_rolls: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 7, 3] } - result = maybe_game |> Result.try |game| score game - result == Ok 20 + result = maybe_game |> Result.try |game| score(game) + result == Ok(20) # should be able to replay this finished game from the start expect @@ -160,8 +160,8 @@ expect # strikes with the two roll bonus do not get bonus rolls expect maybe_game = create { previous_rolls: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 10, 10] } - result = maybe_game |> Result.try |game| score game - result == Ok 30 + result = maybe_game |> Result.try |game| score(game) + result == Ok(30) # should be able to replay this finished game from the start expect @@ -172,8 +172,8 @@ expect # last two strikes followed by only last bonus with non strike points expect maybe_game = create { previous_rolls: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 10, 0, 1] } - result = maybe_game |> Result.try |game| score game - result == Ok 31 + result = maybe_game |> Result.try |game| score(game) + result == Ok(31) # should be able to replay this finished game from the start expect @@ -184,8 +184,8 @@ expect # a strike with the one roll bonus after a spare in the last frame does not get a bonus expect maybe_game = create { previous_rolls: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 3, 10] } - result = maybe_game |> Result.try |game| score game - result == Ok 20 + result = maybe_game |> Result.try |game| score(game) + result == Ok(20) # should be able to replay this finished game from the start expect @@ -196,8 +196,8 @@ expect # all strikes is a perfect game expect maybe_game = create { previous_rolls: [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10] } - result = maybe_game |> Result.try |game| score game - result == Ok 300 + result = maybe_game |> Result.try |game| score(game) + result == Ok(300) # should be able to replay this finished game from the start expect @@ -211,7 +211,7 @@ expect result = maybe_game |> Result.try |game| - game |> roll 11 + game |> roll(11) result |> Result.is_err # two rolls in a frame cannot score more than 10 points @@ -220,7 +220,7 @@ expect result = maybe_game |> Result.try |game| - game |> roll 6 + game |> roll(6) result |> Result.is_err # bonus roll after a strike in the last frame cannot score more than 10 points @@ -229,7 +229,7 @@ expect result = maybe_game |> Result.try |game| - game |> roll 11 + game |> roll(11) result |> Result.is_err # two bonus rolls after a strike in the last frame cannot score more than 10 points @@ -238,14 +238,14 @@ expect result = maybe_game |> Result.try |game| - game |> roll 6 + game |> roll(6) result |> Result.is_err # two bonus rolls after a strike in the last frame can score more than 10 points if one is a strike expect maybe_game = create { previous_rolls: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 10, 6] } - result = maybe_game |> Result.try |game| score game - result == Ok 26 + result = maybe_game |> Result.try |game| score(game) + result == Ok(26) # should be able to replay this finished game from the start expect @@ -259,7 +259,7 @@ expect result = maybe_game |> Result.try |game| - game |> roll 10 + game |> roll(10) result |> Result.is_err # second bonus roll after a strike in the last frame cannot score more than 10 points @@ -268,19 +268,19 @@ expect result = maybe_game |> Result.try |game| - game |> roll 11 + game |> roll(11) result |> Result.is_err # an unstarted game cannot be scored expect maybe_game = create { previous_rolls: [] } - result = maybe_game |> Result.try |game| score game + result = maybe_game |> Result.try |game| score(game) result |> Result.is_err # an incomplete game cannot be scored expect maybe_game = create { previous_rolls: [0, 0] } - result = maybe_game |> Result.try |game| score game + result = maybe_game |> Result.try |game| score(game) result |> Result.is_err # cannot roll if game already has ten frames @@ -289,25 +289,25 @@ expect result = maybe_game |> Result.try |game| - game |> roll 0 + game |> roll(0) result |> Result.is_err # bonus rolls for a strike in the last frame must be rolled before score can be calculated expect maybe_game = create { previous_rolls: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10] } - result = maybe_game |> Result.try |game| score game + result = maybe_game |> Result.try |game| score(game) result |> Result.is_err # both bonus rolls for a strike in the last frame must be rolled before score can be calculated expect maybe_game = create { previous_rolls: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 10] } - result = maybe_game |> Result.try |game| score game + result = maybe_game |> Result.try |game| score(game) result |> Result.is_err # bonus roll for a spare in the last frame must be rolled before score can be calculated expect maybe_game = create { previous_rolls: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 3] } - result = maybe_game |> Result.try |game| score game + result = maybe_game |> Result.try |game| score(game) result |> Result.is_err # cannot roll after bonus roll for spare @@ -316,7 +316,7 @@ expect result = maybe_game |> Result.try |game| - game |> roll 2 + game |> roll(2) result |> Result.is_err # cannot roll after bonus rolls for strike @@ -325,6 +325,6 @@ expect result = maybe_game |> Result.try |game| - game |> roll 2 + game |> roll(2) result |> Result.is_err diff --git a/exercises/practice/change/.meta/template.j2 b/exercises/practice/change/.meta/template.j2 index e689e598..372bf523 100644 --- a/exercises/practice/change/.meta/template.j2 +++ b/exercises/practice/change/.meta/template.j2 @@ -8,7 +8,7 @@ import {{ exercise | to_pascal }} exposing [{{ cases[0]["property"] | to_snake } # {{ case["description"] }} expect coins = {{ case["input"]["coins"] | to_roc }} - result = coins |> {{ case["property"] | to_snake }} {{ case["input"]["target"] }} + result = coins |> {{ case["property"] | to_snake }}({{ case["input"]["target"] }}) {%- if case["expected"]["error"] %} result |> Result.is_err {%- else %} diff --git a/exercises/practice/change/change-test.roc b/exercises/practice/change/change-test.roc index 35705306..3f1bf081 100644 --- a/exercises/practice/change/change-test.roc +++ b/exercises/practice/change/change-test.roc @@ -8,79 +8,79 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line! "" + Stdout.line!("") import Change exposing [find_fewest_coins] # change for 1 cent expect coins = [1, 5, 10, 25] - result = coins |> find_fewest_coins 1 + result = coins |> find_fewest_coins(1) result == Ok [1] # single coin change expect coins = [1, 5, 10, 25, 100] - result = coins |> find_fewest_coins 25 + result = coins |> find_fewest_coins(25) result == Ok [25] # multiple coin change expect coins = [1, 5, 10, 25, 100] - result = coins |> find_fewest_coins 15 + result = coins |> find_fewest_coins(15) result == Ok [5, 10] # change with Lilliputian Coins expect coins = [1, 4, 15, 20, 50] - result = coins |> find_fewest_coins 23 + result = coins |> find_fewest_coins(23) result == Ok [4, 4, 15] # change with Lower Elbonia Coins expect coins = [1, 5, 10, 21, 25] - result = coins |> find_fewest_coins 63 + result = coins |> find_fewest_coins(63) result == Ok [21, 21, 21] # large target values expect coins = [1, 2, 5, 10, 20, 50, 100] - result = coins |> find_fewest_coins 999 + result = coins |> find_fewest_coins(999) result == Ok [2, 2, 5, 20, 20, 50, 100, 100, 100, 100, 100, 100, 100, 100, 100] # possible change without unit coins available expect coins = [2, 5, 10, 20, 50] - result = coins |> find_fewest_coins 21 + result = coins |> find_fewest_coins(21) result == Ok [2, 2, 2, 5, 10] # another possible change without unit coins available expect coins = [4, 5] - result = coins |> find_fewest_coins 27 + result = coins |> find_fewest_coins(27) result == Ok [4, 4, 4, 5, 5, 5] # a greedy approach is not optimal expect coins = [1, 10, 11] - result = coins |> find_fewest_coins 20 + result = coins |> find_fewest_coins(20) result == Ok [10, 10] # no coins make 0 change expect coins = [1, 5, 10, 21, 25] - result = coins |> find_fewest_coins 0 + result = coins |> find_fewest_coins(0) result == Ok [] # error testing for change smaller than the smallest of coins expect coins = [5, 10] - result = coins |> find_fewest_coins 3 + result = coins |> find_fewest_coins(3) result |> Result.is_err # error if no combination can add up to target expect coins = [5, 10] - result = coins |> find_fewest_coins 94 + result = coins |> find_fewest_coins(94) result |> Result.is_err diff --git a/exercises/practice/circular-buffer/.meta/template.j2 b/exercises/practice/circular-buffer/.meta/template.j2 index ff9ecd3e..6a9ce081 100644 --- a/exercises/practice/circular-buffer/.meta/template.j2 +++ b/exercises/practice/circular-buffer/.meta/template.j2 @@ -25,11 +25,11 @@ run_operations{{ loop.index }} = |_| {%- endif %} {%- elif op["operation"] == "read" %} {%- if op["should_succeed"] %} - |> read? |> \read_result -> + |> read? |> |read_result| expect read_result.value == {{ op["expected"] }} read_result.new_buffer {%- else %} - |> \buffer_before_read -> + |> |buffer_before_read| read_result = buffer_before_read |> read expect read_result == Err BufferEmpty buffer_before_read diff --git a/exercises/practice/circular-buffer/circular-buffer-test.roc b/exercises/practice/circular-buffer/circular-buffer-test.roc index e37a4731..eedfe246 100644 --- a/exercises/practice/circular-buffer/circular-buffer-test.roc +++ b/exercises/practice/circular-buffer/circular-buffer-test.roc @@ -8,7 +8,7 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line! "" + Stdout.line!("") import CircularBuffer exposing [create, read, write, overwrite, clear] diff --git a/exercises/practice/clock/.meta/template.j2 b/exercises/practice/clock/.meta/template.j2 index 8748b4b9..4c98e23a 100644 --- a/exercises/practice/clock/.meta/template.j2 +++ b/exercises/practice/clock/.meta/template.j2 @@ -16,7 +16,7 @@ expect {%- elif case["property"] in ["add", "subtract"] %} expect clock = create {{ plugins.to_hours_minutes_record(case["input"]) }} - result = clock |> {{ case["property"] | to_snake }} { minutes: {{ case["input"]["value"] }} } |> to_str + result = clock |> {{ case["property"] | to_snake }}({ minutes: {{ case["input"]["value"] }} }) |> to_str expected = {{ case["expected"] | to_roc }} result == expected {%- elif case["property"] == "equal" %} diff --git a/exercises/practice/clock/clock-test.roc b/exercises/practice/clock/clock-test.roc index 3e7d74f9..93b43591 100644 --- a/exercises/practice/clock/clock-test.roc +++ b/exercises/practice/clock/clock-test.roc @@ -8,7 +8,7 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line! "" + Stdout.line!("") import Clock exposing [create, add, subtract, to_str] @@ -163,56 +163,56 @@ expect # add minutes expect clock = create { hours: 10 } - result = clock |> add { minutes: 3 } |> to_str + result = clock |> add({ minutes: 3 }) |> to_str expected = "10:03" result == expected # add no minutes expect clock = create { hours: 6, minutes: 41 } - result = clock |> add { minutes: 0 } |> to_str + result = clock |> add({ minutes: 0 }) |> to_str expected = "06:41" result == expected # add to next hour expect clock = create { minutes: 45 } - result = clock |> add { minutes: 40 } |> to_str + result = clock |> add({ minutes: 40 }) |> to_str expected = "01:25" result == expected # add more than one hour expect clock = create { hours: 10 } - result = clock |> add { minutes: 61 } |> to_str + result = clock |> add({ minutes: 61 }) |> to_str expected = "11:01" result == expected # add more than two hours with carry expect clock = create { minutes: 45 } - result = clock |> add { minutes: 160 } |> to_str + result = clock |> add({ minutes: 160 }) |> to_str expected = "03:25" result == expected # add across midnight expect clock = create { hours: 23, minutes: 59 } - result = clock |> add { minutes: 2 } |> to_str + result = clock |> add({ minutes: 2 }) |> to_str expected = "00:01" result == expected # add more than one day (1500 min = 25 hrs) expect clock = create { hours: 5, minutes: 32 } - result = clock |> add { minutes: 1500 } |> to_str + result = clock |> add({ minutes: 1500 }) |> to_str expected = "06:32" result == expected # add more than two days expect clock = create { hours: 1, minutes: 1 } - result = clock |> add { minutes: 3500 } |> to_str + result = clock |> add({ minutes: 3500 }) |> to_str expected = "11:21" result == expected @@ -223,56 +223,56 @@ expect # subtract minutes expect clock = create { hours: 10, minutes: 3 } - result = clock |> subtract { minutes: 3 } |> to_str + result = clock |> subtract({ minutes: 3 }) |> to_str expected = "10:00" result == expected # subtract to previous hour expect clock = create { hours: 10, minutes: 3 } - result = clock |> subtract { minutes: 30 } |> to_str + result = clock |> subtract({ minutes: 30 }) |> to_str expected = "09:33" result == expected # subtract more than an hour expect clock = create { hours: 10, minutes: 3 } - result = clock |> subtract { minutes: 70 } |> to_str + result = clock |> subtract({ minutes: 70 }) |> to_str expected = "08:53" result == expected # subtract across midnight expect clock = create { minutes: 3 } - result = clock |> subtract { minutes: 4 } |> to_str + result = clock |> subtract({ minutes: 4 }) |> to_str expected = "23:59" result == expected # subtract more than two hours expect clock = create {} - result = clock |> subtract { minutes: 160 } |> to_str + result = clock |> subtract({ minutes: 160 }) |> to_str expected = "21:20" result == expected # subtract more than two hours with borrow expect clock = create { hours: 6, minutes: 15 } - result = clock |> subtract { minutes: 160 } |> to_str + result = clock |> subtract({ minutes: 160 }) |> to_str expected = "03:35" result == expected # subtract more than one day (1500 min = 25 hrs) expect clock = create { hours: 5, minutes: 32 } - result = clock |> subtract { minutes: 1500 } |> to_str + result = clock |> subtract({ minutes: 1500 }) |> to_str expected = "04:32" result == expected # subtract more than two days expect clock = create { hours: 2, minutes: 20 } - result = clock |> subtract { minutes: 3000 } |> to_str + result = clock |> subtract({ minutes: 3000 }) |> to_str expected = "00:20" result == expected @@ -397,28 +397,28 @@ expect # Can add max I64 values to a clock expect clock = create { hours: 23, minutes: 59 } - result = clock |> add { minutes: 9223372036854775807 } |> to_str + result = clock |> add({ minutes: 9223372036854775807 }) |> to_str expected = "18:06" result == expected # Can add min I64 values to a clock expect clock = create { hours: 23, minutes: 59 } - result = clock |> add { minutes: -9223372036854775808 } |> to_str + result = clock |> add({ minutes: -9223372036854775808 }) |> to_str expected = "05:51" result == expected # Can subtract max I64 values from a clock expect clock = create { hours: 23, minutes: 59 } - result = clock |> subtract { minutes: 9223372036854775807 } |> to_str + result = clock |> subtract({ minutes: 9223372036854775807 }) |> to_str expected = "05:52" result == expected # Can subtract min I64 values from a clock expect clock = create { hours: 23, minutes: 59 } - result = clock |> subtract { minutes: -9223372036854775808 } |> to_str + result = clock |> subtract({ minutes: -9223372036854775808 }) |> to_str expected = "18:07" result == expected diff --git a/exercises/practice/collatz-conjecture/.meta/template.j2 b/exercises/practice/collatz-conjecture/.meta/template.j2 index 580a826e..5859e457 100644 --- a/exercises/practice/collatz-conjecture/.meta/template.j2 +++ b/exercises/practice/collatz-conjecture/.meta/template.j2 @@ -7,7 +7,7 @@ import {{ exercise | to_pascal }} exposing [steps] {% for case in cases -%} # {{ case["description"] }} expect - result = {{ case["property"] | to_snake }} {{ case["input"]["number"] }} + result = {{ case["property"] | to_snake }}({{ case["input"]["number"] }}) {%- if case["expected"]["error"] %} Result.is_err result {%- else %} diff --git a/exercises/practice/collatz-conjecture/collatz-conjecture-test.roc b/exercises/practice/collatz-conjecture/collatz-conjecture-test.roc index 2e4b0c32..54bb20f8 100644 --- a/exercises/practice/collatz-conjecture/collatz-conjecture-test.roc +++ b/exercises/practice/collatz-conjecture/collatz-conjecture-test.roc @@ -8,32 +8,32 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line! "" + Stdout.line!("") import CollatzConjecture exposing [steps] # zero steps for one expect - result = steps 1 + result = steps(1) result == Ok 0 # divide if even expect - result = steps 16 + result = steps(16) result == Ok 4 # even and odd steps expect - result = steps 12 + result = steps(12) result == Ok 9 # large number of even and odd steps expect - result = steps 1000000 + result = steps(1000000) result == Ok 152 # zero is an error expect - result = steps 0 + result = steps(0) Result.is_err result diff --git a/exercises/practice/complex-numbers/complex-numbers-test.roc b/exercises/practice/complex-numbers/complex-numbers-test.roc index 9d818e03..bad13743 100644 --- a/exercises/practice/complex-numbers/complex-numbers-test.roc +++ b/exercises/practice/complex-numbers/complex-numbers-test.roc @@ -8,7 +8,7 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line! "" + Stdout.line!("") import ComplexNumbers exposing [real, imaginary, add, sub, mul, div, conjugate, abs, exp] diff --git a/exercises/practice/connect/connect-test.roc b/exercises/practice/connect/connect-test.roc index bfa91d0c..de464c8d 100644 --- a/exercises/practice/connect/connect-test.roc +++ b/exercises/practice/connect/connect-test.roc @@ -8,7 +8,7 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line! "" + Stdout.line!("") import Connect exposing [winner] diff --git a/exercises/practice/crypto-square/.meta/template.j2 b/exercises/practice/crypto-square/.meta/template.j2 index 18b27565..be3e8b42 100644 --- a/exercises/practice/crypto-square/.meta/template.j2 +++ b/exercises/practice/crypto-square/.meta/template.j2 @@ -8,8 +8,8 @@ import {{ exercise | to_pascal }} exposing [{{ cases[0]["property"] | to_snake } # {{ case["description"] }} expect text = {{ case["input"]["plaintext"] | to_roc }} - result = {{ case["property"] | to_snake }} text - expected = Ok {{ case["expected"] | to_roc }} + result = {{ case["property"] | to_snake }}(text) + expected = Ok({{ case["expected"] | to_roc }}) result == expected {% endfor %} diff --git a/exercises/practice/crypto-square/crypto-square-test.roc b/exercises/practice/crypto-square/crypto-square-test.roc index e413450a..0d7dd196 100644 --- a/exercises/practice/crypto-square/crypto-square-test.roc +++ b/exercises/practice/crypto-square/crypto-square-test.roc @@ -8,63 +8,63 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line! "" + Stdout.line!("") import CryptoSquare exposing [ciphertext] # empty plaintext results in an empty ciphertext expect text = "" - result = ciphertext text - expected = Ok "" + result = ciphertext(text) + expected = Ok("") result == expected # normalization results in empty plaintext expect text = "... --- ..." - result = ciphertext text - expected = Ok "" + result = ciphertext(text) + expected = Ok("") result == expected # Lowercase expect text = "A" - result = ciphertext text - expected = Ok "a" + result = ciphertext(text) + expected = Ok("a") result == expected # Remove spaces expect text = " b " - result = ciphertext text - expected = Ok "b" + result = ciphertext(text) + expected = Ok("b") result == expected # Remove punctuation expect text = "@1,%!" - result = ciphertext text - expected = Ok "1" + result = ciphertext(text) + expected = Ok("1") result == expected # 9 character plaintext results in 3 chunks of 3 characters expect text = "This is fun!" - result = ciphertext text - expected = Ok "tsf hiu isn" + result = ciphertext(text) + expected = Ok("tsf hiu isn") result == expected # 8 character plaintext results in 3 chunks, the last one with a trailing space expect text = "Chill out." - result = ciphertext text - expected = Ok "clu hlt io " + result = ciphertext(text) + expected = Ok("clu hlt io ") result == expected # 54 character plaintext results in 8 chunks, the last two with trailing spaces expect text = "If man was meant to stay on the ground, god would have given us roots." - result = ciphertext text - expected = Ok "imtgdvs fearwer mayoogo anouuio ntnnlvt wttddes aohghn sseoau " + result = ciphertext(text) + expected = Ok("imtgdvs fearwer mayoogo anouuio ntnnlvt wttddes aohghn sseoau ") result == expected diff --git a/exercises/practice/custom-set/custom-set-test.roc b/exercises/practice/custom-set/custom-set-test.roc index a96d0973..bfab4da7 100644 --- a/exercises/practice/custom-set/custom-set-test.roc +++ b/exercises/practice/custom-set/custom-set-test.roc @@ -8,7 +8,7 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line! "" + Stdout.line!("") import CustomSet exposing [ contains, diff --git a/exercises/practice/darts/.meta/template.j2 b/exercises/practice/darts/.meta/template.j2 index 1f2a9d98..1aa085d5 100644 --- a/exercises/practice/darts/.meta/template.j2 +++ b/exercises/practice/darts/.meta/template.j2 @@ -7,7 +7,7 @@ import Darts exposing [score] {% for case in cases -%} # {{ case["description"] }} expect - result = {{ case["property"] | to_snake }} {{ case["input"]["x"] | to_roc_float }} {{ case["input"]["y"] | to_roc_float }} + result = {{ case["property"] | to_snake }}({{ case["input"]["x"] | to_roc_float }}, {{ case["input"]["y"] | to_roc_float }}) result == {{ case["expected"] }} {% endfor %} diff --git a/exercises/practice/darts/darts-test.roc b/exercises/practice/darts/darts-test.roc index 7751045a..2616dc2e 100644 --- a/exercises/practice/darts/darts-test.roc +++ b/exercises/practice/darts/darts-test.roc @@ -8,72 +8,72 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line! "" + Stdout.line!("") import Darts exposing [score] # Missed target expect - result = score -9.0f64 9.0f64 + result = score(-9.0f64, 9.0f64) result == 0 # On the outer circle expect - result = score 0.0f64 10.0f64 + result = score(0.0f64, 10.0f64) result == 1 # On the middle circle expect - result = score -5.0f64 0.0f64 + result = score(-5.0f64, 0.0f64) result == 5 # On the inner circle expect - result = score 0.0f64 -1.0f64 + result = score(0.0f64, -1.0f64) result == 10 # Exactly on center expect - result = score 0.0f64 0.0f64 + result = score(0.0f64, 0.0f64) result == 10 # Near the center expect - result = score -0.1f64 -0.1f64 + result = score(-0.1f64, -0.1f64) result == 10 # Just within the inner circle expect - result = score 0.7f64 0.7f64 + result = score(0.7f64, 0.7f64) result == 10 # Just outside the inner circle expect - result = score 0.8f64 -0.8f64 + result = score(0.8f64, -0.8f64) result == 5 # Just within the middle circle expect - result = score -3.5f64 3.5f64 + result = score(-3.5f64, 3.5f64) result == 5 # Just outside the middle circle expect - result = score -3.6f64 -3.6f64 + result = score(-3.6f64, -3.6f64) result == 1 # Just within the outer circle expect - result = score -7.0f64 7.0f64 + result = score(-7.0f64, 7.0f64) result == 1 # Just outside the outer circle expect - result = score 7.1f64 -7.1f64 + result = score(7.1f64, -7.1f64) result == 0 # Asymmetric position between the inner and middle circles expect - result = score 0.5f64 -4.0f64 + result = score(0.5f64, -4.0f64) result == 5 diff --git a/exercises/practice/diamond/.meta/template.j2 b/exercises/practice/diamond/.meta/template.j2 index ed46b6ee..348be2e9 100644 --- a/exercises/practice/diamond/.meta/template.j2 +++ b/exercises/practice/diamond/.meta/template.j2 @@ -7,8 +7,8 @@ import {{ exercise | to_pascal }} exposing [{{ exercise | to_snake }}] {% for case in cases -%} # {{ case["description"] }} expect - result = {{ exercise | to_snake }} '{{ case["input"]["letter"] }}' - expected = {{ case["expected"] | to_roc_multiline_string | replace(" ", "·") | indent(8) }} |> Str.replace_each "·" " " + result = {{ exercise | to_snake }}('{{ case["input"]["letter"] }}') + expected = {{ case["expected"] | to_roc_multiline_string | replace(" ", "·") | indent(8) }} |> Str.replace_each("·", " ") result == expected {% endfor %} diff --git a/exercises/practice/diamond/diamond-test.roc b/exercises/practice/diamond/diamond-test.roc index 87ae32a1..e461abe5 100644 --- a/exercises/practice/diamond/diamond-test.roc +++ b/exercises/practice/diamond/diamond-test.roc @@ -8,31 +8,31 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line! "" + Stdout.line!("") import Diamond exposing [diamond] # Degenerate case with a single 'A' row expect - result = diamond 'A' - expected = "A" |> Str.replace_each "·" " " + result = diamond('A') + expected = "A" |> Str.replace_each("·", " ") result == expected # Degenerate case with no row containing 3 distinct groups of spaces expect - result = diamond 'B' + result = diamond('B') expected = """ ·A· B·B ·A· """ - |> Str.replace_each "·" " " + |> Str.replace_each("·", " ") result == expected # Smallest non-degenerate case with odd diamond side length expect - result = diamond 'C' + result = diamond('C') expected = """ ··A·· @@ -41,12 +41,12 @@ expect ·B·B· ··A·· """ - |> Str.replace_each "·" " " + |> Str.replace_each("·", " ") result == expected # Smallest non-degenerate case with even diamond side length expect - result = diamond 'D' + result = diamond('D') expected = """ ···A··· @@ -57,12 +57,12 @@ expect ··B·B·· ···A··· """ - |> Str.replace_each "·" " " + |> Str.replace_each("·", " ") result == expected # Largest possible diamond expect - result = diamond 'Z' + result = diamond('Z') expected = """ ·························A························· @@ -117,6 +117,6 @@ expect ························B·B························ ·························A························· """ - |> Str.replace_each "·" " " + |> Str.replace_each("·", " ") result == expected diff --git a/exercises/practice/difference-of-squares/.meta/template.j2 b/exercises/practice/difference-of-squares/.meta/template.j2 index 59b84b7c..23bf22a3 100644 --- a/exercises/practice/difference-of-squares/.meta/template.j2 +++ b/exercises/practice/difference-of-squares/.meta/template.j2 @@ -12,7 +12,7 @@ import DifferenceOfSquares exposing [square_of_sum, sum_of_squares, difference_o {% for case in supercase["cases"] -%} # {{ case["description"] }} expect - result = {{ case["property"] | to_snake }} {{ case["input"]["number"] }} + result = {{ case["property"] | to_snake }}({{ case["input"]["number"] }}) result == {{ case["expected"] }} {% endfor %} diff --git a/exercises/practice/difference-of-squares/difference-of-squares-test.roc b/exercises/practice/difference-of-squares/difference-of-squares-test.roc index d46c00e6..1222aef7 100644 --- a/exercises/practice/difference-of-squares/difference-of-squares-test.roc +++ b/exercises/practice/difference-of-squares/difference-of-squares-test.roc @@ -8,7 +8,7 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line! "" + Stdout.line!("") import DifferenceOfSquares exposing [square_of_sum, sum_of_squares, difference_of_squares] @@ -18,17 +18,17 @@ import DifferenceOfSquares exposing [square_of_sum, sum_of_squares, difference_o # square of sum 1 expect - result = square_of_sum 1 + result = square_of_sum(1) result == 1 # square of sum 5 expect - result = square_of_sum 5 + result = square_of_sum(5) result == 225 # square of sum 100 expect - result = square_of_sum 100 + result = square_of_sum(100) result == 25502500 ## @@ -37,17 +37,17 @@ expect # sum of squares 1 expect - result = sum_of_squares 1 + result = sum_of_squares(1) result == 1 # sum of squares 5 expect - result = sum_of_squares 5 + result = sum_of_squares(5) result == 55 # sum of squares 100 expect - result = sum_of_squares 100 + result = sum_of_squares(100) result == 338350 ## @@ -56,16 +56,16 @@ expect # difference of squares 1 expect - result = difference_of_squares 1 + result = difference_of_squares(1) result == 0 # difference of squares 5 expect - result = difference_of_squares 5 + result = difference_of_squares(5) result == 170 # difference of squares 100 expect - result = difference_of_squares 100 + result = difference_of_squares(100) result == 25164150 diff --git a/exercises/practice/dominoes/dominoes-test.roc b/exercises/practice/dominoes/dominoes-test.roc index 36a4056c..4fdfae62 100644 --- a/exercises/practice/dominoes/dominoes-test.roc +++ b/exercises/practice/dominoes/dominoes-test.roc @@ -8,7 +8,7 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line! "" + Stdout.line!("") import Dominoes exposing [find_chain] diff --git a/exercises/practice/eliuds-eggs/.meta/template.j2 b/exercises/practice/eliuds-eggs/.meta/template.j2 index 196d5020..bfe5d436 100644 --- a/exercises/practice/eliuds-eggs/.meta/template.j2 +++ b/exercises/practice/eliuds-eggs/.meta/template.j2 @@ -7,7 +7,7 @@ import {{ exercise | to_pascal }} exposing [{{ cases[0]["property"] | to_snake } {% for case in cases -%} # {{ case["description"] }} expect - result = {{ case["property"] | to_snake }} {{ case["input"]["number"] | to_roc }} + result = {{ case["property"] | to_snake }}({{ case["input"]["number"] | to_roc }}) result == {{ case["expected"] | to_roc }} {% endfor %} diff --git a/exercises/practice/eliuds-eggs/eliuds-eggs-test.roc b/exercises/practice/eliuds-eggs/eliuds-eggs-test.roc index 733c66be..2bdad812 100644 --- a/exercises/practice/eliuds-eggs/eliuds-eggs-test.roc +++ b/exercises/practice/eliuds-eggs/eliuds-eggs-test.roc @@ -8,27 +8,27 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line! "" + Stdout.line!("") import EliudsEggs exposing [egg_count] # 0 eggs expect - result = egg_count 0 + result = egg_count(0) result == 0 # 1 egg expect - result = egg_count 16 + result = egg_count(16) result == 1 # 4 eggs expect - result = egg_count 89 + result = egg_count(89) result == 4 # 13 eggs expect - result = egg_count 2000000000 + result = egg_count(2000000000) result == 13 diff --git a/exercises/practice/etl/etl-test.roc b/exercises/practice/etl/etl-test.roc index c14f4bf7..7ea1bfbd 100644 --- a/exercises/practice/etl/etl-test.roc +++ b/exercises/practice/etl/etl-test.roc @@ -8,7 +8,7 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line! "" + Stdout.line!("") import Etl exposing [transform] diff --git a/exercises/practice/flatten-array/.meta/template.j2 b/exercises/practice/flatten-array/.meta/template.j2 index a36cde7d..8314785c 100644 --- a/exercises/practice/flatten-array/.meta/template.j2 +++ b/exercises/practice/flatten-array/.meta/template.j2 @@ -7,7 +7,7 @@ import {{ exercise | to_pascal }} exposing [{{ cases[0]["property"] | to_snake } {% for case in cases -%} # {{ case["description"] }} expect - result = {{ case["property"] | to_snake }} ({{ plugins.to_nested(case["input"]["array"]) }}) + result = {{ case["property"] | to_snake }}(({{ plugins.to_nested(case["input"]["array"]) }})) result == {{ case["expected"] | to_roc }} {% endfor %} diff --git a/exercises/practice/flatten-array/flatten-array-test.roc b/exercises/practice/flatten-array/flatten-array-test.roc index 63203f75..b31a60d7 100644 --- a/exercises/practice/flatten-array/flatten-array-test.roc +++ b/exercises/practice/flatten-array/flatten-array-test.roc @@ -8,211 +8,200 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line! "" + Stdout.line!("") import FlattenArray exposing [flatten] # empty expect - result = flatten - ( - NestedArray [ - ] - ) + result = flatten( + NestedArray [ + ], + ) result == [] # no nesting expect - result = flatten - ( - NestedArray [ - Value 0, - Value 1, - Value 2, - ] - ) + result = flatten( + NestedArray [ + Value 0, + Value 1, + Value 2, + ], + ) result == [0, 1, 2] # flattens a nested array expect - result = flatten - ( + result = flatten( + NestedArray [ NestedArray [ NestedArray [ - NestedArray [ - ], ], - ] - ) + ], + ], + ) result == [] # flattens array with just integers present expect - result = flatten - ( + result = flatten( + NestedArray [ + Value 1, NestedArray [ - Value 1, - NestedArray [ - Value 2, - Value 3, - Value 4, - Value 5, - Value 6, - Value 7, - ], - Value 8, - ] - ) + Value 2, + Value 3, + Value 4, + Value 5, + Value 6, + Value 7, + ], + Value 8, + ], + ) result == [1, 2, 3, 4, 5, 6, 7, 8] # 5 level nesting expect - result = flatten - ( + result = flatten( + NestedArray [ + Value 0, + Value 2, NestedArray [ - Value 0, - Value 2, NestedArray [ - NestedArray [ - Value 2, - Value 3, - ], - Value 8, - Value 100, - Value 4, + Value 2, + Value 3, + ], + Value 8, + Value 100, + Value 4, + NestedArray [ NestedArray [ NestedArray [ - NestedArray [ - Value 50, - ], + Value 50, ], ], ], - Value -2, - ] - ) + ], + Value -2, + ], + ) result == [0, 2, 2, 3, 8, 100, 4, 50, -2] # 6 level nesting expect - result = flatten - ( + result = flatten( + NestedArray [ + Value 1, NestedArray [ - Value 1, + Value 2, NestedArray [ - Value 2, NestedArray [ - NestedArray [ - Value 3, - ], + Value 3, ], + ], + NestedArray [ + Value 4, NestedArray [ - Value 4, NestedArray [ - NestedArray [ - Value 5, - ], + Value 5, ], ], - Value 6, - Value 7, ], - Value 8, - ] - ) + Value 6, + Value 7, + ], + Value 8, + ], + ) result == [1, 2, 3, 4, 5, 6, 7, 8] # null values are omitted from the final result expect - result = flatten - ( - NestedArray [ - Value 1, - Value 2, - Null, - ] - ) + result = flatten( + NestedArray [ + Value 1, + Value 2, + Null, + ], + ) result == [1, 2] # consecutive null values at the front of the array are omitted from the final result expect - result = flatten - ( - NestedArray [ - Null, - Null, - Value 3, - ] - ) + result = flatten( + NestedArray [ + Null, + Null, + Value 3, + ], + ) result == [3] # consecutive null values in the middle of the array are omitted from the final result expect - result = flatten - ( - NestedArray [ - Value 1, - Null, - Null, - Value 4, - ] - ) + result = flatten( + NestedArray [ + Value 1, + Null, + Null, + Value 4, + ], + ) result == [1, 4] # 6 level nested array with null values expect - result = flatten - ( + result = flatten( + NestedArray [ + Value 0, + Value 2, NestedArray [ - Value 0, - Value 2, + NestedArray [ + Value 2, + Value 3, + ], + Value 8, NestedArray [ NestedArray [ - Value 2, - Value 3, - ], - Value 8, - NestedArray [ - NestedArray [ - Value 100, - ], + Value 100, ], - Null, + ], + Null, + NestedArray [ NestedArray [ - NestedArray [ - Null, - ], + Null, ], ], - Value -2, - ] - ) + ], + Value -2, + ], + ) result == [0, 2, 2, 3, 8, 100, -2] # all values in nested array are null expect - result = flatten - ( + result = flatten( + NestedArray [ + Null, NestedArray [ - Null, NestedArray [ NestedArray [ - NestedArray [ - Null, - ], + Null, ], ], - Null, - Null, + ], + Null, + Null, + NestedArray [ NestedArray [ - NestedArray [ - Null, - Null, - ], + Null, Null, ], Null, - ] - ) + ], + Null, + ], + ) result == [] diff --git a/exercises/practice/flower-field/.meta/template.j2 b/exercises/practice/flower-field/.meta/template.j2 index 34cd4b31..14eafc1f 100644 --- a/exercises/practice/flower-field/.meta/template.j2 +++ b/exercises/practice/flower-field/.meta/template.j2 @@ -7,9 +7,9 @@ import {{ exercise | to_pascal }} exposing [{{ cases[0]["property"] | to_snake } {% for case in cases -%} # {{ case["description"] }} expect - garden = {{ case["input"]["garden"] | to_roc_multiline_string | replace(" ", "·") | indent(8) }} |> Str.replace_each "·" " " - result = {{ case["property"] | to_snake }} garden - expected = {{ case["expected"] | to_roc_multiline_string | replace(" ", "·") | indent(8) }} |> Str.replace_each "·" " " + garden = {{ case["input"]["garden"] | to_roc_multiline_string | replace(" ", "·") | indent(8) }} |> Str.replace_each("·", " ") + result = {{ case["property"] | to_snake }}(garden) + expected = {{ case["expected"] | to_roc_multiline_string | replace(" ", "·") | indent(8) }} |> Str.replace_each("·", " ") result == expected {% endfor %} diff --git a/exercises/practice/flower-field/flower-field-test.roc b/exercises/practice/flower-field/flower-field-test.roc index 11b01541..99620535 100644 --- a/exercises/practice/flower-field/flower-field-test.roc +++ b/exercises/practice/flower-field/flower-field-test.roc @@ -8,22 +8,22 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line! "" + Stdout.line!("") import FlowerField exposing [annotate] # no rows expect - garden = "" |> Str.replace_each "·" " " - result = annotate garden - expected = "" |> Str.replace_each "·" " " + garden = "" |> Str.replace_each("·", " ") + result = annotate(garden) + expected = "" |> Str.replace_each("·", " ") result == expected # no columns expect - garden = "" |> Str.replace_each "·" " " - result = annotate garden - expected = "" |> Str.replace_each "·" " " + garden = "" |> Str.replace_each("·", " ") + result = annotate(garden) + expected = "" |> Str.replace_each("·", " ") result == expected # no flowers @@ -34,15 +34,15 @@ expect ··· ··· """ - |> Str.replace_each "·" " " - result = annotate garden + |> Str.replace_each("·", " ") + result = annotate(garden) expected = """ ··· ··· ··· """ - |> Str.replace_each "·" " " + |> Str.replace_each("·", " ") result == expected # garden full of flowers @@ -53,15 +53,15 @@ expect *** *** """ - |> Str.replace_each "·" " " - result = annotate garden + |> Str.replace_each("·", " ") + result = annotate(garden) expected = """ *** *** *** """ - |> Str.replace_each "·" " " + |> Str.replace_each("·", " ") result == expected # flower surrounded by spaces @@ -72,15 +72,15 @@ expect ·*· ··· """ - |> Str.replace_each "·" " " - result = annotate garden + |> Str.replace_each("·", " ") + result = annotate(garden) expected = """ 111 1*1 111 """ - |> Str.replace_each "·" " " + |> Str.replace_each("·", " ") result == expected # space surrounded by flowers @@ -91,29 +91,29 @@ expect *·* *** """ - |> Str.replace_each "·" " " - result = annotate garden + |> Str.replace_each("·", " ") + result = annotate(garden) expected = """ *** *8* *** """ - |> Str.replace_each "·" " " + |> Str.replace_each("·", " ") result == expected # horizontal line expect - garden = "·*·*·" |> Str.replace_each "·" " " - result = annotate garden - expected = "1*2*1" |> Str.replace_each "·" " " + garden = "·*·*·" |> Str.replace_each("·", " ") + result = annotate(garden) + expected = "1*2*1" |> Str.replace_each("·", " ") result == expected # horizontal line, flowers at edges expect - garden = "*···*" |> Str.replace_each "·" " " - result = annotate garden - expected = "*1·1*" |> Str.replace_each "·" " " + garden = "*···*" |> Str.replace_each("·", " ") + result = annotate(garden) + expected = "*1·1*" |> Str.replace_each("·", " ") result == expected # vertical line @@ -126,8 +126,8 @@ expect * · """ - |> Str.replace_each "·" " " - result = annotate garden + |> Str.replace_each("·", " ") + result = annotate(garden) expected = """ 1 @@ -136,7 +136,7 @@ expect * 1 """ - |> Str.replace_each "·" " " + |> Str.replace_each("·", " ") result == expected # vertical line, flowers at edges @@ -149,8 +149,8 @@ expect · * """ - |> Str.replace_each "·" " " - result = annotate garden + |> Str.replace_each("·", " ") + result = annotate(garden) expected = """ * @@ -159,7 +159,7 @@ expect 1 * """ - |> Str.replace_each "·" " " + |> Str.replace_each("·", " ") result == expected # cross @@ -172,8 +172,8 @@ expect ··*·· ··*·· """ - |> Str.replace_each "·" " " - result = annotate garden + |> Str.replace_each("·", " ") + result = annotate(garden) expected = """ ·2*2· @@ -182,7 +182,7 @@ expect 25*52 ·2*2· """ - |> Str.replace_each "·" " " + |> Str.replace_each("·", " ") result == expected # large garden @@ -196,8 +196,8 @@ expect ·*··*· ······ """ - |> Str.replace_each "·" " " - result = annotate garden + |> Str.replace_each("·", " ") + result = annotate(garden) expected = """ 1*22*1 @@ -207,6 +207,6 @@ expect 1*22*2 111111 """ - |> Str.replace_each "·" " " + |> Str.replace_each("·", " ") result == expected diff --git a/exercises/practice/food-chain/.meta/template.j2 b/exercises/practice/food-chain/.meta/template.j2 index 4826b8b1..18bdbc29 100644 --- a/exercises/practice/food-chain/.meta/template.j2 +++ b/exercises/practice/food-chain/.meta/template.j2 @@ -7,7 +7,7 @@ import {{ exercise | to_pascal }} exposing [{{ cases[0]["property"] | to_snake } {% for case in cases -%} # {{ case["description"] }} expect - result = {{ case["property"] | to_snake }} {{ case["input"]["startVerse"] | to_roc }} {{ case["input"]["endVerse"] | to_roc }} + result = {{ case["property"] | to_snake }}({{ case["input"]["startVerse"] | to_roc }}, {{ case["input"]["endVerse"] | to_roc }}) result == {{ case["expected"] | join('\n') | to_roc_multiline_string | indent(8) }} {% endfor %} \ No newline at end of file diff --git a/exercises/practice/food-chain/food-chain-test.roc b/exercises/practice/food-chain/food-chain-test.roc index 489b1cd8..90fe0d3e 100644 --- a/exercises/practice/food-chain/food-chain-test.roc +++ b/exercises/practice/food-chain/food-chain-test.roc @@ -8,13 +8,13 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line! "" + Stdout.line!("") import FoodChain exposing [recite] # fly expect - result = recite 1 1 + result = recite(1, 1) result == """ @@ -24,7 +24,7 @@ expect # spider expect - result = recite 2 2 + result = recite(2, 2) result == """ @@ -36,7 +36,7 @@ expect # bird expect - result = recite 3 3 + result = recite(3, 3) result == """ @@ -49,7 +49,7 @@ expect # cat expect - result = recite 4 4 + result = recite(4, 4) result == """ @@ -63,7 +63,7 @@ expect # dog expect - result = recite 5 5 + result = recite(5, 5) result == """ @@ -78,7 +78,7 @@ expect # goat expect - result = recite 6 6 + result = recite(6, 6) result == """ @@ -94,7 +94,7 @@ expect # cow expect - result = recite 7 7 + result = recite(7, 7) result == """ @@ -111,7 +111,7 @@ expect # horse expect - result = recite 8 8 + result = recite(8, 8) result == """ @@ -121,7 +121,7 @@ expect # multiple verses expect - result = recite 1 3 + result = recite(1, 3) result == """ @@ -142,7 +142,7 @@ expect # full song expect - result = recite 1 8 + result = recite(1, 8) result == """ diff --git a/exercises/practice/forth/forth-test.roc b/exercises/practice/forth/forth-test.roc index ff4c9c7c..76bb0b01 100644 --- a/exercises/practice/forth/forth-test.roc +++ b/exercises/practice/forth/forth-test.roc @@ -8,7 +8,7 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line! "" + Stdout.line!("") import Forth exposing [evaluate] diff --git a/exercises/practice/gigasecond/.meta/template.j2 b/exercises/practice/gigasecond/.meta/template.j2 index be2140c7..017461a6 100644 --- a/exercises/practice/gigasecond/.meta/template.j2 +++ b/exercises/practice/gigasecond/.meta/template.j2 @@ -7,7 +7,7 @@ import {{ exercise | to_pascal }} exposing [add] {% for case in cases -%} # {{ case["description"] }} expect - result = {{ case["property"] | to_snake }} {{ case["input"]["moment"] | to_roc }} + result = {{ case["property"] | to_snake }}({{ case["input"]["moment"] | to_roc }}) result == {{ case["expected"] | to_roc }} {% endfor %} diff --git a/exercises/practice/gigasecond/gigasecond-test.roc b/exercises/practice/gigasecond/gigasecond-test.roc index 70f6e6b7..68b5b3b2 100644 --- a/exercises/practice/gigasecond/gigasecond-test.roc +++ b/exercises/practice/gigasecond/gigasecond-test.roc @@ -9,32 +9,32 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line! "" + Stdout.line!("") import Gigasecond exposing [add] # date only specification of time expect - result = add "2011-04-25" + result = add("2011-04-25") result == "2043-01-01T01:46:40" # second test for date only specification of time expect - result = add "1977-06-13" + result = add("1977-06-13") result == "2009-02-19T01:46:40" # third test for date only specification of time expect - result = add "1959-07-19" + result = add("1959-07-19") result == "1991-03-27T01:46:40" # full time specified expect - result = add "2015-01-24T22:00:00" + result = add("2015-01-24T22:00:00") result == "2046-10-02T23:46:40" # full time with day roll-over expect - result = add "2015-01-24T23:59:59" + result = add("2015-01-24T23:59:59") result == "2046-10-03T01:46:39" diff --git a/exercises/practice/go-counting/go-counting-test.roc b/exercises/practice/go-counting/go-counting-test.roc index 0c1fd6d7..ec8c0498 100644 --- a/exercises/practice/go-counting/go-counting-test.roc +++ b/exercises/practice/go-counting/go-counting-test.roc @@ -8,7 +8,7 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line! "" + Stdout.line!("") import GoCounting exposing [territory, territories] diff --git a/exercises/practice/grains/grains-test.roc b/exercises/practice/grains/grains-test.roc index e4d816d7..1af91798 100644 --- a/exercises/practice/grains/grains-test.roc +++ b/exercises/practice/grains/grains-test.roc @@ -8,7 +8,7 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line! "" + Stdout.line!("") import Grains exposing [grains_on_square, total_grains] diff --git a/exercises/practice/grep/.meta/template.j2 b/exercises/practice/grep/.meta/template.j2 index 34afad90..77270f17 100644 --- a/exercises/practice/grep/.meta/template.j2 +++ b/exercises/practice/grep/.meta/template.j2 @@ -8,8 +8,8 @@ import {{ exercise | to_pascal }} exposing [grep] {% for innerCase in case["cases"] -%} # {{ case["description"] }} - {{ innerCase["description"] }} expect - result = {{ innerCase["property"] | to_snake }} {{ innerCase["input"]["pattern"] | to_roc }} {{ innerCase["input"]["flags"] | to_roc }} {{ innerCase["input"]["files"] | to_roc }} - result == Ok {{ innerCase["expected"] | join('\n') | to_roc_multiline_string | indent(8) }} + result = {{ innerCase["property"] | to_snake }}({{ innerCase["input"]["pattern"] | to_roc }}, {{ innerCase["input"]["flags"] | to_roc }}, {{ innerCase["input"]["files"] | to_roc }}) + result == Ok({{ innerCase["expected"] | join('\n') | to_roc_multiline_string | indent(8) }}) {% endfor %} {% endfor %} diff --git a/exercises/practice/grep/grep-test.roc b/exercises/practice/grep/grep-test.roc index 6c29124e..bd999ae3 100644 --- a/exercises/practice/grep/grep-test.roc +++ b/exercises/practice/grep/grep-test.roc @@ -8,105 +8,109 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line! "" + Stdout.line!("") import Grep exposing [grep] # Test grepping a single file - One file, one match, no flags expect - result = grep "Agamemnon" [] ["iliad.txt"] - result == Ok "Of Atreus, Agamemnon, King of men." + result = grep("Agamemnon", [], ["iliad.txt"]) + result == Ok("Of Atreus, Agamemnon, King of men.") # Test grepping a single file - One file, one match, print line numbers flag expect - result = grep "Forbidden" ["-n"] ["paradise-lost.txt"] - result == Ok "2:Of that Forbidden Tree, whose mortal tast" + result = grep("Forbidden", ["-n"], ["paradise-lost.txt"]) + result == Ok("2:Of that Forbidden Tree, whose mortal tast") # Test grepping a single file - One file, one match, case-insensitive flag expect - result = grep "FORBIDDEN" ["-i"] ["paradise-lost.txt"] - result == Ok "Of that Forbidden Tree, whose mortal tast" + result = grep("FORBIDDEN", ["-i"], ["paradise-lost.txt"]) + result == Ok("Of that Forbidden Tree, whose mortal tast") # Test grepping a single file - One file, one match, print file names flag expect - result = grep "Forbidden" ["-l"] ["paradise-lost.txt"] - result == Ok "paradise-lost.txt" + result = grep("Forbidden", ["-l"], ["paradise-lost.txt"]) + result == Ok("paradise-lost.txt") # Test grepping a single file - One file, one match, match entire lines flag expect - result = grep "With loss of Eden, till one greater Man" ["-x"] ["paradise-lost.txt"] - result == Ok "With loss of Eden, till one greater Man" + result = grep("With loss of Eden, till one greater Man", ["-x"], ["paradise-lost.txt"]) + result == Ok("With loss of Eden, till one greater Man") # Test grepping a single file - One file, one match, multiple flags expect - result = grep "OF ATREUS, Agamemnon, KIng of MEN." ["-n", "-i", "-x"] ["iliad.txt"] - result == Ok "9:Of Atreus, Agamemnon, King of men." + result = grep("OF ATREUS, Agamemnon, KIng of MEN.", ["-n", "-i", "-x"], ["iliad.txt"]) + result == Ok("9:Of Atreus, Agamemnon, King of men.") # Test grepping a single file - One file, several matches, no flags expect - result = grep "may" [] ["midsummer-night.txt"] + result = grep("may", [], ["midsummer-night.txt"]) result - == Ok + == Ok( """ Nor how it may concern my modesty, But I beseech your grace that I may know The worst that may befall me in this case, - """ + """, + ) # Test grepping a single file - One file, several matches, print line numbers flag expect - result = grep "may" ["-n"] ["midsummer-night.txt"] + result = grep("may", ["-n"], ["midsummer-night.txt"]) result - == Ok + == Ok( """ 3:Nor how it may concern my modesty, 5:But I beseech your grace that I may know 6:The worst that may befall me in this case, - """ + """, + ) # Test grepping a single file - One file, several matches, match entire lines flag expect - result = grep "may" ["-x"] ["midsummer-night.txt"] - result == Ok "" + result = grep("may", ["-x"], ["midsummer-night.txt"]) + result == Ok("") # Test grepping a single file - One file, several matches, case-insensitive flag expect - result = grep "ACHILLES" ["-i"] ["iliad.txt"] + result = grep("ACHILLES", ["-i"], ["iliad.txt"]) result - == Ok + == Ok( """ Achilles sing, O Goddess! Peleus' son; The noble Chief Achilles from the son - """ + """, + ) # Test grepping a single file - One file, several matches, inverted flag expect - result = grep "Of" ["-v"] ["paradise-lost.txt"] + result = grep("Of", ["-v"], ["paradise-lost.txt"]) result - == Ok + == Ok( """ Brought Death into the World, and all our woe, With loss of Eden, till one greater Man Restore us, and regain the blissful Seat, Sing Heav'nly Muse, that on the secret top That Shepherd, who first taught the chosen Seed - """ + """, + ) # Test grepping a single file - One file, no matches, various flags expect - result = grep "Gandalf" ["-n", "-l", "-x", "-i"] ["iliad.txt"] - result == Ok "" + result = grep("Gandalf", ["-n", "-l", "-x", "-i"], ["iliad.txt"]) + result == Ok("") # Test grepping a single file - One file, one match, file flag takes precedence over line flag expect - result = grep "ten" ["-n", "-l"] ["iliad.txt"] - result == Ok "iliad.txt" + result = grep("ten", ["-n", "-l"], ["iliad.txt"]) + result == Ok("iliad.txt") # Test grepping a single file - One file, several matches, inverted and match entire lines flags expect - result = grep "Illustrious into Ades premature," ["-x", "-v"] ["iliad.txt"] + result = grep("Illustrious into Ades premature,", ["-x", "-v"], ["iliad.txt"]) result - == Ok + == Ok( """ Achilles sing, O Goddess! Peleus' son; His wrath pernicious, who ten thousand woes @@ -116,51 +120,55 @@ expect When fierce dispute had separated once The noble Chief Achilles from the son Of Atreus, Agamemnon, King of men. - """ + """, + ) # Test grepping multiples files at once - Multiple files, one match, no flags expect - result = grep "Agamemnon" [] ["iliad.txt", "midsummer-night.txt", "paradise-lost.txt"] - result == Ok "iliad.txt:Of Atreus, Agamemnon, King of men." + result = grep("Agamemnon", [], ["iliad.txt", "midsummer-night.txt", "paradise-lost.txt"]) + result == Ok("iliad.txt:Of Atreus, Agamemnon, King of men.") # Test grepping multiples files at once - Multiple files, several matches, no flags expect - result = grep "may" [] ["iliad.txt", "midsummer-night.txt", "paradise-lost.txt"] + result = grep("may", [], ["iliad.txt", "midsummer-night.txt", "paradise-lost.txt"]) result - == Ok + == Ok( """ midsummer-night.txt:Nor how it may concern my modesty, midsummer-night.txt:But I beseech your grace that I may know midsummer-night.txt:The worst that may befall me in this case, - """ + """, + ) # Test grepping multiples files at once - Multiple files, several matches, print line numbers flag expect - result = grep "that" ["-n"] ["iliad.txt", "midsummer-night.txt", "paradise-lost.txt"] + result = grep("that", ["-n"], ["iliad.txt", "midsummer-night.txt", "paradise-lost.txt"]) result - == Ok + == Ok( """ midsummer-night.txt:5:But I beseech your grace that I may know midsummer-night.txt:6:The worst that may befall me in this case, paradise-lost.txt:2:Of that Forbidden Tree, whose mortal tast paradise-lost.txt:6:Sing Heav'nly Muse, that on the secret top - """ + """, + ) # Test grepping multiples files at once - Multiple files, one match, print file names flag expect - result = grep "who" ["-l"] ["iliad.txt", "midsummer-night.txt", "paradise-lost.txt"] + result = grep("who", ["-l"], ["iliad.txt", "midsummer-night.txt", "paradise-lost.txt"]) result - == Ok + == Ok( """ iliad.txt paradise-lost.txt - """ + """, + ) # Test grepping multiples files at once - Multiple files, several matches, case-insensitive flag expect - result = grep "TO" ["-i"] ["iliad.txt", "midsummer-night.txt", "paradise-lost.txt"] + result = grep("TO", ["-i"], ["iliad.txt", "midsummer-night.txt", "paradise-lost.txt"]) result - == Ok + == Ok( """ iliad.txt:Caused to Achaia's host, sent many a soul iliad.txt:Illustrious into Ades premature, @@ -172,49 +180,52 @@ expect paradise-lost.txt:Brought Death into the World, and all our woe, paradise-lost.txt:Restore us, and regain the blissful Seat, paradise-lost.txt:Sing Heav'nly Muse, that on the secret top - """ + """, + ) # Test grepping multiples files at once - Multiple files, several matches, inverted flag expect - result = grep "a" ["-v"] ["iliad.txt", "midsummer-night.txt", "paradise-lost.txt"] + result = grep("a", ["-v"], ["iliad.txt", "midsummer-night.txt", "paradise-lost.txt"]) result - == Ok + == Ok( """ iliad.txt:Achilles sing, O Goddess! Peleus' son; iliad.txt:The noble Chief Achilles from the son midsummer-night.txt:If I refuse to wed Demetrius. - """ + """, + ) # Test grepping multiples files at once - Multiple files, one match, match entire lines flag expect - result = grep "But I beseech your grace that I may know" ["-x"] ["iliad.txt", "midsummer-night.txt", "paradise-lost.txt"] - result == Ok "midsummer-night.txt:But I beseech your grace that I may know" + result = grep("But I beseech your grace that I may know", ["-x"], ["iliad.txt", "midsummer-night.txt", "paradise-lost.txt"]) + result == Ok("midsummer-night.txt:But I beseech your grace that I may know") # Test grepping multiples files at once - Multiple files, one match, multiple flags expect - result = grep "WITH LOSS OF EDEN, TILL ONE GREATER MAN" ["-n", "-i", "-x"] ["iliad.txt", "midsummer-night.txt", "paradise-lost.txt"] - result == Ok "paradise-lost.txt:4:With loss of Eden, till one greater Man" + result = grep("WITH LOSS OF EDEN, TILL ONE GREATER MAN", ["-n", "-i", "-x"], ["iliad.txt", "midsummer-night.txt", "paradise-lost.txt"]) + result == Ok("paradise-lost.txt:4:With loss of Eden, till one greater Man") # Test grepping multiples files at once - Multiple files, no matches, various flags expect - result = grep "Frodo" ["-n", "-l", "-x", "-i"] ["iliad.txt", "midsummer-night.txt", "paradise-lost.txt"] - result == Ok "" + result = grep("Frodo", ["-n", "-l", "-x", "-i"], ["iliad.txt", "midsummer-night.txt", "paradise-lost.txt"]) + result == Ok("") # Test grepping multiples files at once - Multiple files, several matches, file flag takes precedence over line number flag expect - result = grep "who" ["-n", "-l"] ["iliad.txt", "midsummer-night.txt", "paradise-lost.txt"] + result = grep("who", ["-n", "-l"], ["iliad.txt", "midsummer-night.txt", "paradise-lost.txt"]) result - == Ok + == Ok( """ iliad.txt paradise-lost.txt - """ + """, + ) # Test grepping multiples files at once - Multiple files, several matches, inverted and match entire lines flags expect - result = grep "Illustrious into Ades premature," ["-x", "-v"] ["iliad.txt", "midsummer-night.txt", "paradise-lost.txt"] + result = grep("Illustrious into Ades premature,", ["-x", "-v"], ["iliad.txt", "midsummer-night.txt", "paradise-lost.txt"]) result - == Ok + == Ok( """ iliad.txt:Achilles sing, O Goddess! Peleus' son; iliad.txt:His wrath pernicious, who ten thousand woes @@ -239,5 +250,6 @@ expect paradise-lost.txt:Sing Heav'nly Muse, that on the secret top paradise-lost.txt:Of Oreb, or of Sinai, didst inspire paradise-lost.txt:That Shepherd, who first taught the chosen Seed - """ + """, + ) diff --git a/exercises/practice/hamming/.meta/template.j2 b/exercises/practice/hamming/.meta/template.j2 index 5e5b85a9..3b6eb393 100644 --- a/exercises/practice/hamming/.meta/template.j2 +++ b/exercises/practice/hamming/.meta/template.j2 @@ -7,11 +7,11 @@ import {{ exercise | to_pascal }} exposing [{{ cases[0]["property"] | to_snake } {% for case in cases -%} # {{ case["description"] }} expect - result = {{ case["property"] | to_snake }} {{ case["input"]["strand1"] | to_roc }} {{ case["input"]["strand2"] | to_roc }} + result = {{ case["property"] | to_snake }}({{ case["input"]["strand1"] | to_roc }}, {{ case["input"]["strand2"] | to_roc }}) {%- if case["expected"]["error"] %} - Result.is_err result + Result.is_err(result) {%- else %} - result == Ok {{ case["expected"] }} + result == Ok({{ case["expected"] }}) {%- endif %} {% endfor %} diff --git a/exercises/practice/hamming/hamming-test.roc b/exercises/practice/hamming/hamming-test.roc index 355af55b..1f4cc25d 100644 --- a/exercises/practice/hamming/hamming-test.roc +++ b/exercises/practice/hamming/hamming-test.roc @@ -8,52 +8,52 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line! "" + Stdout.line!("") import Hamming exposing [distance] # empty strands expect - result = distance "" "" - result == Ok 0 + result = distance("", "") + result == Ok(0) # single letter identical strands expect - result = distance "A" "A" - result == Ok 0 + result = distance("A", "A") + result == Ok(0) # single letter different strands expect - result = distance "G" "T" - result == Ok 1 + result = distance("G", "T") + result == Ok(1) # long identical strands expect - result = distance "GGACTGAAATCTG" "GGACTGAAATCTG" - result == Ok 0 + result = distance("GGACTGAAATCTG", "GGACTGAAATCTG") + result == Ok(0) # long different strands expect - result = distance "GGACGGATTCTG" "AGGACGGATTCT" - result == Ok 9 + result = distance("GGACGGATTCTG", "AGGACGGATTCT") + result == Ok(9) # disallow first strand longer expect - result = distance "AATG" "AAA" - Result.is_err result + result = distance("AATG", "AAA") + Result.is_err(result) # disallow second strand longer expect - result = distance "ATA" "AGTG" - Result.is_err result + result = distance("ATA", "AGTG") + Result.is_err(result) # disallow empty first strand expect - result = distance "" "G" - Result.is_err result + result = distance("", "G") + Result.is_err(result) # disallow empty second strand expect - result = distance "G" "" - Result.is_err result + result = distance("G", "") + Result.is_err(result) diff --git a/exercises/practice/hello-world/hello-world-test.roc b/exercises/practice/hello-world/hello-world-test.roc index 81203450..fe44c9db 100644 --- a/exercises/practice/hello-world/hello-world-test.roc +++ b/exercises/practice/hello-world/hello-world-test.roc @@ -8,7 +8,7 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line! "" + Stdout.line!("") import HelloWorld exposing [hello] diff --git a/exercises/practice/high-scores/.meta/template.j2 b/exercises/practice/high-scores/.meta/template.j2 index 0b17d129..68329390 100644 --- a/exercises/practice/high-scores/.meta/template.j2 +++ b/exercises/practice/high-scores/.meta/template.j2 @@ -16,7 +16,7 @@ import {{ exercise | to_pascal }} exposing [latest, personal_best, personal_top_ # {{ case["description"] }} {%- endif %} expect - result = {{ case["property"] | to_snake }} {{ case["input"]["scores"] }} + result = {{ case["property"] | to_snake }}({{ case["input"]["scores"] }}) result == {% if case["property"] != "personalTopThree" %}Ok {% endif %}{{ case["expected"] | to_roc }} {% endfor -%} diff --git a/exercises/practice/high-scores/high-scores-test.roc b/exercises/practice/high-scores/high-scores-test.roc index b08850ac..20e2d7b0 100644 --- a/exercises/practice/high-scores/high-scores-test.roc +++ b/exercises/practice/high-scores/high-scores-test.roc @@ -8,43 +8,43 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line! "" + Stdout.line!("") import HighScores exposing [latest, personal_best, personal_top_three] ## Latest score expect - result = latest [100, 0, 90, 30] + result = latest([100, 0, 90, 30]) result == Ok 30 ## Personal best expect - result = personal_best [40, 100, 70] + result = personal_best([40, 100, 70]) result == Ok 100 ## Top 3 scores # Personal top three from a list of scores expect - result = personal_top_three [10, 30, 90, 30, 100, 20, 10, 0, 30, 40, 40, 70, 70] + result = personal_top_three([10, 30, 90, 30, 100, 20, 10, 0, 30, 40, 40, 70, 70]) result == [100, 90, 70] # Personal top highest to lowest expect - result = personal_top_three [20, 10, 30] + result = personal_top_three([20, 10, 30]) result == [30, 20, 10] # Personal top when there is a tie expect - result = personal_top_three [40, 20, 40, 30] + result = personal_top_three([40, 20, 40, 30]) result == [40, 40, 30] # Personal top when there are less than 3 expect - result = personal_top_three [30, 70] + result = personal_top_three([30, 70]) result == [70, 30] # Personal top when there is only one expect - result = personal_top_three [40] + result = personal_top_three([40]) result == [40] diff --git a/exercises/practice/house/.meta/template.j2 b/exercises/practice/house/.meta/template.j2 index a2c0bb06..1ad789e0 100644 --- a/exercises/practice/house/.meta/template.j2 +++ b/exercises/practice/house/.meta/template.j2 @@ -7,7 +7,7 @@ import {{ exercise | to_pascal }} exposing [{{ cases[0]["property"] | to_snake } {% for case in cases -%} # {{ case["description"] }} expect - result = {{ case["property"] | to_snake }} {{ case["input"]["startVerse"] }} {{ case["input"]["endVerse"] }} + result = {{ case["property"] | to_snake }}({{ case["input"]["startVerse"] }}, {{ case["input"]["endVerse"] }}) result == {{ "\n".join(case["expected"]) | to_roc }} {% endfor %} diff --git a/exercises/practice/house/house-test.roc b/exercises/practice/house/house-test.roc index 87852c8a..a4a501eb 100644 --- a/exercises/practice/house/house-test.roc +++ b/exercises/practice/house/house-test.roc @@ -8,77 +8,77 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line! "" + Stdout.line!("") import House exposing [recite] # verse one - the house that jack built expect - result = recite 1 1 + result = recite(1, 1) result == "This is the house that Jack built." # verse two - the malt that lay expect - result = recite 2 2 + result = recite(2, 2) result == "This is the malt that lay in the house that Jack built." # verse three - the rat that ate expect - result = recite 3 3 + result = recite(3, 3) result == "This is the rat that ate the malt that lay in the house that Jack built." # verse four - the cat that killed expect - result = recite 4 4 + result = recite(4, 4) result == "This is the cat that killed the rat that ate the malt that lay in the house that Jack built." # verse five - the dog that worried expect - result = recite 5 5 + result = recite(5, 5) result == "This is the dog that worried the cat that killed the rat that ate the malt that lay in the house that Jack built." # verse six - the cow with the crumpled horn expect - result = recite 6 6 + result = recite(6, 6) result == "This is the cow with the crumpled horn that tossed the dog that worried the cat that killed the rat that ate the malt that lay in the house that Jack built." # verse seven - the maiden all forlorn expect - result = recite 7 7 + result = recite(7, 7) result == "This is the maiden all forlorn that milked the cow with the crumpled horn that tossed the dog that worried the cat that killed the rat that ate the malt that lay in the house that Jack built." # verse eight - the man all tattered and torn expect - result = recite 8 8 + result = recite(8, 8) result == "This is the man all tattered and torn that kissed the maiden all forlorn that milked the cow with the crumpled horn that tossed the dog that worried the cat that killed the rat that ate the malt that lay in the house that Jack built." # verse nine - the priest all shaven and shorn expect - result = recite 9 9 + result = recite(9, 9) result == "This is the priest all shaven and shorn that married the man all tattered and torn that kissed the maiden all forlorn that milked the cow with the crumpled horn that tossed the dog that worried the cat that killed the rat that ate the malt that lay in the house that Jack built." # verse 10 - the rooster that crowed in the morn expect - result = recite 10 10 + result = recite(10, 10) result == "This is the rooster that crowed in the morn that woke the priest all shaven and shorn that married the man all tattered and torn that kissed the maiden all forlorn that milked the cow with the crumpled horn that tossed the dog that worried the cat that killed the rat that ate the malt that lay in the house that Jack built." # verse 11 - the farmer sowing his corn expect - result = recite 11 11 + result = recite(11, 11) result == "This is the farmer sowing his corn that kept the rooster that crowed in the morn that woke the priest all shaven and shorn that married the man all tattered and torn that kissed the maiden all forlorn that milked the cow with the crumpled horn that tossed the dog that worried the cat that killed the rat that ate the malt that lay in the house that Jack built." # verse 12 - the horse and the hound and the horn expect - result = recite 12 12 + result = recite(12, 12) result == "This is the horse and the hound and the horn that belonged to the farmer sowing his corn that kept the rooster that crowed in the morn that woke the priest all shaven and shorn that married the man all tattered and torn that kissed the maiden all forlorn that milked the cow with the crumpled horn that tossed the dog that worried the cat that killed the rat that ate the malt that lay in the house that Jack built." # multiple verses expect - result = recite 4 8 + result = recite(4, 8) result == "This is the cat that killed the rat that ate the malt that lay in the house that Jack built.\nThis is the dog that worried the cat that killed the rat that ate the malt that lay in the house that Jack built.\nThis is the cow with the crumpled horn that tossed the dog that worried the cat that killed the rat that ate the malt that lay in the house that Jack built.\nThis is the maiden all forlorn that milked the cow with the crumpled horn that tossed the dog that worried the cat that killed the rat that ate the malt that lay in the house that Jack built.\nThis is the man all tattered and torn that kissed the maiden all forlorn that milked the cow with the crumpled horn that tossed the dog that worried the cat that killed the rat that ate the malt that lay in the house that Jack built." # full rhyme expect - result = recite 1 12 + result = recite(1, 12) result == "This is the house that Jack built.\nThis is the malt that lay in the house that Jack built.\nThis is the rat that ate the malt that lay in the house that Jack built.\nThis is the cat that killed the rat that ate the malt that lay in the house that Jack built.\nThis is the dog that worried the cat that killed the rat that ate the malt that lay in the house that Jack built.\nThis is the cow with the crumpled horn that tossed the dog that worried the cat that killed the rat that ate the malt that lay in the house that Jack built.\nThis is the maiden all forlorn that milked the cow with the crumpled horn that tossed the dog that worried the cat that killed the rat that ate the malt that lay in the house that Jack built.\nThis is the man all tattered and torn that kissed the maiden all forlorn that milked the cow with the crumpled horn that tossed the dog that worried the cat that killed the rat that ate the malt that lay in the house that Jack built.\nThis is the priest all shaven and shorn that married the man all tattered and torn that kissed the maiden all forlorn that milked the cow with the crumpled horn that tossed the dog that worried the cat that killed the rat that ate the malt that lay in the house that Jack built.\nThis is the rooster that crowed in the morn that woke the priest all shaven and shorn that married the man all tattered and torn that kissed the maiden all forlorn that milked the cow with the crumpled horn that tossed the dog that worried the cat that killed the rat that ate the malt that lay in the house that Jack built.\nThis is the farmer sowing his corn that kept the rooster that crowed in the morn that woke the priest all shaven and shorn that married the man all tattered and torn that kissed the maiden all forlorn that milked the cow with the crumpled horn that tossed the dog that worried the cat that killed the rat that ate the malt that lay in the house that Jack built.\nThis is the horse and the hound and the horn that belonged to the farmer sowing his corn that kept the rooster that crowed in the morn that woke the priest all shaven and shorn that married the man all tattered and torn that kissed the maiden all forlorn that milked the cow with the crumpled horn that tossed the dog that worried the cat that killed the rat that ate the malt that lay in the house that Jack built." diff --git a/exercises/practice/isbn-verifier/.meta/template.j2 b/exercises/practice/isbn-verifier/.meta/template.j2 index e3258a20..6cd86f30 100644 --- a/exercises/practice/isbn-verifier/.meta/template.j2 +++ b/exercises/practice/isbn-verifier/.meta/template.j2 @@ -7,7 +7,7 @@ import {{ exercise | to_pascal }} exposing [is_valid] {% for case in cases -%} # {{ case["description"] }} expect - result = {{ case["property"] | to_snake }} {{ case["input"]["isbn"] | to_roc }} + result = {{ case["property"] | to_snake }}({{ case["input"]["isbn"] | to_roc }}) result == {{ case["expected"] | to_roc }} {% endfor %} diff --git a/exercises/practice/isbn-verifier/isbn-verifier-test.roc b/exercises/practice/isbn-verifier/isbn-verifier-test.roc index b12e3a7c..feb8f6a7 100644 --- a/exercises/practice/isbn-verifier/isbn-verifier-test.roc +++ b/exercises/practice/isbn-verifier/isbn-verifier-test.roc @@ -8,102 +8,102 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line! "" + Stdout.line!("") import IsbnVerifier exposing [is_valid] # valid isbn expect - result = is_valid "3-598-21508-8" + result = is_valid("3-598-21508-8") result == Bool.true # invalid isbn check digit expect - result = is_valid "3-598-21508-9" + result = is_valid("3-598-21508-9") result == Bool.false # valid isbn with a check digit of 10 expect - result = is_valid "3-598-21507-X" + result = is_valid("3-598-21507-X") result == Bool.true # check digit is a character other than X expect - result = is_valid "3-598-21507-A" + result = is_valid("3-598-21507-A") result == Bool.false # invalid check digit in isbn is not treated as zero expect - result = is_valid "4-598-21507-B" + result = is_valid("4-598-21507-B") result == Bool.false # invalid character in isbn is not treated as zero expect - result = is_valid "3-598-P1581-X" + result = is_valid("3-598-P1581-X") result == Bool.false # X is only valid as a check digit expect - result = is_valid "3-598-2X507-9" + result = is_valid("3-598-2X507-9") result == Bool.false # valid isbn without separating dashes expect - result = is_valid "3598215088" + result = is_valid("3598215088") result == Bool.true # isbn without separating dashes and X as check digit expect - result = is_valid "359821507X" + result = is_valid("359821507X") result == Bool.true # isbn without check digit and dashes expect - result = is_valid "359821507" + result = is_valid("359821507") result == Bool.false # too long isbn and no dashes expect - result = is_valid "3598215078X" + result = is_valid("3598215078X") result == Bool.false # too short isbn expect - result = is_valid "00" + result = is_valid("00") result == Bool.false # isbn without check digit expect - result = is_valid "3-598-21507" + result = is_valid("3-598-21507") result == Bool.false # check digit of X should not be used for 0 expect - result = is_valid "3-598-21515-X" + result = is_valid("3-598-21515-X") result == Bool.false # empty isbn expect - result = is_valid "" + result = is_valid("") result == Bool.false # input is 9 characters expect - result = is_valid "134456729" + result = is_valid("134456729") result == Bool.false # invalid characters are not ignored after checking length expect - result = is_valid "3132P34035" + result = is_valid("3132P34035") result == Bool.false # invalid characters are not ignored before checking length expect - result = is_valid "3598P215088" + result = is_valid("3598P215088") result == Bool.false # input is too long but contains a valid isbn expect - result = is_valid "98245726788" + result = is_valid("98245726788") result == Bool.false diff --git a/exercises/practice/isogram/.meta/template.j2 b/exercises/practice/isogram/.meta/template.j2 index 35c5b095..86dc2d01 100644 --- a/exercises/practice/isogram/.meta/template.j2 +++ b/exercises/practice/isogram/.meta/template.j2 @@ -7,7 +7,7 @@ import {{ exercise | to_pascal }} exposing [is_isogram] {% for case in cases -%} # {{ case["description"] }} expect - result = {{ case["property"] | to_snake }} {{ case["input"]["phrase"] | to_roc }} + result = {{ case["property"] | to_snake }}({{ case["input"]["phrase"] | to_roc }}) result == {{ case["expected"] | to_roc }} {% endfor %} diff --git a/exercises/practice/isogram/isogram-test.roc b/exercises/practice/isogram/isogram-test.roc index 6d99aaf6..cd897f25 100644 --- a/exercises/practice/isogram/isogram-test.roc +++ b/exercises/practice/isogram/isogram-test.roc @@ -8,77 +8,77 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line! "" + Stdout.line!("") import Isogram exposing [is_isogram] # empty string expect - result = is_isogram "" + result = is_isogram("") result == Bool.true # isogram with only lower case characters expect - result = is_isogram "isogram" + result = is_isogram("isogram") result == Bool.true # word with one duplicated character expect - result = is_isogram "eleven" + result = is_isogram("eleven") result == Bool.false # word with one duplicated character from the end of the alphabet expect - result = is_isogram "zzyzx" + result = is_isogram("zzyzx") result == Bool.false # longest reported english isogram expect - result = is_isogram "subdermatoglyphic" + result = is_isogram("subdermatoglyphic") result == Bool.true # word with duplicated character in mixed case expect - result = is_isogram "Alphabet" + result = is_isogram("Alphabet") result == Bool.false # word with duplicated character in mixed case, lowercase first expect - result = is_isogram "alphAbet" + result = is_isogram("alphAbet") result == Bool.false # hypothetical isogrammic word with hyphen expect - result = is_isogram "thumbscrew-japingly" + result = is_isogram("thumbscrew-japingly") result == Bool.true # hypothetical word with duplicated character following hyphen expect - result = is_isogram "thumbscrew-jappingly" + result = is_isogram("thumbscrew-jappingly") result == Bool.false # isogram with duplicated hyphen expect - result = is_isogram "six-year-old" + result = is_isogram("six-year-old") result == Bool.true # made-up name that is an isogram expect - result = is_isogram "Emily Jung Schwartzkopf" + result = is_isogram("Emily Jung Schwartzkopf") result == Bool.true # duplicated character in the middle expect - result = is_isogram "accentor" + result = is_isogram("accentor") result == Bool.false # same first and last characters expect - result = is_isogram "angola" + result = is_isogram("angola") result == Bool.false # word with duplicated character and with two hyphens expect - result = is_isogram "up-to-date" + result = is_isogram("up-to-date") result == Bool.false diff --git a/exercises/practice/killer-sudoku-helper/killer-sudoku-helper-test.roc b/exercises/practice/killer-sudoku-helper/killer-sudoku-helper-test.roc index dfd13835..2687a5fb 100644 --- a/exercises/practice/killer-sudoku-helper/killer-sudoku-helper-test.roc +++ b/exercises/practice/killer-sudoku-helper/killer-sudoku-helper-test.roc @@ -8,7 +8,7 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line! "" + Stdout.line!("") import KillerSudokuHelper exposing [combinations] diff --git a/exercises/practice/kindergarten-garden/.meta/template.j2 b/exercises/practice/kindergarten-garden/.meta/template.j2 index 00bde51a..2e162d9a 100644 --- a/exercises/practice/kindergarten-garden/.meta/template.j2 +++ b/exercises/practice/kindergarten-garden/.meta/template.j2 @@ -21,7 +21,7 @@ import {{ exercise | to_pascal }} exposing [plants] # {{ subcase["description"] }} expect diagram = {{ subcase["input"]["diagram"] | to_roc_multiline_string | indent(8) }} - result = diagram |> {{ subcase["property"] | to_snake }} {{ subcase["input"]["student"] | to_pascal }} + result = diagram |> {{ subcase["property"] | to_snake }}({{ subcase["input"]["student"] | to_pascal }}) result == Ok [{% for plant in subcase["expected"] %}{{ plant | to_pascal }}, {% endfor %}] {% endfor %} diff --git a/exercises/practice/kindergarten-garden/kindergarten-garden-test.roc b/exercises/practice/kindergarten-garden/kindergarten-garden-test.roc index 27d3e261..b0e2b558 100644 --- a/exercises/practice/kindergarten-garden/kindergarten-garden-test.roc +++ b/exercises/practice/kindergarten-garden/kindergarten-garden-test.roc @@ -8,7 +8,7 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line! "" + Stdout.line!("") import KindergartenGarden exposing [plants] @@ -23,7 +23,7 @@ expect RC GG """ - result = diagram |> plants Alice + result = diagram |> plants(Alice) result == Ok [Radishes, Clover, Grass, Grass] # different garden with single student @@ -33,7 +33,7 @@ expect VC RC """ - result = diagram |> plants Alice + result = diagram |> plants(Alice) result == Ok [Violets, Clover, Radishes, Clover] # garden with two students @@ -43,7 +43,7 @@ expect VVCG VVRC """ - result = diagram |> plants Bob + result = diagram |> plants(Bob) result == Ok [Clover, Grass, Radishes, Clover] ## multiple students for the same garden with three students @@ -55,7 +55,7 @@ expect VVCCGG VVCCGG """ - result = diagram |> plants Bob + result = diagram |> plants(Bob) result == Ok [Clover, Clover, Clover, Clover] # third student's garden @@ -65,7 +65,7 @@ expect VVCCGG VVCCGG """ - result = diagram |> plants Charlie + result = diagram |> plants(Charlie) result == Ok [Grass, Grass, Grass, Grass] ### @@ -79,7 +79,7 @@ expect VRCGVVRVCGGCCGVRGCVCGCGV VRCCCGCRRGVCGCRVVCVGCGCV """ - result = diagram |> plants Alice + result = diagram |> plants(Alice) result == Ok [Violets, Radishes, Violets, Radishes] # for Bob, second student's garden @@ -89,7 +89,7 @@ expect VRCGVVRVCGGCCGVRGCVCGCGV VRCCCGCRRGVCGCRVVCVGCGCV """ - result = diagram |> plants Bob + result = diagram |> plants(Bob) result == Ok [Clover, Grass, Clover, Clover] # for Charlie @@ -99,7 +99,7 @@ expect VRCGVVRVCGGCCGVRGCVCGCGV VRCCCGCRRGVCGCRVVCVGCGCV """ - result = diagram |> plants Charlie + result = diagram |> plants(Charlie) result == Ok [Violets, Violets, Clover, Grass] # for David @@ -109,7 +109,7 @@ expect VRCGVVRVCGGCCGVRGCVCGCGV VRCCCGCRRGVCGCRVVCVGCGCV """ - result = diagram |> plants David + result = diagram |> plants(David) result == Ok [Radishes, Violets, Clover, Radishes] # for Eve @@ -119,7 +119,7 @@ expect VRCGVVRVCGGCCGVRGCVCGCGV VRCCCGCRRGVCGCRVVCVGCGCV """ - result = diagram |> plants Eve + result = diagram |> plants(Eve) result == Ok [Clover, Grass, Radishes, Grass] # for Fred @@ -129,7 +129,7 @@ expect VRCGVVRVCGGCCGVRGCVCGCGV VRCCCGCRRGVCGCRVVCVGCGCV """ - result = diagram |> plants Fred + result = diagram |> plants(Fred) result == Ok [Grass, Clover, Violets, Clover] # for Ginny @@ -139,7 +139,7 @@ expect VRCGVVRVCGGCCGVRGCVCGCGV VRCCCGCRRGVCGCRVVCVGCGCV """ - result = diagram |> plants Ginny + result = diagram |> plants(Ginny) result == Ok [Clover, Grass, Grass, Clover] # for Harriet @@ -149,7 +149,7 @@ expect VRCGVVRVCGGCCGVRGCVCGCGV VRCCCGCRRGVCGCRVVCVGCGCV """ - result = diagram |> plants Harriet + result = diagram |> plants(Harriet) result == Ok [Violets, Radishes, Radishes, Violets] # for Ileana @@ -159,7 +159,7 @@ expect VRCGVVRVCGGCCGVRGCVCGCGV VRCCCGCRRGVCGCRVVCVGCGCV """ - result = diagram |> plants Ileana + result = diagram |> plants(Ileana) result == Ok [Grass, Clover, Violets, Clover] # for Joseph @@ -169,7 +169,7 @@ expect VRCGVVRVCGGCCGVRGCVCGCGV VRCCCGCRRGVCGCRVVCVGCGCV """ - result = diagram |> plants Joseph + result = diagram |> plants(Joseph) result == Ok [Violets, Clover, Violets, Grass] # for Kincaid, second to last student's garden @@ -179,7 +179,7 @@ expect VRCGVVRVCGGCCGVRGCVCGCGV VRCCCGCRRGVCGCRVVCVGCGCV """ - result = diagram |> plants Kincaid + result = diagram |> plants(Kincaid) result == Ok [Grass, Clover, Clover, Grass] # for Larry, last student's garden @@ -189,6 +189,6 @@ expect VRCGVVRVCGGCCGVRGCVCGCGV VRCCCGCRRGVCGCRVVCVGCGCV """ - result = diagram |> plants Larry + result = diagram |> plants(Larry) result == Ok [Grass, Violets, Clover, Violets] diff --git a/exercises/practice/knapsack/.meta/template.j2 b/exercises/practice/knapsack/.meta/template.j2 index 18c73583..a7a2d839 100644 --- a/exercises/practice/knapsack/.meta/template.j2 +++ b/exercises/practice/knapsack/.meta/template.j2 @@ -16,7 +16,7 @@ expect {%- endfor %} ] {%- endif %} - result = {{ case["property"] | to_snake }} { items, maximum_weight: {{ case["input"]["maximumWeight"] }} } + result = {{ case["property"] | to_snake }}({ items, maximum_weight: {{ case["input"]["maximumWeight"] }} }) result == {{ case["expected"] | to_roc }} {% endfor %} \ No newline at end of file diff --git a/exercises/practice/knapsack/knapsack-test.roc b/exercises/practice/knapsack/knapsack-test.roc index 046371d9..f4d0f401 100644 --- a/exercises/practice/knapsack/knapsack-test.roc +++ b/exercises/practice/knapsack/knapsack-test.roc @@ -8,14 +8,14 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line! "" + Stdout.line!("") import Knapsack exposing [maximum_value] # no items expect items = [] - result = maximum_value { items, maximum_weight: 100 } + result = maximum_value({ items, maximum_weight: 100 }) result == 0 # one item, too heavy @@ -23,7 +23,7 @@ expect items = [ { weight: 100, value: 1 }, ] - result = maximum_value { items, maximum_weight: 10 } + result = maximum_value({ items, maximum_weight: 10 }) result == 0 # five items (cannot be greedy by weight) @@ -35,7 +35,7 @@ expect { weight: 2, value: 5 }, { weight: 10, value: 21 }, ] - result = maximum_value { items, maximum_weight: 10 } + result = maximum_value({ items, maximum_weight: 10 }) result == 21 # five items (cannot be greedy by value) @@ -47,7 +47,7 @@ expect { weight: 2, value: 20 }, { weight: 10, value: 50 }, ] - result = maximum_value { items, maximum_weight: 10 } + result = maximum_value({ items, maximum_weight: 10 }) result == 80 # example knapsack @@ -58,7 +58,7 @@ expect { weight: 6, value: 30 }, { weight: 4, value: 50 }, ] - result = maximum_value { items, maximum_weight: 10 } + result = maximum_value({ items, maximum_weight: 10 }) result == 90 # 8 items @@ -73,7 +73,7 @@ expect { weight: 2, value: 5 }, { weight: 2, value: 5 }, ] - result = maximum_value { items, maximum_weight: 104 } + result = maximum_value({ items, maximum_weight: 104 }) result == 900 # 15 items @@ -95,6 +95,6 @@ expect { weight: 118, value: 229 }, { weight: 120, value: 240 }, ] - result = maximum_value { items, maximum_weight: 750 } + result = maximum_value({ items, maximum_weight: 750 }) result == 1458 diff --git a/exercises/practice/largest-series-product/.meta/template.j2 b/exercises/practice/largest-series-product/.meta/template.j2 index 0c27be4a..32e91028 100644 --- a/exercises/practice/largest-series-product/.meta/template.j2 +++ b/exercises/practice/largest-series-product/.meta/template.j2 @@ -8,7 +8,7 @@ import {{ exercise | to_pascal }} exposing [{{ cases[0]["property"] | to_snake } # {{ case["description"] }} expect digits = {{ case["input"]["digits"] | to_roc }} - result = digits |> {{ case["property"] | to_snake }} {{ case["input"]["span"] | to_roc }} + result = digits |> {{ case["property"] | to_snake }}({{ case["input"]["span"] | to_roc }}) {%- if case["expected"]["error"] %} result |> Result.is_err {%- else %} diff --git a/exercises/practice/largest-series-product/largest-series-product-test.roc b/exercises/practice/largest-series-product/largest-series-product-test.roc index 42e0a095..ddf4091f 100644 --- a/exercises/practice/largest-series-product/largest-series-product-test.roc +++ b/exercises/practice/largest-series-product/largest-series-product-test.roc @@ -8,102 +8,102 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line! "" + Stdout.line!("") import LargestSeriesProduct exposing [largest_product] # finds the largest product if span equals length expect digits = "29" - result = digits |> largest_product 2 + result = digits |> largest_product(2) expected = Ok 18 result == expected # can find the largest product of 2 with numbers in order expect digits = "0123456789" - result = digits |> largest_product 2 + result = digits |> largest_product(2) expected = Ok 72 result == expected # can find the largest product of 2 expect digits = "576802143" - result = digits |> largest_product 2 + result = digits |> largest_product(2) expected = Ok 48 result == expected # can find the largest product of 3 with numbers in order expect digits = "0123456789" - result = digits |> largest_product 3 + result = digits |> largest_product(3) expected = Ok 504 result == expected # can find the largest product of 3 expect digits = "1027839564" - result = digits |> largest_product 3 + result = digits |> largest_product(3) expected = Ok 270 result == expected # can find the largest product of 5 with numbers in order expect digits = "0123456789" - result = digits |> largest_product 5 + result = digits |> largest_product(5) expected = Ok 15120 result == expected # can get the largest product of a big number expect digits = "73167176531330624919225119674426574742355349194934" - result = digits |> largest_product 6 + result = digits |> largest_product(6) expected = Ok 23520 result == expected # reports zero if the only digits are zero expect digits = "0000" - result = digits |> largest_product 2 + result = digits |> largest_product(2) expected = Ok 0 result == expected # reports zero if all spans include zero expect digits = "99099" - result = digits |> largest_product 3 + result = digits |> largest_product(3) expected = Ok 0 result == expected # rejects span longer than string length expect digits = "123" - result = digits |> largest_product 4 + result = digits |> largest_product(4) result |> Result.is_err # reports 1 for empty string and empty product (0 span) expect digits = "" - result = digits |> largest_product 0 + result = digits |> largest_product(0) expected = Ok 1 result == expected # reports 1 for nonempty string and empty product (0 span) expect digits = "123" - result = digits |> largest_product 0 + result = digits |> largest_product(0) expected = Ok 1 result == expected # rejects empty string and nonzero span expect digits = "" - result = digits |> largest_product 1 + result = digits |> largest_product(1) result |> Result.is_err # rejects invalid character in digits expect digits = "1234a5" - result = digits |> largest_product 2 + result = digits |> largest_product(2) result |> Result.is_err diff --git a/exercises/practice/leap/leap-test.roc b/exercises/practice/leap/leap-test.roc index b80b8f81..d6d745b0 100644 --- a/exercises/practice/leap/leap-test.roc +++ b/exercises/practice/leap/leap-test.roc @@ -8,7 +8,7 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line! "" + Stdout.line!("") import Leap exposing [is_leap_year] diff --git a/exercises/practice/list-ops/.meta/template.j2 b/exercises/practice/list-ops/.meta/template.j2 index cc1bf906..aaa0c48f 100644 --- a/exercises/practice/list-ops/.meta/template.j2 +++ b/exercises/practice/list-ops/.meta/template.j2 @@ -21,25 +21,25 @@ import {{ exercise | to_pascal }} exposing [append, concat, filter, length, map, # {{ case["description"] }} expect {%- if case["property"] == "append" %} - result = {{ case["property"] | to_snake }} {{ case["input"]["list1"] | to_roc }} {{ case["input"]["list2"] | to_roc }} + result = {{ case["property"] | to_snake }}({{ case["input"]["list1"] | to_roc }}, {{ case["input"]["list2"] | to_roc }}) result == {{ case["expected"] | to_roc }} {%- elif case["property"] == "concat" %} - result = {{ case["property"] | to_snake }} {{ case["input"]["lists"] | to_roc }} + result = {{ case["property"] | to_snake }}({{ case["input"]["lists"] | to_roc }}) result == {{ case["expected"] | to_roc }} {%- elif case["property"] == "filter" %} - result = {{ case["property"] | to_snake }} {{ case["input"]["list"] | to_roc }} ({{ function_map[case["input"]["function"]] }}) + result = {{ case["property"] | to_snake }}({{ case["input"]["list"] | to_roc }}, {{ function_map[case["input"]["function"]] }}) result == {{ case["expected"] | to_roc }} {%- elif case["property"] == "length" %} - result = {{ case["property"] | to_snake }} {{ case["input"]["list"] | to_roc }} + result = {{ case["property"] | to_snake }}({{ case["input"]["list"] | to_roc }}) result == {{ case["expected"] }} {%- elif case["property"] == "map" %} - result = {{ case["property"] | to_snake }} {{ case["input"]["list"] | to_roc }} ({{ function_map[case["input"]["function"]] }}) + result = {{ case["property"] | to_snake }}({{ case["input"]["list"] | to_roc }}, {{ function_map[case["input"]["function"]] }}) result == {{ case["expected"] }} {%- elif case["property"] in ("foldl", "foldr") %} - result = {{ case["property"] | to_snake }} {{ case["input"]["list"] | to_roc }} {{ case["input"]["initial"] }} ({{ function_map[case["input"]["function"]] }}){% if "/" in function_map[case["input"]["function"]] %}|> Num.round{% endif %} + result = {{ case["property"] | to_snake }}({{ case["input"]["list"] | to_roc }}, {{ case["input"]["initial"] }}, {{ function_map[case["input"]["function"]] }}){% if "/" in function_map[case["input"]["function"]] %}|> Num.round{% endif %} result == {{ case["expected"] | to_roc }} {%- elif case["property"] == "reverse" %} - result = {{ case["property"] | to_snake }} {{ case["input"]["list"] | to_roc }} + result = {{ case["property"] | to_snake }}({{ case["input"]["list"] | to_roc }}) result == {{ case["expected"] | to_roc }} {%- else %} Bool.true # This test case is not yet implemented diff --git a/exercises/practice/list-ops/list-ops-test.roc b/exercises/practice/list-ops/list-ops-test.roc index 60d75d16..6ebd8ce3 100644 --- a/exercises/practice/list-ops/list-ops-test.roc +++ b/exercises/practice/list-ops/list-ops-test.roc @@ -8,7 +8,7 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line! "" + Stdout.line!("") import ListOps exposing [append, concat, filter, length, map, foldl, foldr, reverse] @@ -18,22 +18,22 @@ import ListOps exposing [append, concat, filter, length, map, foldl, foldr, reve # empty lists expect - result = append [] [] + result = append([], []) result == [] # list to empty list expect - result = append [] [1, 2, 3, 4] + result = append([], [1, 2, 3, 4]) result == [1, 2, 3, 4] # empty list to list expect - result = append [1, 2, 3, 4] [] + result = append([1, 2, 3, 4], []) result == [1, 2, 3, 4] # non-empty lists expect - result = append [1, 2] [2, 3, 4, 5] + result = append([1, 2], [2, 3, 4, 5]) result == [1, 2, 2, 3, 4, 5] ## @@ -42,17 +42,17 @@ expect # empty list expect - result = concat [] + result = concat([]) result == [] # list of lists expect - result = concat [[1, 2], [3], [], [4, 5, 6]] + result = concat([[1, 2], [3], [], [4, 5, 6]]) result == [1, 2, 3, 4, 5, 6] # list of nested lists expect - result = concat [[[1], [2]], [[3]], [[]], [[4, 5, 6]]] + result = concat([[[1], [2]], [[3]], [[]], [[4, 5, 6]]]) result == [[1], [2], [3], [], [4, 5, 6]] ## @@ -61,12 +61,12 @@ expect # empty list expect - result = filter [] (Num.is_odd) + result = filter([], Num.is_odd) result == [] # non-empty list expect - result = filter [1, 2, 3, 5] (Num.is_odd) + result = filter([1, 2, 3, 5], Num.is_odd) result == [1, 3, 5] ## @@ -75,12 +75,12 @@ expect # empty list expect - result = length [] + result = length([]) result == 0 # non-empty list expect - result = length [1, 2, 3, 4] + result = length([1, 2, 3, 4]) result == 4 ## @@ -89,12 +89,12 @@ expect # empty list expect - result = map [] (|x| x + 1) + result = map([], |x| x + 1) result == [] # non-empty list expect - result = map [1, 3, 5, 7] (|x| x + 1) + result = map([1, 3, 5, 7], |x| x + 1) result == [2, 4, 6, 8] ## @@ -103,17 +103,17 @@ expect # empty list expect - result = foldl [] 2 (|acc, el| el * acc) + result = foldl([], 2, |acc, el| el * acc) result == 2 # direction independent function applied to non-empty list expect - result = foldl [1, 2, 3, 4] 5 (|acc, el| el + acc) + result = foldl([1, 2, 3, 4], 5, |acc, el| el + acc) result == 15 # direction dependent function applied to non-empty list expect - result = foldl [1, 2, 3, 4] 24 (|acc, el| el / acc) |> Num.round + result = foldl([1, 2, 3, 4], 24, |acc, el| el / acc) |> Num.round result == 64 ## @@ -122,17 +122,17 @@ expect # empty list expect - result = foldr [] 2 (|acc, el| el * acc) + result = foldr([], 2, |acc, el| el * acc) result == 2 # direction independent function applied to non-empty list expect - result = foldr [1, 2, 3, 4] 5 (|acc, el| el + acc) + result = foldr([1, 2, 3, 4], 5, |acc, el| el + acc) result == 15 # direction dependent function applied to non-empty list expect - result = foldr [1, 2, 3, 4] 24 (|acc, el| el / acc) |> Num.round + result = foldr([1, 2, 3, 4], 24, |acc, el| el / acc) |> Num.round result == 9 ## @@ -141,16 +141,16 @@ expect # empty list expect - result = reverse [] + result = reverse([]) result == [] # non-empty list expect - result = reverse [1, 3, 5, 7] + result = reverse([1, 3, 5, 7]) result == [7, 5, 3, 1] # list of lists is not flattened expect - result = reverse [[1, 2], [3], [], [4, 5, 6]] + result = reverse([[1, 2], [3], [], [4, 5, 6]]) result == [[4, 5, 6], [], [3], [1, 2]] diff --git a/exercises/practice/luhn/.meta/template.j2 b/exercises/practice/luhn/.meta/template.j2 index 9003a9cd..2f2e4ef6 100644 --- a/exercises/practice/luhn/.meta/template.j2 +++ b/exercises/practice/luhn/.meta/template.j2 @@ -7,7 +7,7 @@ import {{ exercise | to_pascal }} exposing [{{ cases[0]["property"] | to_snake } {% for case in cases -%} # {{ case["description"] }} expect - result = {{ case["property"] | to_snake }} {{ case["input"]["value"] | to_roc }} + result = {{ case["property"] | to_snake }}({{ case["input"]["value"] | to_roc }}) result == {{ case["expected"] | to_roc }} {% endfor %} diff --git a/exercises/practice/luhn/luhn-test.roc b/exercises/practice/luhn/luhn-test.roc index 4928e34f..0ae078a3 100644 --- a/exercises/practice/luhn/luhn-test.roc +++ b/exercises/practice/luhn/luhn-test.roc @@ -8,117 +8,117 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line! "" + Stdout.line!("") import Luhn exposing [valid] # single digit strings can not be valid expect - result = valid "1" + result = valid("1") result == Bool.false # a single zero is invalid expect - result = valid "0" + result = valid("0") result == Bool.false # a simple valid SIN that remains valid if reversed expect - result = valid "059" + result = valid("059") result == Bool.true # a simple valid SIN that becomes invalid if reversed expect - result = valid "59" + result = valid("59") result == Bool.true # a valid Canadian SIN expect - result = valid "055 444 285" + result = valid("055 444 285") result == Bool.true # invalid Canadian SIN expect - result = valid "055 444 286" + result = valid("055 444 286") result == Bool.false # invalid credit card expect - result = valid "8273 1232 7352 0569" + result = valid("8273 1232 7352 0569") result == Bool.false # invalid long number with an even remainder expect - result = valid "1 2345 6789 1234 5678 9012" + result = valid("1 2345 6789 1234 5678 9012") result == Bool.false # invalid long number with a remainder divisible by 5 expect - result = valid "1 2345 6789 1234 5678 9013" + result = valid("1 2345 6789 1234 5678 9013") result == Bool.false # valid number with an even number of digits expect - result = valid "095 245 88" + result = valid("095 245 88") result == Bool.true # valid number with an odd number of spaces expect - result = valid "234 567 891 234" + result = valid("234 567 891 234") result == Bool.true # valid strings with a non-digit added at the end become invalid expect - result = valid "059a" + result = valid("059a") result == Bool.false # valid strings with punctuation included become invalid expect - result = valid "055-444-285" + result = valid("055-444-285") result == Bool.false # valid strings with symbols included become invalid expect - result = valid "055# 444$ 285" + result = valid("055# 444$ 285") result == Bool.false # single zero with space is invalid expect - result = valid " 0" + result = valid(" 0") result == Bool.false # more than a single zero is valid expect - result = valid "0000 0" + result = valid("0000 0") result == Bool.true # input digit 9 is correctly converted to output digit 9 expect - result = valid "091" + result = valid("091") result == Bool.true # very long input is valid expect - result = valid "9999999999 9999999999 9999999999 9999999999" + result = valid("9999999999 9999999999 9999999999 9999999999") result == Bool.true # valid luhn with an odd number of digits and non zero first digit expect - result = valid "109" + result = valid("109") result == Bool.true # using ascii value for non-doubled non-digit isn't allowed expect - result = valid "055b 444 285" + result = valid("055b 444 285") result == Bool.false # using ascii value for doubled non-digit isn't allowed expect - result = valid ":9" + result = valid(":9") result == Bool.false # non-numeric, non-space char in the middle with a sum that's divisible by 10 isn't allowed expect - result = valid "59%59" + result = valid("59%59") result == Bool.false diff --git a/exercises/practice/matching-brackets/matching-brackets-test.roc b/exercises/practice/matching-brackets/matching-brackets-test.roc index 6922a02b..61821e0e 100644 --- a/exercises/practice/matching-brackets/matching-brackets-test.roc +++ b/exercises/practice/matching-brackets/matching-brackets-test.roc @@ -8,7 +8,7 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line! "" + Stdout.line!("") import MatchingBrackets exposing [is_paired] diff --git a/exercises/practice/matrix/.meta/template.j2 b/exercises/practice/matrix/.meta/template.j2 index da16ff9f..e3f97d3f 100644 --- a/exercises/practice/matrix/.meta/template.j2 +++ b/exercises/practice/matrix/.meta/template.j2 @@ -8,7 +8,7 @@ import {{ exercise | to_pascal }} exposing [row, column] # {{ case["description"] }} expect matrix_str = {{ case["input"]["string"] | to_roc_multiline_string | indent(8) }} - result = matrix_str |> {{ case["property"] | to_snake }} {{ case["input"]["index"] | to_roc }} + result = matrix_str |> {{ case["property"] | to_snake }}({{ case["input"]["index"] | to_roc }}) result == Ok {{ case["expected"] | to_roc }} {% endfor %} diff --git a/exercises/practice/matrix/matrix-test.roc b/exercises/practice/matrix/matrix-test.roc index de612e8a..7517ceb5 100644 --- a/exercises/practice/matrix/matrix-test.roc +++ b/exercises/practice/matrix/matrix-test.roc @@ -8,14 +8,14 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line! "" + Stdout.line!("") import Matrix exposing [row, column] # extract row from one number matrix expect matrix_str = "1" - result = matrix_str |> row 1 + result = matrix_str |> row(1) result == Ok [1] # can extract row @@ -25,7 +25,7 @@ expect 1 2 3 4 """ - result = matrix_str |> row 2 + result = matrix_str |> row(2) result == Ok [3, 4] # extract row where numbers have different widths @@ -35,7 +35,7 @@ expect 1 2 10 20 """ - result = matrix_str |> row 2 + result = matrix_str |> row(2) result == Ok [10, 20] # can extract row from non-square matrix with no corresponding column @@ -47,13 +47,13 @@ expect 7 8 9 8 7 6 """ - result = matrix_str |> row 4 + result = matrix_str |> row(4) result == Ok [8, 7, 6] # extract column from one number matrix expect matrix_str = "1" - result = matrix_str |> column 1 + result = matrix_str |> column(1) result == Ok [1] # can extract column @@ -64,7 +64,7 @@ expect 4 5 6 7 8 9 """ - result = matrix_str |> column 3 + result = matrix_str |> column(3) result == Ok [3, 6, 9] # can extract column from non-square matrix with no corresponding row @@ -75,7 +75,7 @@ expect 5 6 7 8 9 8 7 6 """ - result = matrix_str |> column 4 + result = matrix_str |> column(4) result == Ok [4, 8, 6] # extract column where numbers have different widths @@ -86,6 +86,6 @@ expect 18 3 1 9 4 800 """ - result = matrix_str |> column 2 + result = matrix_str |> column(2) result == Ok [1903, 3, 4] diff --git a/exercises/practice/meetup/.meta/template.j2 b/exercises/practice/meetup/.meta/template.j2 index 44e298e8..0519cd73 100644 --- a/exercises/practice/meetup/.meta/template.j2 +++ b/exercises/practice/meetup/.meta/template.j2 @@ -7,13 +7,13 @@ import {{ exercise | to_pascal }} exposing [{{ cases[0]["property"] | to_snake } {% for case in cases -%} # {{ case["description"] }} expect - result = {{ case["property"] | to_snake }} { + result = {{ case["property"] | to_snake }}({ year: {{ case["input"]["year"] | to_roc }}, month: {{ case["input"]["month"] | to_roc }}, week: {{ case["input"]["week"] | to_pascal }}, day_of_week: {{ case["input"]["dayofweek"] | to_pascal }}, - } - expected = Ok {{ case["expected"] | to_roc }} + }) + expected = Ok({{ case["expected"] | to_roc }}) result == expected {% endfor %} diff --git a/exercises/practice/meetup/meetup-test.roc b/exercises/practice/meetup/meetup-test.roc index 2149e8e9..79a956fd 100644 --- a/exercises/practice/meetup/meetup-test.roc +++ b/exercises/practice/meetup/meetup-test.roc @@ -9,1052 +9,1242 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line! "" + Stdout.line!("") import Meetup exposing [meetup] # when teenth Monday is the 13th, the first day of the teenth week expect - result = meetup { - year: 2013, - month: 5, - week: Teenth, - day_of_week: Monday, - } - expected = Ok "2013-05-13" + result = meetup( + { + year: 2013, + month: 5, + week: Teenth, + day_of_week: Monday, + }, + ) + expected = Ok("2013-05-13") result == expected # when teenth Monday is the 19th, the last day of the teenth week expect - result = meetup { - year: 2013, - month: 8, - week: Teenth, - day_of_week: Monday, - } - expected = Ok "2013-08-19" + result = meetup( + { + year: 2013, + month: 8, + week: Teenth, + day_of_week: Monday, + }, + ) + expected = Ok("2013-08-19") result == expected # when teenth Monday is some day in the middle of the teenth week expect - result = meetup { - year: 2013, - month: 9, - week: Teenth, - day_of_week: Monday, - } - expected = Ok "2013-09-16" + result = meetup( + { + year: 2013, + month: 9, + week: Teenth, + day_of_week: Monday, + }, + ) + expected = Ok("2013-09-16") result == expected # when teenth Tuesday is the 19th, the last day of the teenth week expect - result = meetup { - year: 2013, - month: 3, - week: Teenth, - day_of_week: Tuesday, - } - expected = Ok "2013-03-19" + result = meetup( + { + year: 2013, + month: 3, + week: Teenth, + day_of_week: Tuesday, + }, + ) + expected = Ok("2013-03-19") result == expected # when teenth Tuesday is some day in the middle of the teenth week expect - result = meetup { - year: 2013, - month: 4, - week: Teenth, - day_of_week: Tuesday, - } - expected = Ok "2013-04-16" + result = meetup( + { + year: 2013, + month: 4, + week: Teenth, + day_of_week: Tuesday, + }, + ) + expected = Ok("2013-04-16") result == expected # when teenth Tuesday is the 13th, the first day of the teenth week expect - result = meetup { - year: 2013, - month: 8, - week: Teenth, - day_of_week: Tuesday, - } - expected = Ok "2013-08-13" + result = meetup( + { + year: 2013, + month: 8, + week: Teenth, + day_of_week: Tuesday, + }, + ) + expected = Ok("2013-08-13") result == expected # when teenth Wednesday is some day in the middle of the teenth week expect - result = meetup { - year: 2013, - month: 1, - week: Teenth, - day_of_week: Wednesday, - } - expected = Ok "2013-01-16" + result = meetup( + { + year: 2013, + month: 1, + week: Teenth, + day_of_week: Wednesday, + }, + ) + expected = Ok("2013-01-16") result == expected # when teenth Wednesday is the 13th, the first day of the teenth week expect - result = meetup { - year: 2013, - month: 2, - week: Teenth, - day_of_week: Wednesday, - } - expected = Ok "2013-02-13" + result = meetup( + { + year: 2013, + month: 2, + week: Teenth, + day_of_week: Wednesday, + }, + ) + expected = Ok("2013-02-13") result == expected # when teenth Wednesday is the 19th, the last day of the teenth week expect - result = meetup { - year: 2013, - month: 6, - week: Teenth, - day_of_week: Wednesday, - } - expected = Ok "2013-06-19" + result = meetup( + { + year: 2013, + month: 6, + week: Teenth, + day_of_week: Wednesday, + }, + ) + expected = Ok("2013-06-19") result == expected # when teenth Thursday is some day in the middle of the teenth week expect - result = meetup { - year: 2013, - month: 5, - week: Teenth, - day_of_week: Thursday, - } - expected = Ok "2013-05-16" + result = meetup( + { + year: 2013, + month: 5, + week: Teenth, + day_of_week: Thursday, + }, + ) + expected = Ok("2013-05-16") result == expected # when teenth Thursday is the 13th, the first day of the teenth week expect - result = meetup { - year: 2013, - month: 6, - week: Teenth, - day_of_week: Thursday, - } - expected = Ok "2013-06-13" + result = meetup( + { + year: 2013, + month: 6, + week: Teenth, + day_of_week: Thursday, + }, + ) + expected = Ok("2013-06-13") result == expected # when teenth Thursday is the 19th, the last day of the teenth week expect - result = meetup { - year: 2013, - month: 9, - week: Teenth, - day_of_week: Thursday, - } - expected = Ok "2013-09-19" + result = meetup( + { + year: 2013, + month: 9, + week: Teenth, + day_of_week: Thursday, + }, + ) + expected = Ok("2013-09-19") result == expected # when teenth Friday is the 19th, the last day of the teenth week expect - result = meetup { - year: 2013, - month: 4, - week: Teenth, - day_of_week: Friday, - } - expected = Ok "2013-04-19" + result = meetup( + { + year: 2013, + month: 4, + week: Teenth, + day_of_week: Friday, + }, + ) + expected = Ok("2013-04-19") result == expected # when teenth Friday is some day in the middle of the teenth week expect - result = meetup { - year: 2013, - month: 8, - week: Teenth, - day_of_week: Friday, - } - expected = Ok "2013-08-16" + result = meetup( + { + year: 2013, + month: 8, + week: Teenth, + day_of_week: Friday, + }, + ) + expected = Ok("2013-08-16") result == expected # when teenth Friday is the 13th, the first day of the teenth week expect - result = meetup { - year: 2013, - month: 9, - week: Teenth, - day_of_week: Friday, - } - expected = Ok "2013-09-13" + result = meetup( + { + year: 2013, + month: 9, + week: Teenth, + day_of_week: Friday, + }, + ) + expected = Ok("2013-09-13") result == expected # when teenth Saturday is some day in the middle of the teenth week expect - result = meetup { - year: 2013, - month: 2, - week: Teenth, - day_of_week: Saturday, - } - expected = Ok "2013-02-16" + result = meetup( + { + year: 2013, + month: 2, + week: Teenth, + day_of_week: Saturday, + }, + ) + expected = Ok("2013-02-16") result == expected # when teenth Saturday is the 13th, the first day of the teenth week expect - result = meetup { - year: 2013, - month: 4, - week: Teenth, - day_of_week: Saturday, - } - expected = Ok "2013-04-13" + result = meetup( + { + year: 2013, + month: 4, + week: Teenth, + day_of_week: Saturday, + }, + ) + expected = Ok("2013-04-13") result == expected # when teenth Saturday is the 19th, the last day of the teenth week expect - result = meetup { - year: 2013, - month: 10, - week: Teenth, - day_of_week: Saturday, - } - expected = Ok "2013-10-19" + result = meetup( + { + year: 2013, + month: 10, + week: Teenth, + day_of_week: Saturday, + }, + ) + expected = Ok("2013-10-19") result == expected # when teenth Sunday is the 19th, the last day of the teenth week expect - result = meetup { - year: 2013, - month: 5, - week: Teenth, - day_of_week: Sunday, - } - expected = Ok "2013-05-19" + result = meetup( + { + year: 2013, + month: 5, + week: Teenth, + day_of_week: Sunday, + }, + ) + expected = Ok("2013-05-19") result == expected # when teenth Sunday is some day in the middle of the teenth week expect - result = meetup { - year: 2013, - month: 6, - week: Teenth, - day_of_week: Sunday, - } - expected = Ok "2013-06-16" + result = meetup( + { + year: 2013, + month: 6, + week: Teenth, + day_of_week: Sunday, + }, + ) + expected = Ok("2013-06-16") result == expected # when teenth Sunday is the 13th, the first day of the teenth week expect - result = meetup { - year: 2013, - month: 10, - week: Teenth, - day_of_week: Sunday, - } - expected = Ok "2013-10-13" + result = meetup( + { + year: 2013, + month: 10, + week: Teenth, + day_of_week: Sunday, + }, + ) + expected = Ok("2013-10-13") result == expected # when first Monday is some day in the middle of the first week expect - result = meetup { - year: 2013, - month: 3, - week: First, - day_of_week: Monday, - } - expected = Ok "2013-03-04" + result = meetup( + { + year: 2013, + month: 3, + week: First, + day_of_week: Monday, + }, + ) + expected = Ok("2013-03-04") result == expected # when first Monday is the 1st, the first day of the first week expect - result = meetup { - year: 2013, - month: 4, - week: First, - day_of_week: Monday, - } - expected = Ok "2013-04-01" + result = meetup( + { + year: 2013, + month: 4, + week: First, + day_of_week: Monday, + }, + ) + expected = Ok("2013-04-01") result == expected # when first Tuesday is the 7th, the last day of the first week expect - result = meetup { - year: 2013, - month: 5, - week: First, - day_of_week: Tuesday, - } - expected = Ok "2013-05-07" + result = meetup( + { + year: 2013, + month: 5, + week: First, + day_of_week: Tuesday, + }, + ) + expected = Ok("2013-05-07") result == expected # when first Tuesday is some day in the middle of the first week expect - result = meetup { - year: 2013, - month: 6, - week: First, - day_of_week: Tuesday, - } - expected = Ok "2013-06-04" + result = meetup( + { + year: 2013, + month: 6, + week: First, + day_of_week: Tuesday, + }, + ) + expected = Ok("2013-06-04") result == expected # when first Wednesday is some day in the middle of the first week expect - result = meetup { - year: 2013, - month: 7, - week: First, - day_of_week: Wednesday, - } - expected = Ok "2013-07-03" + result = meetup( + { + year: 2013, + month: 7, + week: First, + day_of_week: Wednesday, + }, + ) + expected = Ok("2013-07-03") result == expected # when first Wednesday is the 7th, the last day of the first week expect - result = meetup { - year: 2013, - month: 8, - week: First, - day_of_week: Wednesday, - } - expected = Ok "2013-08-07" + result = meetup( + { + year: 2013, + month: 8, + week: First, + day_of_week: Wednesday, + }, + ) + expected = Ok("2013-08-07") result == expected # when first Thursday is some day in the middle of the first week expect - result = meetup { - year: 2013, - month: 9, - week: First, - day_of_week: Thursday, - } - expected = Ok "2013-09-05" + result = meetup( + { + year: 2013, + month: 9, + week: First, + day_of_week: Thursday, + }, + ) + expected = Ok("2013-09-05") result == expected # when first Thursday is another day in the middle of the first week expect - result = meetup { - year: 2013, - month: 10, - week: First, - day_of_week: Thursday, - } - expected = Ok "2013-10-03" + result = meetup( + { + year: 2013, + month: 10, + week: First, + day_of_week: Thursday, + }, + ) + expected = Ok("2013-10-03") result == expected # when first Friday is the 1st, the first day of the first week expect - result = meetup { - year: 2013, - month: 11, - week: First, - day_of_week: Friday, - } - expected = Ok "2013-11-01" + result = meetup( + { + year: 2013, + month: 11, + week: First, + day_of_week: Friday, + }, + ) + expected = Ok("2013-11-01") result == expected # when first Friday is some day in the middle of the first week expect - result = meetup { - year: 2013, - month: 12, - week: First, - day_of_week: Friday, - } - expected = Ok "2013-12-06" + result = meetup( + { + year: 2013, + month: 12, + week: First, + day_of_week: Friday, + }, + ) + expected = Ok("2013-12-06") result == expected # when first Saturday is some day in the middle of the first week expect - result = meetup { - year: 2013, - month: 1, - week: First, - day_of_week: Saturday, - } - expected = Ok "2013-01-05" + result = meetup( + { + year: 2013, + month: 1, + week: First, + day_of_week: Saturday, + }, + ) + expected = Ok("2013-01-05") result == expected # when first Saturday is another day in the middle of the first week expect - result = meetup { - year: 2013, - month: 2, - week: First, - day_of_week: Saturday, - } - expected = Ok "2013-02-02" + result = meetup( + { + year: 2013, + month: 2, + week: First, + day_of_week: Saturday, + }, + ) + expected = Ok("2013-02-02") result == expected # when first Sunday is some day in the middle of the first week expect - result = meetup { - year: 2013, - month: 3, - week: First, - day_of_week: Sunday, - } - expected = Ok "2013-03-03" + result = meetup( + { + year: 2013, + month: 3, + week: First, + day_of_week: Sunday, + }, + ) + expected = Ok("2013-03-03") result == expected # when first Sunday is the 7th, the last day of the first week expect - result = meetup { - year: 2013, - month: 4, - week: First, - day_of_week: Sunday, - } - expected = Ok "2013-04-07" + result = meetup( + { + year: 2013, + month: 4, + week: First, + day_of_week: Sunday, + }, + ) + expected = Ok("2013-04-07") result == expected # when second Monday is some day in the middle of the second week expect - result = meetup { - year: 2013, - month: 3, - week: Second, - day_of_week: Monday, - } - expected = Ok "2013-03-11" + result = meetup( + { + year: 2013, + month: 3, + week: Second, + day_of_week: Monday, + }, + ) + expected = Ok("2013-03-11") result == expected # when second Monday is the 8th, the first day of the second week expect - result = meetup { - year: 2013, - month: 4, - week: Second, - day_of_week: Monday, - } - expected = Ok "2013-04-08" + result = meetup( + { + year: 2013, + month: 4, + week: Second, + day_of_week: Monday, + }, + ) + expected = Ok("2013-04-08") result == expected # when second Tuesday is the 14th, the last day of the second week expect - result = meetup { - year: 2013, - month: 5, - week: Second, - day_of_week: Tuesday, - } - expected = Ok "2013-05-14" + result = meetup( + { + year: 2013, + month: 5, + week: Second, + day_of_week: Tuesday, + }, + ) + expected = Ok("2013-05-14") result == expected # when second Tuesday is some day in the middle of the second week expect - result = meetup { - year: 2013, - month: 6, - week: Second, - day_of_week: Tuesday, - } - expected = Ok "2013-06-11" + result = meetup( + { + year: 2013, + month: 6, + week: Second, + day_of_week: Tuesday, + }, + ) + expected = Ok("2013-06-11") result == expected # when second Wednesday is some day in the middle of the second week expect - result = meetup { - year: 2013, - month: 7, - week: Second, - day_of_week: Wednesday, - } - expected = Ok "2013-07-10" + result = meetup( + { + year: 2013, + month: 7, + week: Second, + day_of_week: Wednesday, + }, + ) + expected = Ok("2013-07-10") result == expected # when second Wednesday is the 14th, the last day of the second week expect - result = meetup { - year: 2013, - month: 8, - week: Second, - day_of_week: Wednesday, - } - expected = Ok "2013-08-14" + result = meetup( + { + year: 2013, + month: 8, + week: Second, + day_of_week: Wednesday, + }, + ) + expected = Ok("2013-08-14") result == expected # when second Thursday is some day in the middle of the second week expect - result = meetup { - year: 2013, - month: 9, - week: Second, - day_of_week: Thursday, - } - expected = Ok "2013-09-12" + result = meetup( + { + year: 2013, + month: 9, + week: Second, + day_of_week: Thursday, + }, + ) + expected = Ok("2013-09-12") result == expected # when second Thursday is another day in the middle of the second week expect - result = meetup { - year: 2013, - month: 10, - week: Second, - day_of_week: Thursday, - } - expected = Ok "2013-10-10" + result = meetup( + { + year: 2013, + month: 10, + week: Second, + day_of_week: Thursday, + }, + ) + expected = Ok("2013-10-10") result == expected # when second Friday is the 8th, the first day of the second week expect - result = meetup { - year: 2013, - month: 11, - week: Second, - day_of_week: Friday, - } - expected = Ok "2013-11-08" + result = meetup( + { + year: 2013, + month: 11, + week: Second, + day_of_week: Friday, + }, + ) + expected = Ok("2013-11-08") result == expected # when second Friday is some day in the middle of the second week expect - result = meetup { - year: 2013, - month: 12, - week: Second, - day_of_week: Friday, - } - expected = Ok "2013-12-13" + result = meetup( + { + year: 2013, + month: 12, + week: Second, + day_of_week: Friday, + }, + ) + expected = Ok("2013-12-13") result == expected # when second Saturday is some day in the middle of the second week expect - result = meetup { - year: 2013, - month: 1, - week: Second, - day_of_week: Saturday, - } - expected = Ok "2013-01-12" + result = meetup( + { + year: 2013, + month: 1, + week: Second, + day_of_week: Saturday, + }, + ) + expected = Ok("2013-01-12") result == expected # when second Saturday is another day in the middle of the second week expect - result = meetup { - year: 2013, - month: 2, - week: Second, - day_of_week: Saturday, - } - expected = Ok "2013-02-09" + result = meetup( + { + year: 2013, + month: 2, + week: Second, + day_of_week: Saturday, + }, + ) + expected = Ok("2013-02-09") result == expected # when second Sunday is some day in the middle of the second week expect - result = meetup { - year: 2013, - month: 3, - week: Second, - day_of_week: Sunday, - } - expected = Ok "2013-03-10" + result = meetup( + { + year: 2013, + month: 3, + week: Second, + day_of_week: Sunday, + }, + ) + expected = Ok("2013-03-10") result == expected # when second Sunday is the 14th, the last day of the second week expect - result = meetup { - year: 2013, - month: 4, - week: Second, - day_of_week: Sunday, - } - expected = Ok "2013-04-14" + result = meetup( + { + year: 2013, + month: 4, + week: Second, + day_of_week: Sunday, + }, + ) + expected = Ok("2013-04-14") result == expected # when third Monday is some day in the middle of the third week expect - result = meetup { - year: 2013, - month: 3, - week: Third, - day_of_week: Monday, - } - expected = Ok "2013-03-18" + result = meetup( + { + year: 2013, + month: 3, + week: Third, + day_of_week: Monday, + }, + ) + expected = Ok("2013-03-18") result == expected # when third Monday is the 15th, the first day of the third week expect - result = meetup { - year: 2013, - month: 4, - week: Third, - day_of_week: Monday, - } - expected = Ok "2013-04-15" + result = meetup( + { + year: 2013, + month: 4, + week: Third, + day_of_week: Monday, + }, + ) + expected = Ok("2013-04-15") result == expected # when third Tuesday is the 21st, the last day of the third week expect - result = meetup { - year: 2013, - month: 5, - week: Third, - day_of_week: Tuesday, - } - expected = Ok "2013-05-21" + result = meetup( + { + year: 2013, + month: 5, + week: Third, + day_of_week: Tuesday, + }, + ) + expected = Ok("2013-05-21") result == expected # when third Tuesday is some day in the middle of the third week expect - result = meetup { - year: 2013, - month: 6, - week: Third, - day_of_week: Tuesday, - } - expected = Ok "2013-06-18" + result = meetup( + { + year: 2013, + month: 6, + week: Third, + day_of_week: Tuesday, + }, + ) + expected = Ok("2013-06-18") result == expected # when third Wednesday is some day in the middle of the third week expect - result = meetup { - year: 2013, - month: 7, - week: Third, - day_of_week: Wednesday, - } - expected = Ok "2013-07-17" + result = meetup( + { + year: 2013, + month: 7, + week: Third, + day_of_week: Wednesday, + }, + ) + expected = Ok("2013-07-17") result == expected # when third Wednesday is the 21st, the last day of the third week expect - result = meetup { - year: 2013, - month: 8, - week: Third, - day_of_week: Wednesday, - } - expected = Ok "2013-08-21" + result = meetup( + { + year: 2013, + month: 8, + week: Third, + day_of_week: Wednesday, + }, + ) + expected = Ok("2013-08-21") result == expected # when third Thursday is some day in the middle of the third week expect - result = meetup { - year: 2013, - month: 9, - week: Third, - day_of_week: Thursday, - } - expected = Ok "2013-09-19" + result = meetup( + { + year: 2013, + month: 9, + week: Third, + day_of_week: Thursday, + }, + ) + expected = Ok("2013-09-19") result == expected # when third Thursday is another day in the middle of the third week expect - result = meetup { - year: 2013, - month: 10, - week: Third, - day_of_week: Thursday, - } - expected = Ok "2013-10-17" + result = meetup( + { + year: 2013, + month: 10, + week: Third, + day_of_week: Thursday, + }, + ) + expected = Ok("2013-10-17") result == expected # when third Friday is the 15th, the first day of the third week expect - result = meetup { - year: 2013, - month: 11, - week: Third, - day_of_week: Friday, - } - expected = Ok "2013-11-15" + result = meetup( + { + year: 2013, + month: 11, + week: Third, + day_of_week: Friday, + }, + ) + expected = Ok("2013-11-15") result == expected # when third Friday is some day in the middle of the third week expect - result = meetup { - year: 2013, - month: 12, - week: Third, - day_of_week: Friday, - } - expected = Ok "2013-12-20" + result = meetup( + { + year: 2013, + month: 12, + week: Third, + day_of_week: Friday, + }, + ) + expected = Ok("2013-12-20") result == expected # when third Saturday is some day in the middle of the third week expect - result = meetup { - year: 2013, - month: 1, - week: Third, - day_of_week: Saturday, - } - expected = Ok "2013-01-19" + result = meetup( + { + year: 2013, + month: 1, + week: Third, + day_of_week: Saturday, + }, + ) + expected = Ok("2013-01-19") result == expected # when third Saturday is another day in the middle of the third week expect - result = meetup { - year: 2013, - month: 2, - week: Third, - day_of_week: Saturday, - } - expected = Ok "2013-02-16" + result = meetup( + { + year: 2013, + month: 2, + week: Third, + day_of_week: Saturday, + }, + ) + expected = Ok("2013-02-16") result == expected # when third Sunday is some day in the middle of the third week expect - result = meetup { - year: 2013, - month: 3, - week: Third, - day_of_week: Sunday, - } - expected = Ok "2013-03-17" + result = meetup( + { + year: 2013, + month: 3, + week: Third, + day_of_week: Sunday, + }, + ) + expected = Ok("2013-03-17") result == expected # when third Sunday is the 21st, the last day of the third week expect - result = meetup { - year: 2013, - month: 4, - week: Third, - day_of_week: Sunday, - } - expected = Ok "2013-04-21" + result = meetup( + { + year: 2013, + month: 4, + week: Third, + day_of_week: Sunday, + }, + ) + expected = Ok("2013-04-21") result == expected # when fourth Monday is some day in the middle of the fourth week expect - result = meetup { - year: 2013, - month: 3, - week: Fourth, - day_of_week: Monday, - } - expected = Ok "2013-03-25" + result = meetup( + { + year: 2013, + month: 3, + week: Fourth, + day_of_week: Monday, + }, + ) + expected = Ok("2013-03-25") result == expected # when fourth Monday is the 22nd, the first day of the fourth week expect - result = meetup { - year: 2013, - month: 4, - week: Fourth, - day_of_week: Monday, - } - expected = Ok "2013-04-22" + result = meetup( + { + year: 2013, + month: 4, + week: Fourth, + day_of_week: Monday, + }, + ) + expected = Ok("2013-04-22") result == expected # when fourth Tuesday is the 28th, the last day of the fourth week expect - result = meetup { - year: 2013, - month: 5, - week: Fourth, - day_of_week: Tuesday, - } - expected = Ok "2013-05-28" + result = meetup( + { + year: 2013, + month: 5, + week: Fourth, + day_of_week: Tuesday, + }, + ) + expected = Ok("2013-05-28") result == expected # when fourth Tuesday is some day in the middle of the fourth week expect - result = meetup { - year: 2013, - month: 6, - week: Fourth, - day_of_week: Tuesday, - } - expected = Ok "2013-06-25" + result = meetup( + { + year: 2013, + month: 6, + week: Fourth, + day_of_week: Tuesday, + }, + ) + expected = Ok("2013-06-25") result == expected # when fourth Wednesday is some day in the middle of the fourth week expect - result = meetup { - year: 2013, - month: 7, - week: Fourth, - day_of_week: Wednesday, - } - expected = Ok "2013-07-24" + result = meetup( + { + year: 2013, + month: 7, + week: Fourth, + day_of_week: Wednesday, + }, + ) + expected = Ok("2013-07-24") result == expected # when fourth Wednesday is the 28th, the last day of the fourth week expect - result = meetup { - year: 2013, - month: 8, - week: Fourth, - day_of_week: Wednesday, - } - expected = Ok "2013-08-28" + result = meetup( + { + year: 2013, + month: 8, + week: Fourth, + day_of_week: Wednesday, + }, + ) + expected = Ok("2013-08-28") result == expected # when fourth Thursday is some day in the middle of the fourth week expect - result = meetup { - year: 2013, - month: 9, - week: Fourth, - day_of_week: Thursday, - } - expected = Ok "2013-09-26" + result = meetup( + { + year: 2013, + month: 9, + week: Fourth, + day_of_week: Thursday, + }, + ) + expected = Ok("2013-09-26") result == expected # when fourth Thursday is another day in the middle of the fourth week expect - result = meetup { - year: 2013, - month: 10, - week: Fourth, - day_of_week: Thursday, - } - expected = Ok "2013-10-24" + result = meetup( + { + year: 2013, + month: 10, + week: Fourth, + day_of_week: Thursday, + }, + ) + expected = Ok("2013-10-24") result == expected # when fourth Friday is the 22nd, the first day of the fourth week expect - result = meetup { - year: 2013, - month: 11, - week: Fourth, - day_of_week: Friday, - } - expected = Ok "2013-11-22" + result = meetup( + { + year: 2013, + month: 11, + week: Fourth, + day_of_week: Friday, + }, + ) + expected = Ok("2013-11-22") result == expected # when fourth Friday is some day in the middle of the fourth week expect - result = meetup { - year: 2013, - month: 12, - week: Fourth, - day_of_week: Friday, - } - expected = Ok "2013-12-27" + result = meetup( + { + year: 2013, + month: 12, + week: Fourth, + day_of_week: Friday, + }, + ) + expected = Ok("2013-12-27") result == expected # when fourth Saturday is some day in the middle of the fourth week expect - result = meetup { - year: 2013, - month: 1, - week: Fourth, - day_of_week: Saturday, - } - expected = Ok "2013-01-26" + result = meetup( + { + year: 2013, + month: 1, + week: Fourth, + day_of_week: Saturday, + }, + ) + expected = Ok("2013-01-26") result == expected # when fourth Saturday is another day in the middle of the fourth week expect - result = meetup { - year: 2013, - month: 2, - week: Fourth, - day_of_week: Saturday, - } - expected = Ok "2013-02-23" + result = meetup( + { + year: 2013, + month: 2, + week: Fourth, + day_of_week: Saturday, + }, + ) + expected = Ok("2013-02-23") result == expected # when fourth Sunday is some day in the middle of the fourth week expect - result = meetup { - year: 2013, - month: 3, - week: Fourth, - day_of_week: Sunday, - } - expected = Ok "2013-03-24" + result = meetup( + { + year: 2013, + month: 3, + week: Fourth, + day_of_week: Sunday, + }, + ) + expected = Ok("2013-03-24") result == expected # when fourth Sunday is the 28th, the last day of the fourth week expect - result = meetup { - year: 2013, - month: 4, - week: Fourth, - day_of_week: Sunday, - } - expected = Ok "2013-04-28" + result = meetup( + { + year: 2013, + month: 4, + week: Fourth, + day_of_week: Sunday, + }, + ) + expected = Ok("2013-04-28") result == expected # last Monday in a month with four Mondays expect - result = meetup { - year: 2013, - month: 3, - week: Last, - day_of_week: Monday, - } - expected = Ok "2013-03-25" + result = meetup( + { + year: 2013, + month: 3, + week: Last, + day_of_week: Monday, + }, + ) + expected = Ok("2013-03-25") result == expected # last Monday in a month with five Mondays expect - result = meetup { - year: 2013, - month: 4, - week: Last, - day_of_week: Monday, - } - expected = Ok "2013-04-29" + result = meetup( + { + year: 2013, + month: 4, + week: Last, + day_of_week: Monday, + }, + ) + expected = Ok("2013-04-29") result == expected # last Tuesday in a month with four Tuesdays expect - result = meetup { - year: 2013, - month: 5, - week: Last, - day_of_week: Tuesday, - } - expected = Ok "2013-05-28" + result = meetup( + { + year: 2013, + month: 5, + week: Last, + day_of_week: Tuesday, + }, + ) + expected = Ok("2013-05-28") result == expected # last Tuesday in another month with four Tuesdays expect - result = meetup { - year: 2013, - month: 6, - week: Last, - day_of_week: Tuesday, - } - expected = Ok "2013-06-25" + result = meetup( + { + year: 2013, + month: 6, + week: Last, + day_of_week: Tuesday, + }, + ) + expected = Ok("2013-06-25") result == expected # last Wednesday in a month with five Wednesdays expect - result = meetup { - year: 2013, - month: 7, - week: Last, - day_of_week: Wednesday, - } - expected = Ok "2013-07-31" + result = meetup( + { + year: 2013, + month: 7, + week: Last, + day_of_week: Wednesday, + }, + ) + expected = Ok("2013-07-31") result == expected # last Wednesday in a month with four Wednesdays expect - result = meetup { - year: 2013, - month: 8, - week: Last, - day_of_week: Wednesday, - } - expected = Ok "2013-08-28" + result = meetup( + { + year: 2013, + month: 8, + week: Last, + day_of_week: Wednesday, + }, + ) + expected = Ok("2013-08-28") result == expected # last Thursday in a month with four Thursdays expect - result = meetup { - year: 2013, - month: 9, - week: Last, - day_of_week: Thursday, - } - expected = Ok "2013-09-26" + result = meetup( + { + year: 2013, + month: 9, + week: Last, + day_of_week: Thursday, + }, + ) + expected = Ok("2013-09-26") result == expected # last Thursday in a month with five Thursdays expect - result = meetup { - year: 2013, - month: 10, - week: Last, - day_of_week: Thursday, - } - expected = Ok "2013-10-31" + result = meetup( + { + year: 2013, + month: 10, + week: Last, + day_of_week: Thursday, + }, + ) + expected = Ok("2013-10-31") result == expected # last Friday in a month with five Fridays expect - result = meetup { - year: 2013, - month: 11, - week: Last, - day_of_week: Friday, - } - expected = Ok "2013-11-29" + result = meetup( + { + year: 2013, + month: 11, + week: Last, + day_of_week: Friday, + }, + ) + expected = Ok("2013-11-29") result == expected # last Friday in a month with four Fridays expect - result = meetup { - year: 2013, - month: 12, - week: Last, - day_of_week: Friday, - } - expected = Ok "2013-12-27" + result = meetup( + { + year: 2013, + month: 12, + week: Last, + day_of_week: Friday, + }, + ) + expected = Ok("2013-12-27") result == expected # last Saturday in a month with four Saturdays expect - result = meetup { - year: 2013, - month: 1, - week: Last, - day_of_week: Saturday, - } - expected = Ok "2013-01-26" + result = meetup( + { + year: 2013, + month: 1, + week: Last, + day_of_week: Saturday, + }, + ) + expected = Ok("2013-01-26") result == expected # last Saturday in another month with four Saturdays expect - result = meetup { - year: 2013, - month: 2, - week: Last, - day_of_week: Saturday, - } - expected = Ok "2013-02-23" + result = meetup( + { + year: 2013, + month: 2, + week: Last, + day_of_week: Saturday, + }, + ) + expected = Ok("2013-02-23") result == expected # last Sunday in a month with five Sundays expect - result = meetup { - year: 2013, - month: 3, - week: Last, - day_of_week: Sunday, - } - expected = Ok "2013-03-31" + result = meetup( + { + year: 2013, + month: 3, + week: Last, + day_of_week: Sunday, + }, + ) + expected = Ok("2013-03-31") result == expected # last Sunday in a month with four Sundays expect - result = meetup { - year: 2013, - month: 4, - week: Last, - day_of_week: Sunday, - } - expected = Ok "2013-04-28" + result = meetup( + { + year: 2013, + month: 4, + week: Last, + day_of_week: Sunday, + }, + ) + expected = Ok("2013-04-28") result == expected # when last Wednesday in February in a leap year is the 29th expect - result = meetup { - year: 2012, - month: 2, - week: Last, - day_of_week: Wednesday, - } - expected = Ok "2012-02-29" + result = meetup( + { + year: 2012, + month: 2, + week: Last, + day_of_week: Wednesday, + }, + ) + expected = Ok("2012-02-29") result == expected # last Wednesday in December that is also the last day of the year expect - result = meetup { - year: 2014, - month: 12, - week: Last, - day_of_week: Wednesday, - } - expected = Ok "2014-12-31" + result = meetup( + { + year: 2014, + month: 12, + week: Last, + day_of_week: Wednesday, + }, + ) + expected = Ok("2014-12-31") result == expected # when last Sunday in February in a non-leap year is not the 29th expect - result = meetup { - year: 2015, - month: 2, - week: Last, - day_of_week: Sunday, - } - expected = Ok "2015-02-22" + result = meetup( + { + year: 2015, + month: 2, + week: Last, + day_of_week: Sunday, + }, + ) + expected = Ok("2015-02-22") result == expected # when first Friday is the 7th, the last day of the first week expect - result = meetup { - year: 2012, - month: 12, - week: First, - day_of_week: Friday, - } - expected = Ok "2012-12-07" + result = meetup( + { + year: 2012, + month: 12, + week: First, + day_of_week: Friday, + }, + ) + expected = Ok("2012-12-07") result == expected diff --git a/exercises/practice/micro-blog/.meta/template.j2 b/exercises/practice/micro-blog/.meta/template.j2 index f6874d2a..0d29d5f2 100644 --- a/exercises/practice/micro-blog/.meta/template.j2 +++ b/exercises/practice/micro-blog/.meta/template.j2 @@ -7,7 +7,7 @@ import {{ exercise | to_pascal }} exposing [{{ cases[0]["property"] | to_snake } {% for case in cases -%} # {{ case["description"] }} expect - result = {{ case["property"] | to_snake }} {{ case["input"]["phrase"] | to_roc }} + result = {{ case["property"] | to_snake }}({{ case["input"]["phrase"] | to_roc }}) result == Ok {{ case["expected"] | to_roc }} {% endfor %} diff --git a/exercises/practice/micro-blog/micro-blog-test.roc b/exercises/practice/micro-blog/micro-blog-test.roc index 9f1f1f19..4d94396a 100644 --- a/exercises/practice/micro-blog/micro-blog-test.roc +++ b/exercises/practice/micro-blog/micro-blog-test.roc @@ -9,67 +9,67 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line! "" + Stdout.line!("") import MicroBlog exposing [truncate] # English language short expect - result = truncate "Hi" + result = truncate("Hi") result == Ok "Hi" # English language long expect - result = truncate "Hello there" + result = truncate("Hello there") result == Ok "Hello" # German language short (broth) expect - result = truncate "brühe" + result = truncate("brühe") result == Ok "brühe" # German language long (bear carpet → beards) expect - result = truncate "Bärteppich" + result = truncate("Bärteppich") result == Ok "Bärte" # Bulgarian language short (good) expect - result = truncate "Добър" + result = truncate("Добър") result == Ok "Добър" # Greek language short (health) expect - result = truncate "υγειά" + result = truncate("υγειά") result == Ok "υγειά" # Maths short expect - result = truncate "a=πr²" + result = truncate("a=πr²") result == Ok "a=πr²" # Maths long expect - result = truncate "∅⊊ℕ⊊ℤ⊊ℚ⊊ℝ⊊ℂ" + result = truncate("∅⊊ℕ⊊ℤ⊊ℚ⊊ℝ⊊ℂ") result == Ok "∅⊊ℕ⊊ℤ" # English and emoji short expect - result = truncate "Fly 🛫" + result = truncate("Fly 🛫") result == Ok "Fly 🛫" # Emoji short expect - result = truncate "💇" + result = truncate("💇") result == Ok "💇" # Emoji long expect - result = truncate "❄🌡🤧🤒🏥🕰😀" + result = truncate("❄🌡🤧🤒🏥🕰😀") result == Ok "❄🌡🤧🤒🏥" # Royal Flush? expect - result = truncate "🃎🂸🃅🃋🃍🃁🃊" + result = truncate("🃎🂸🃅🃋🃍🃁🃊") result == Ok "🃎🂸🃅🃋🃍" diff --git a/exercises/practice/minesweeper/.meta/template.j2 b/exercises/practice/minesweeper/.meta/template.j2 index 6398b101..7e04ffab 100644 --- a/exercises/practice/minesweeper/.meta/template.j2 +++ b/exercises/practice/minesweeper/.meta/template.j2 @@ -7,9 +7,9 @@ import {{ exercise | to_pascal }} exposing [{{ cases[0]["property"] | to_snake } {% for case in cases -%} # {{ case["description"] }} expect - minefield = {{ case["input"]["minefield"] | to_roc_multiline_string | replace(" ", "·") | indent(8) }} |> Str.replace_each "·" " " - result = {{ case["property"] | to_snake }} minefield - expected = {{ case["expected"] | to_roc_multiline_string | replace(" ", "·") | indent(8) }} |> Str.replace_each "·" " " + minefield = {{ case["input"]["minefield"] | to_roc_multiline_string | replace(" ", "·") | indent(8) }} |> Str.replace_each("·", " ") + result = {{ case["property"] | to_snake }}(minefield) + expected = {{ case["expected"] | to_roc_multiline_string | replace(" ", "·") | indent(8) }} |> Str.replace_each("·", " ") result == expected {% endfor %} diff --git a/exercises/practice/minesweeper/minesweeper-test.roc b/exercises/practice/minesweeper/minesweeper-test.roc index 601218fe..87276176 100644 --- a/exercises/practice/minesweeper/minesweeper-test.roc +++ b/exercises/practice/minesweeper/minesweeper-test.roc @@ -8,22 +8,22 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line! "" + Stdout.line!("") import Minesweeper exposing [annotate] # no rows expect - minefield = "" |> Str.replace_each "·" " " - result = annotate minefield - expected = "" |> Str.replace_each "·" " " + minefield = "" |> Str.replace_each("·", " ") + result = annotate(minefield) + expected = "" |> Str.replace_each("·", " ") result == expected # no columns expect - minefield = "" |> Str.replace_each "·" " " - result = annotate minefield - expected = "" |> Str.replace_each "·" " " + minefield = "" |> Str.replace_each("·", " ") + result = annotate(minefield) + expected = "" |> Str.replace_each("·", " ") result == expected # no mines @@ -34,15 +34,15 @@ expect ··· ··· """ - |> Str.replace_each "·" " " - result = annotate minefield + |> Str.replace_each("·", " ") + result = annotate(minefield) expected = """ ··· ··· ··· """ - |> Str.replace_each "·" " " + |> Str.replace_each("·", " ") result == expected # minefield with only mines @@ -53,15 +53,15 @@ expect *** *** """ - |> Str.replace_each "·" " " - result = annotate minefield + |> Str.replace_each("·", " ") + result = annotate(minefield) expected = """ *** *** *** """ - |> Str.replace_each "·" " " + |> Str.replace_each("·", " ") result == expected # mine surrounded by spaces @@ -72,15 +72,15 @@ expect ·*· ··· """ - |> Str.replace_each "·" " " - result = annotate minefield + |> Str.replace_each("·", " ") + result = annotate(minefield) expected = """ 111 1*1 111 """ - |> Str.replace_each "·" " " + |> Str.replace_each("·", " ") result == expected # space surrounded by mines @@ -91,29 +91,29 @@ expect *·* *** """ - |> Str.replace_each "·" " " - result = annotate minefield + |> Str.replace_each("·", " ") + result = annotate(minefield) expected = """ *** *8* *** """ - |> Str.replace_each "·" " " + |> Str.replace_each("·", " ") result == expected # horizontal line expect - minefield = "·*·*·" |> Str.replace_each "·" " " - result = annotate minefield - expected = "1*2*1" |> Str.replace_each "·" " " + minefield = "·*·*·" |> Str.replace_each("·", " ") + result = annotate(minefield) + expected = "1*2*1" |> Str.replace_each("·", " ") result == expected # horizontal line, mines at edges expect - minefield = "*···*" |> Str.replace_each "·" " " - result = annotate minefield - expected = "*1·1*" |> Str.replace_each "·" " " + minefield = "*···*" |> Str.replace_each("·", " ") + result = annotate(minefield) + expected = "*1·1*" |> Str.replace_each("·", " ") result == expected # vertical line @@ -126,8 +126,8 @@ expect * · """ - |> Str.replace_each "·" " " - result = annotate minefield + |> Str.replace_each("·", " ") + result = annotate(minefield) expected = """ 1 @@ -136,7 +136,7 @@ expect * 1 """ - |> Str.replace_each "·" " " + |> Str.replace_each("·", " ") result == expected # vertical line, mines at edges @@ -149,8 +149,8 @@ expect · * """ - |> Str.replace_each "·" " " - result = annotate minefield + |> Str.replace_each("·", " ") + result = annotate(minefield) expected = """ * @@ -159,7 +159,7 @@ expect 1 * """ - |> Str.replace_each "·" " " + |> Str.replace_each("·", " ") result == expected # cross @@ -172,8 +172,8 @@ expect ··*·· ··*·· """ - |> Str.replace_each "·" " " - result = annotate minefield + |> Str.replace_each("·", " ") + result = annotate(minefield) expected = """ ·2*2· @@ -182,7 +182,7 @@ expect 25*52 ·2*2· """ - |> Str.replace_each "·" " " + |> Str.replace_each("·", " ") result == expected # large minefield @@ -196,8 +196,8 @@ expect ·*··*· ······ """ - |> Str.replace_each "·" " " - result = annotate minefield + |> Str.replace_each("·", " ") + result = annotate(minefield) expected = """ 1*22*1 @@ -207,6 +207,6 @@ expect 1*22*2 111111 """ - |> Str.replace_each "·" " " + |> Str.replace_each("·", " ") result == expected diff --git a/exercises/practice/nth-prime/.meta/template.j2 b/exercises/practice/nth-prime/.meta/template.j2 index dc61da84..7c8f0f90 100644 --- a/exercises/practice/nth-prime/.meta/template.j2 +++ b/exercises/practice/nth-prime/.meta/template.j2 @@ -7,7 +7,7 @@ import {{ exercise | to_pascal }} exposing [{{ cases[0]["property"] | to_snake } {% for case in cases -%} # {{ case["description"] }} expect - result = {{ case["property"] | to_snake }} {{ case["input"]["number"] }} + result = {{ case["property"] | to_snake }}({{ case["input"]["number"] }}) {%- if case["expected"]["error"] %} result |> Result.is_err {%- else %} diff --git a/exercises/practice/nth-prime/nth-prime-test.roc b/exercises/practice/nth-prime/nth-prime-test.roc index 6bb1741d..512ce43d 100644 --- a/exercises/practice/nth-prime/nth-prime-test.roc +++ b/exercises/practice/nth-prime/nth-prime-test.roc @@ -8,32 +8,32 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line! "" + Stdout.line!("") import NthPrime exposing [prime] # first prime expect - result = prime 1 + result = prime(1) result == Ok 2 # second prime expect - result = prime 2 + result = prime(2) result == Ok 3 # sixth prime expect - result = prime 6 + result = prime(6) result == Ok 13 # big prime expect - result = prime 10001 + result = prime(10001) result == Ok 104743 # there is no zeroth prime expect - result = prime 0 + result = prime(0) result |> Result.is_err diff --git a/exercises/practice/nucleotide-count/.meta/template.j2 b/exercises/practice/nucleotide-count/.meta/template.j2 index 75efdd73..7daf42e3 100644 --- a/exercises/practice/nucleotide-count/.meta/template.j2 +++ b/exercises/practice/nucleotide-count/.meta/template.j2 @@ -7,7 +7,7 @@ import {{ exercise | to_pascal }} exposing [{{ cases[0]["property"] | to_snake } {% for case in cases -%} # {{ case["description"] }} expect - result = {{ case["property"] | to_snake }} {{ case["input"]["strand"] | to_roc }} + result = {{ case["property"] | to_snake }}({{ case["input"]["strand"] | to_roc }}) {%- if case["expected"]["error"] %} Result.is_err result {%- else %} diff --git a/exercises/practice/nucleotide-count/nucleotide-count-test.roc b/exercises/practice/nucleotide-count/nucleotide-count-test.roc index 8f722a9d..6c7909b7 100644 --- a/exercises/practice/nucleotide-count/nucleotide-count-test.roc +++ b/exercises/practice/nucleotide-count/nucleotide-count-test.roc @@ -8,32 +8,32 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line! "" + Stdout.line!("") import NucleotideCount exposing [nucleotide_counts] # empty strand expect - result = nucleotide_counts "" + result = nucleotide_counts("") result == Ok { a: 0, c: 0, g: 0, t: 0 } # can count one nucleotide in single-character input expect - result = nucleotide_counts "G" + result = nucleotide_counts("G") result == Ok { a: 0, c: 0, g: 1, t: 0 } # strand with repeated nucleotide expect - result = nucleotide_counts "GGGGGGG" + result = nucleotide_counts("GGGGGGG") result == Ok { a: 0, c: 0, g: 7, t: 0 } # strand with multiple nucleotides expect - result = nucleotide_counts "AGCTTTTCATTCTGACTGCAACGGGCAATATGTCTCTGTGTGGATTAAAAAAAGAGTGTCTGATAGCAGC" + result = nucleotide_counts("AGCTTTTCATTCTGACTGCAACGGGCAATATGTCTCTGTGTGGATTAAAAAAAGAGTGTCTGATAGCAGC") result == Ok { a: 20, c: 12, g: 17, t: 21 } # strand with invalid nucleotides expect - result = nucleotide_counts "AGXXACT" + result = nucleotide_counts("AGXXACT") Result.is_err result diff --git a/exercises/practice/ocr-numbers/ocr-numbers-test.roc b/exercises/practice/ocr-numbers/ocr-numbers-test.roc index 44b441ac..8e2ecd54 100644 --- a/exercises/practice/ocr-numbers/ocr-numbers-test.roc +++ b/exercises/practice/ocr-numbers/ocr-numbers-test.roc @@ -8,7 +8,7 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line! "" + Stdout.line!("") import OcrNumbers exposing [convert] diff --git a/exercises/practice/palindrome-products/.meta/template.j2 b/exercises/practice/palindrome-products/.meta/template.j2 index 0a466f7f..c09d6f3d 100644 --- a/exercises/practice/palindrome-products/.meta/template.j2 +++ b/exercises/practice/palindrome-products/.meta/template.j2 @@ -6,24 +6,24 @@ import {{ exercise | to_pascal }} exposing [smallest, largest] isEq = |result, expected| when (result, expected) is - (Ok {value, factors}, Ok {value: expectedValue, factors: expectedFactors}) -> + (Ok({value, factors}), Ok({value: expectedValue, factors: expectedFactors})) -> value == expectedValue && factors == expectedFactors _ -> Bool.false {% for case in cases -%} # {{ case["description"] }} expect - result = {{ case["property"] | to_snake }} {{ case["input"] | to_roc }} + result = {{ case["property"] | to_snake }}({{ case["input"] | to_roc }}) {%- if case["expected"]["error"] %} result |> Result.is_err {%- else %} - expected = Ok { + expected = Ok({ value: {% if case["expected"]["value"] is none %}0{% else %}{{ case["expected"]["value"] }}{% endif %}, factors: Set.from_list [ {%- for pair in case["expected"]["factors"] %} ({{ pair[0] }}, {{ pair[1] }}),{% endfor %} ] - } + }) result |> isEq expected {%- endif %} diff --git a/exercises/practice/palindrome-products/palindrome-products-test.roc b/exercises/practice/palindrome-products/palindrome-products-test.roc index 284ede4d..dba7f585 100644 --- a/exercises/practice/palindrome-products/palindrome-products-test.roc +++ b/exercises/practice/palindrome-products/palindrome-products-test.roc @@ -8,144 +8,166 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line! "" + Stdout.line!("") import PalindromeProducts exposing [smallest, largest] isEq = |result, expected| when (result, expected) is - (Ok { value, factors }, Ok { value: expectedValue, factors: expectedFactors }) -> + (Ok({ value, factors }), Ok({ value: expectedValue, factors: expectedFactors })) -> value == expectedValue and factors == expectedFactors _ -> Bool.false # find the smallest palindrome from single digit factors expect - result = smallest { min: 1, max: 9 } - expected = Ok { - value: 1, - factors: Set.from_list [ - (1, 1), - ], - } + result = smallest({ min: 1, max: 9 }) + expected = Ok( + { + value: 1, + factors: Set.from_list [ + (1, 1), + ], + }, + ) result |> isEq expected # find the largest palindrome from single digit factors expect - result = largest { min: 1, max: 9 } - expected = Ok { - value: 9, - factors: Set.from_list [ - (1, 9), - (3, 3), - ], - } + result = largest({ min: 1, max: 9 }) + expected = Ok( + { + value: 9, + factors: Set.from_list [ + (1, 9), + (3, 3), + ], + }, + ) result |> isEq expected # find the smallest palindrome from double digit factors expect - result = smallest { min: 10, max: 99 } - expected = Ok { - value: 121, - factors: Set.from_list [ - (11, 11), - ], - } + result = smallest({ min: 10, max: 99 }) + expected = Ok( + { + value: 121, + factors: Set.from_list [ + (11, 11), + ], + }, + ) result |> isEq expected # find the largest palindrome from double digit factors expect - result = largest { min: 10, max: 99 } - expected = Ok { - value: 9009, - factors: Set.from_list [ - (91, 99), - ], - } + result = largest({ min: 10, max: 99 }) + expected = Ok( + { + value: 9009, + factors: Set.from_list [ + (91, 99), + ], + }, + ) result |> isEq expected # find the smallest palindrome from triple digit factors expect - result = smallest { min: 100, max: 999 } - expected = Ok { - value: 10201, - factors: Set.from_list [ - (101, 101), - ], - } + result = smallest({ min: 100, max: 999 }) + expected = Ok( + { + value: 10201, + factors: Set.from_list [ + (101, 101), + ], + }, + ) result |> isEq expected # find the largest palindrome from triple digit factors expect - result = largest { min: 100, max: 999 } - expected = Ok { - value: 906609, - factors: Set.from_list [ - (913, 993), - ], - } + result = largest({ min: 100, max: 999 }) + expected = Ok( + { + value: 906609, + factors: Set.from_list [ + (913, 993), + ], + }, + ) result |> isEq expected # find the smallest palindrome from four digit factors expect - result = smallest { min: 1000, max: 9999 } - expected = Ok { - value: 1002001, - factors: Set.from_list [ - (1001, 1001), - ], - } + result = smallest({ min: 1000, max: 9999 }) + expected = Ok( + { + value: 1002001, + factors: Set.from_list [ + (1001, 1001), + ], + }, + ) result |> isEq expected # find the largest palindrome from four digit factors expect - result = largest { min: 1000, max: 9999 } - expected = Ok { - value: 99000099, - factors: Set.from_list [ - (9901, 9999), - ], - } + result = largest({ min: 1000, max: 9999 }) + expected = Ok( + { + value: 99000099, + factors: Set.from_list [ + (9901, 9999), + ], + }, + ) result |> isEq expected # empty result for smallest if no palindrome in the range expect - result = smallest { min: 1002, max: 1003 } - expected = Ok { - value: 0, - factors: Set.from_list [ - ], - } + result = smallest({ min: 1002, max: 1003 }) + expected = Ok( + { + value: 0, + factors: Set.from_list [ + ], + }, + ) result |> isEq expected # empty result for largest if no palindrome in the range expect - result = largest { min: 15, max: 15 } - expected = Ok { - value: 0, - factors: Set.from_list [ - ], - } + result = largest({ min: 15, max: 15 }) + expected = Ok( + { + value: 0, + factors: Set.from_list [ + ], + }, + ) result |> isEq expected # error result for smallest if min is more than max expect - result = smallest { min: 10000, max: 1 } + result = smallest({ min: 10000, max: 1 }) result |> Result.is_err # error result for largest if min is more than max expect - result = largest { min: 2, max: 1 } + result = largest({ min: 2, max: 1 }) result |> Result.is_err # smallest product does not use the smallest factor expect - result = smallest { min: 3215, max: 4000 } - expected = Ok { - value: 10988901, - factors: Set.from_list [ - (3297, 3333), - ], - } + result = smallest({ min: 3215, max: 4000 }) + expected = Ok( + { + value: 10988901, + factors: Set.from_list [ + (3297, 3333), + ], + }, + ) result |> isEq expected diff --git a/exercises/practice/pangram/.meta/template.j2 b/exercises/practice/pangram/.meta/template.j2 index e0040de3..c0511911 100644 --- a/exercises/practice/pangram/.meta/template.j2 +++ b/exercises/practice/pangram/.meta/template.j2 @@ -7,7 +7,7 @@ import {{ exercise | to_pascal }} exposing [is_pangram] {% for case in cases -%} # {{ case["description"] }} expect - result = {{ case["property"] | to_snake }} {{ case["input"]["sentence"] | to_roc }} + result = {{ case["property"] | to_snake }}({{ case["input"]["sentence"] | to_roc }}) result == {{ case["expected"] | to_roc }} {% endfor %} diff --git a/exercises/practice/pangram/pangram-test.roc b/exercises/practice/pangram/pangram-test.roc index 857e27ad..ac1de933 100644 --- a/exercises/practice/pangram/pangram-test.roc +++ b/exercises/practice/pangram/pangram-test.roc @@ -8,57 +8,57 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line! "" + Stdout.line!("") import Pangram exposing [is_pangram] # empty sentence expect - result = is_pangram "" + result = is_pangram("") result == Bool.false # perfect lower case expect - result = is_pangram "abcdefghijklmnopqrstuvwxyz" + result = is_pangram("abcdefghijklmnopqrstuvwxyz") result == Bool.true # only lower case expect - result = is_pangram "the quick brown fox jumps over the lazy dog" + result = is_pangram("the quick brown fox jumps over the lazy dog") result == Bool.true # missing the letter 'x' expect - result = is_pangram "a quick movement of the enemy will jeopardize five gunboats" + result = is_pangram("a quick movement of the enemy will jeopardize five gunboats") result == Bool.false # missing the letter 'h' expect - result = is_pangram "five boxing wizards jump quickly at it" + result = is_pangram("five boxing wizards jump quickly at it") result == Bool.false # with underscores expect - result = is_pangram "the_quick_brown_fox_jumps_over_the_lazy_dog" + result = is_pangram("the_quick_brown_fox_jumps_over_the_lazy_dog") result == Bool.true # with numbers expect - result = is_pangram "the 1 quick brown fox jumps over the 2 lazy dogs" + result = is_pangram("the 1 quick brown fox jumps over the 2 lazy dogs") result == Bool.true # missing letters replaced by numbers expect - result = is_pangram "7h3 qu1ck brown fox jumps ov3r 7h3 lazy dog" + result = is_pangram("7h3 qu1ck brown fox jumps ov3r 7h3 lazy dog") result == Bool.false # mixed case and punctuation expect - result = is_pangram "\"Five quacking Zephyrs jolt my wax bed.\"" + result = is_pangram("\"Five quacking Zephyrs jolt my wax bed.\"") result == Bool.true # a-m and A-M are 26 different characters but not a pangram expect - result = is_pangram "abcdefghijklm ABCDEFGHIJKLM" + result = is_pangram("abcdefghijklm ABCDEFGHIJKLM") result == Bool.false diff --git a/exercises/practice/pascals-triangle/pascals-triangle-test.roc b/exercises/practice/pascals-triangle/pascals-triangle-test.roc index eb18c455..1c3191d6 100644 --- a/exercises/practice/pascals-triangle/pascals-triangle-test.roc +++ b/exercises/practice/pascals-triangle/pascals-triangle-test.roc @@ -8,7 +8,7 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line! "" + Stdout.line!("") import PascalsTriangle exposing [pascals_triangle] diff --git a/exercises/practice/perfect-numbers/.meta/template.j2 b/exercises/practice/perfect-numbers/.meta/template.j2 index 4c5ea305..85ac393c 100644 --- a/exercises/practice/perfect-numbers/.meta/template.j2 +++ b/exercises/practice/perfect-numbers/.meta/template.j2 @@ -12,7 +12,7 @@ import {{ exercise | to_pascal }} exposing [classify] {% for case in supercase["cases"] -%} # {{ case["description"] }} expect - result = {{ case["property"] | to_snake }} {{ case["input"]["number"] }} + result = {{ case["property"] | to_snake }}({{ case["input"]["number"] }}) {%- if case["expected"]["error"] %} Result.is_err result {%- else %} diff --git a/exercises/practice/perfect-numbers/perfect-numbers-test.roc b/exercises/practice/perfect-numbers/perfect-numbers-test.roc index 7437cd02..fcba677b 100644 --- a/exercises/practice/perfect-numbers/perfect-numbers-test.roc +++ b/exercises/practice/perfect-numbers/perfect-numbers-test.roc @@ -8,7 +8,7 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line! "" + Stdout.line!("") import PerfectNumbers exposing [classify] @@ -18,17 +18,17 @@ import PerfectNumbers exposing [classify] # Smallest perfect number is classified correctly expect - result = classify 6 + result = classify(6) result == Ok Perfect # Medium perfect number is classified correctly expect - result = classify 28 + result = classify(28) result == Ok Perfect # Large perfect number is classified correctly expect - result = classify 33550336 + result = classify(33550336) result == Ok Perfect ## @@ -37,17 +37,17 @@ expect # Smallest abundant number is classified correctly expect - result = classify 12 + result = classify(12) result == Ok Abundant # Medium abundant number is classified correctly expect - result = classify 30 + result = classify(30) result == Ok Abundant # Large abundant number is classified correctly expect - result = classify 33550335 + result = classify(33550335) result == Ok Abundant ## @@ -56,27 +56,27 @@ expect # Smallest prime deficient number is classified correctly expect - result = classify 2 + result = classify(2) result == Ok Deficient # Smallest non-prime deficient number is classified correctly expect - result = classify 4 + result = classify(4) result == Ok Deficient # Medium deficient number is classified correctly expect - result = classify 32 + result = classify(32) result == Ok Deficient # Large deficient number is classified correctly expect - result = classify 33550337 + result = classify(33550337) result == Ok Deficient # Edge case (no factors other than itself) is classified correctly expect - result = classify 1 + result = classify(1) result == Ok Deficient ## @@ -85,6 +85,6 @@ expect # Zero is rejected (as it is not a positive integer) expect - result = classify 0 + result = classify(0) Result.is_err result diff --git a/exercises/practice/phone-number/.meta/template.j2 b/exercises/practice/phone-number/.meta/template.j2 index 0e3df4ab..c6e5ddd9 100644 --- a/exercises/practice/phone-number/.meta/template.j2 +++ b/exercises/practice/phone-number/.meta/template.j2 @@ -7,7 +7,7 @@ import {{ exercise | to_pascal }} exposing [{{ cases[0]["property"] | to_snake } {% for case in cases -%} # {{ case["description"] }} expect - result = {{ case["property"] | to_snake }} {{ case["input"]["phrase"] | to_roc }} + result = {{ case["property"] | to_snake }}({{ case["input"]["phrase"] | to_roc }}) {%- if case["expected"]["error"] %} result |> Result.is_err {%- else %} diff --git a/exercises/practice/phone-number/phone-number-test.roc b/exercises/practice/phone-number/phone-number-test.roc index 39fe9ee1..f2a2abb2 100644 --- a/exercises/practice/phone-number/phone-number-test.roc +++ b/exercises/practice/phone-number/phone-number-test.roc @@ -8,102 +8,102 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line! "" + Stdout.line!("") import PhoneNumber exposing [clean] # cleans the number expect - result = clean "(223) 456-7890" + result = clean("(223) 456-7890") expected = Ok "2234567890" result == expected # cleans numbers with dots expect - result = clean "223.456.7890" + result = clean("223.456.7890") expected = Ok "2234567890" result == expected # cleans numbers with multiple spaces expect - result = clean "223 456 7890 " + result = clean("223 456 7890 ") expected = Ok "2234567890" result == expected # invalid when 9 digits expect - result = clean "123456789" + result = clean("123456789") result |> Result.is_err # invalid when 11 digits does not start with a 1 expect - result = clean "22234567890" + result = clean("22234567890") result |> Result.is_err # valid when 11 digits and starting with 1 expect - result = clean "12234567890" + result = clean("12234567890") expected = Ok "2234567890" result == expected # valid when 11 digits and starting with 1 even with punctuation expect - result = clean "+1 (223) 456-7890" + result = clean("+1 (223) 456-7890") expected = Ok "2234567890" result == expected # invalid when more than 11 digits expect - result = clean "321234567890" + result = clean("321234567890") result |> Result.is_err # invalid with letters expect - result = clean "523-abc-7890" + result = clean("523-abc-7890") result |> Result.is_err # invalid with punctuations expect - result = clean "523-@:!-7890" + result = clean("523-@:!-7890") result |> Result.is_err # invalid if area code starts with 0 expect - result = clean "(023) 456-7890" + result = clean("(023) 456-7890") result |> Result.is_err # invalid if area code starts with 1 expect - result = clean "(123) 456-7890" + result = clean("(123) 456-7890") result |> Result.is_err # invalid if exchange code starts with 0 expect - result = clean "(223) 056-7890" + result = clean("(223) 056-7890") result |> Result.is_err # invalid if exchange code starts with 1 expect - result = clean "(223) 156-7890" + result = clean("(223) 156-7890") result |> Result.is_err # invalid if area code starts with 0 on valid 11-digit number expect - result = clean "1 (023) 456-7890" + result = clean("1 (023) 456-7890") result |> Result.is_err # invalid if area code starts with 1 on valid 11-digit number expect - result = clean "1 (123) 456-7890" + result = clean("1 (123) 456-7890") result |> Result.is_err # invalid if exchange code starts with 0 on valid 11-digit number expect - result = clean "1 (223) 056-7890" + result = clean("1 (223) 056-7890") result |> Result.is_err # invalid if exchange code starts with 1 on valid 11-digit number expect - result = clean "1 (223) 156-7890" + result = clean("1 (223) 156-7890") result |> Result.is_err diff --git a/exercises/practice/pig-latin/.meta/template.j2 b/exercises/practice/pig-latin/.meta/template.j2 index a667978e..b4ae2f04 100644 --- a/exercises/practice/pig-latin/.meta/template.j2 +++ b/exercises/practice/pig-latin/.meta/template.j2 @@ -12,7 +12,7 @@ import {{ exercise | to_pascal }} exposing [{{ cases[0]["cases"][0]["property"] {% for case in supercase["cases"] -%} # {{ case["description"] }} expect - result = {{ case["property"] | to_snake }} {{ case["input"]["phrase"] | to_roc }} + result = {{ case["property"] | to_snake }}({{ case["input"]["phrase"] | to_roc }}) result == {{ case["expected"] | to_roc }} {% endfor %} diff --git a/exercises/practice/pig-latin/pig-latin-test.roc b/exercises/practice/pig-latin/pig-latin-test.roc index 222db292..dcf77d52 100644 --- a/exercises/practice/pig-latin/pig-latin-test.roc +++ b/exercises/practice/pig-latin/pig-latin-test.roc @@ -8,7 +8,7 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line! "" + Stdout.line!("") import PigLatin exposing [translate] @@ -18,32 +18,32 @@ import PigLatin exposing [translate] # word beginning with a expect - result = translate "apple" + result = translate("apple") result == "appleay" # word beginning with e expect - result = translate "ear" + result = translate("ear") result == "earay" # word beginning with i expect - result = translate "igloo" + result = translate("igloo") result == "iglooay" # word beginning with o expect - result = translate "object" + result = translate("object") result == "objectay" # word beginning with u expect - result = translate "under" + result = translate("under") result == "underay" # word beginning with a vowel and followed by a qu expect - result = translate "equal" + result = translate("equal") result == "equalay" ## @@ -52,27 +52,27 @@ expect # word beginning with p expect - result = translate "pig" + result = translate("pig") result == "igpay" # word beginning with k expect - result = translate "koala" + result = translate("koala") result == "oalakay" # word beginning with x expect - result = translate "xenon" + result = translate("xenon") result == "enonxay" # word beginning with q without a following u expect - result = translate "qat" + result = translate("qat") result == "atqay" # word beginning with consonant and vowel containing qu expect - result = translate "liquid" + result = translate("liquid") result == "iquidlay" ## @@ -81,32 +81,32 @@ expect # word beginning with ch expect - result = translate "chair" + result = translate("chair") result == "airchay" # word beginning with qu expect - result = translate "queen" + result = translate("queen") result == "eenquay" # word beginning with qu and a preceding consonant expect - result = translate "square" + result = translate("square") result == "aresquay" # word beginning with th expect - result = translate "therapy" + result = translate("therapy") result == "erapythay" # word beginning with thr expect - result = translate "thrush" + result = translate("thrush") result == "ushthray" # word beginning with sch expect - result = translate "school" + result = translate("school") result == "oolschay" ## @@ -115,12 +115,12 @@ expect # word beginning with yt expect - result = translate "yttria" + result = translate("yttria") result == "yttriaay" # word beginning with xr expect - result = translate "xray" + result = translate("xray") result == "xrayay" ## @@ -129,17 +129,17 @@ expect # y is treated like a consonant at the beginning of a word expect - result = translate "yellow" + result = translate("yellow") result == "ellowyay" # y is treated like a vowel at the end of a consonant cluster expect - result = translate "rhythm" + result = translate("rhythm") result == "ythmrhay" # y as second letter in two letter word expect - result = translate "my" + result = translate("my") result == "ymay" ## @@ -148,6 +148,6 @@ expect # a whole phrase expect - result = translate "quick fast run" + result = translate("quick fast run") result == "ickquay astfay unray" diff --git a/exercises/practice/poker/.meta/template.j2 b/exercises/practice/poker/.meta/template.j2 index 37993dd9..b3dcde9d 100644 --- a/exercises/practice/poker/.meta/template.j2 +++ b/exercises/practice/poker/.meta/template.j2 @@ -8,7 +8,7 @@ import {{ exercise | to_pascal }} exposing [{{ cases[0]["property"] | to_snake } # {{ case["description"] }} expect hands = {{ case["input"]["hands"] | to_roc }} - result = {{ case["property"] | to_snake }} hands - result == Ok {{ case["expected"] | to_roc }} + result = {{ case["property"] | to_snake }}(hands) + result == Ok({{ case["expected"] | to_roc }}) {% endfor %} diff --git a/exercises/practice/poker/poker-test.roc b/exercises/practice/poker/poker-test.roc index 83c4c303..5903a9cb 100644 --- a/exercises/practice/poker/poker-test.roc +++ b/exercises/practice/poker/poker-test.roc @@ -8,229 +8,229 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line! "" + Stdout.line!("") import Poker exposing [best_hands] # single hand always wins expect hands = ["4S 5S 7H 8D JC"] - result = best_hands hands - result == Ok ["4S 5S 7H 8D JC"] + result = best_hands(hands) + result == Ok(["4S 5S 7H 8D JC"]) # highest card out of all hands wins expect hands = ["4D 5S 6S 8D 3C", "2S 4C 7S 9H 10H", "3S 4S 5D 6H JH"] - result = best_hands hands - result == Ok ["3S 4S 5D 6H JH"] + result = best_hands(hands) + result == Ok(["3S 4S 5D 6H JH"]) # a tie has multiple winners expect hands = ["4D 5S 6S 8D 3C", "2S 4C 7S 9H 10H", "3S 4S 5D 6H JH", "3H 4H 5C 6C JD"] - result = best_hands hands - result == Ok ["3S 4S 5D 6H JH", "3H 4H 5C 6C JD"] + result = best_hands(hands) + result == Ok(["3S 4S 5D 6H JH", "3H 4H 5C 6C JD"]) # multiple hands with the same high cards, tie compares next highest ranked, down to last card expect hands = ["3S 5H 6S 8D 7H", "2S 5D 6D 8C 7S"] - result = best_hands hands - result == Ok ["3S 5H 6S 8D 7H"] + result = best_hands(hands) + result == Ok(["3S 5H 6S 8D 7H"]) # winning high card hand also has the lowest card expect hands = ["2S 5H 6S 8D 7H", "3S 4D 6D 8C 7S"] - result = best_hands hands - result == Ok ["2S 5H 6S 8D 7H"] + result = best_hands(hands) + result == Ok(["2S 5H 6S 8D 7H"]) # one pair beats high card expect hands = ["4S 5H 6C 8D KH", "2S 4H 6S 4D JH"] - result = best_hands hands - result == Ok ["2S 4H 6S 4D JH"] + result = best_hands(hands) + result == Ok(["2S 4H 6S 4D JH"]) # highest pair wins expect hands = ["4S 2H 6S 2D JH", "2S 4H 6C 4D JD"] - result = best_hands hands - result == Ok ["2S 4H 6C 4D JD"] + result = best_hands(hands) + result == Ok(["2S 4H 6C 4D JD"]) # both hands have the same pair, high card wins expect hands = ["4H 4S AH JC 3D", "4C 4D AS 5D 6C"] - result = best_hands hands - result == Ok ["4H 4S AH JC 3D"] + result = best_hands(hands) + result == Ok(["4H 4S AH JC 3D"]) # two pairs beats one pair expect hands = ["2S 8H 6S 8D JH", "4S 5H 4C 8C 5C"] - result = best_hands hands - result == Ok ["4S 5H 4C 8C 5C"] + result = best_hands(hands) + result == Ok(["4S 5H 4C 8C 5C"]) # both hands have two pairs, highest ranked pair wins expect hands = ["2S 8H 2D 8D 3H", "4S 5H 4C 8S 5D"] - result = best_hands hands - result == Ok ["2S 8H 2D 8D 3H"] + result = best_hands(hands) + result == Ok(["2S 8H 2D 8D 3H"]) # both hands have two pairs, with the same highest ranked pair, tie goes to low pair expect hands = ["2S QS 2C QD JH", "JD QH JS 8D QC"] - result = best_hands hands - result == Ok ["JD QH JS 8D QC"] + result = best_hands(hands) + result == Ok(["JD QH JS 8D QC"]) # both hands have two identically ranked pairs, tie goes to remaining card (kicker) expect hands = ["JD QH JS 8D QC", "JS QS JC 2D QD"] - result = best_hands hands - result == Ok ["JD QH JS 8D QC"] + result = best_hands(hands) + result == Ok(["JD QH JS 8D QC"]) # both hands have two pairs that add to the same value, win goes to highest pair expect hands = ["6S 6H 3S 3H AS", "7H 7S 2H 2S AC"] - result = best_hands hands - result == Ok ["7H 7S 2H 2S AC"] + result = best_hands(hands) + result == Ok(["7H 7S 2H 2S AC"]) # two pairs first ranked by largest pair expect hands = ["5C 2S 5S 4H 4C", "6S 2S 6H 7C 2C"] - result = best_hands hands - result == Ok ["6S 2S 6H 7C 2C"] + result = best_hands(hands) + result == Ok(["6S 2S 6H 7C 2C"]) # three of a kind beats two pair expect hands = ["2S 8H 2H 8D JH", "4S 5H 4C 8S 4H"] - result = best_hands hands - result == Ok ["4S 5H 4C 8S 4H"] + result = best_hands(hands) + result == Ok(["4S 5H 4C 8S 4H"]) # both hands have three of a kind, tie goes to highest ranked triplet expect hands = ["2S 2H 2C 8D JH", "4S AH AS 8C AD"] - result = best_hands hands - result == Ok ["4S AH AS 8C AD"] + result = best_hands(hands) + result == Ok(["4S AH AS 8C AD"]) # with multiple decks, two players can have same three of a kind, ties go to highest remaining cards expect hands = ["5S AH AS 7C AD", "4S AH AS 8C AD"] - result = best_hands hands - result == Ok ["4S AH AS 8C AD"] + result = best_hands(hands) + result == Ok(["4S AH AS 8C AD"]) # a straight beats three of a kind expect hands = ["4S 5H 4C 8D 4H", "3S 4D 2S 6D 5C"] - result = best_hands hands - result == Ok ["3S 4D 2S 6D 5C"] + result = best_hands(hands) + result == Ok(["3S 4D 2S 6D 5C"]) # aces can end a straight (10 J Q K A) expect hands = ["4S 5H 4C 8D 4H", "10D JH QS KD AC"] - result = best_hands hands - result == Ok ["10D JH QS KD AC"] + result = best_hands(hands) + result == Ok(["10D JH QS KD AC"]) # aces can start a straight (A 2 3 4 5) expect hands = ["4S 5H 4C 8D 4H", "4D AH 3S 2D 5C"] - result = best_hands hands - result == Ok ["4D AH 3S 2D 5C"] + result = best_hands(hands) + result == Ok(["4D AH 3S 2D 5C"]) # aces cannot be in the middle of a straight (Q K A 2 3) expect hands = ["2C 3D 7H 5H 2S", "QS KH AC 2D 3S"] - result = best_hands hands - result == Ok ["2C 3D 7H 5H 2S"] + result = best_hands(hands) + result == Ok(["2C 3D 7H 5H 2S"]) # both hands with a straight, tie goes to highest ranked card expect hands = ["4S 6C 7S 8D 5H", "5S 7H 8S 9D 6H"] - result = best_hands hands - result == Ok ["5S 7H 8S 9D 6H"] + result = best_hands(hands) + result == Ok(["5S 7H 8S 9D 6H"]) # even though an ace is usually high, a 5-high straight is the lowest-scoring straight expect hands = ["2H 3C 4D 5D 6H", "4S AH 3S 2D 5H"] - result = best_hands hands - result == Ok ["2H 3C 4D 5D 6H"] + result = best_hands(hands) + result == Ok(["2H 3C 4D 5D 6H"]) # flush beats a straight expect hands = ["4C 6H 7D 8D 5H", "2S 4S 5S 6S 7S"] - result = best_hands hands - result == Ok ["2S 4S 5S 6S 7S"] + result = best_hands(hands) + result == Ok(["2S 4S 5S 6S 7S"]) # both hands have a flush, tie goes to high card, down to the last one if necessary expect hands = ["2H 7H 8H 9H 6H", "3S 5S 6S 7S 8S"] - result = best_hands hands - result == Ok ["2H 7H 8H 9H 6H"] + result = best_hands(hands) + result == Ok(["2H 7H 8H 9H 6H"]) # full house beats a flush expect hands = ["3H 6H 7H 8H 5H", "4S 5H 4C 5D 4H"] - result = best_hands hands - result == Ok ["4S 5H 4C 5D 4H"] + result = best_hands(hands) + result == Ok(["4S 5H 4C 5D 4H"]) # both hands have a full house, tie goes to highest-ranked triplet expect hands = ["4H 4S 4D 9S 9D", "5H 5S 5D 8S 8D"] - result = best_hands hands - result == Ok ["5H 5S 5D 8S 8D"] + result = best_hands(hands) + result == Ok(["5H 5S 5D 8S 8D"]) # with multiple decks, both hands have a full house with the same triplet, tie goes to the pair expect hands = ["5H 5S 5D 9S 9D", "5H 5S 5D 8S 8D"] - result = best_hands hands - result == Ok ["5H 5S 5D 9S 9D"] + result = best_hands(hands) + result == Ok(["5H 5S 5D 9S 9D"]) # four of a kind beats a full house expect hands = ["4S 5H 4D 5D 4H", "3S 3H 2S 3D 3C"] - result = best_hands hands - result == Ok ["3S 3H 2S 3D 3C"] + result = best_hands(hands) + result == Ok(["3S 3H 2S 3D 3C"]) # both hands have four of a kind, tie goes to high quad expect hands = ["2S 2H 2C 8D 2D", "4S 5H 5S 5D 5C"] - result = best_hands hands - result == Ok ["4S 5H 5S 5D 5C"] + result = best_hands(hands) + result == Ok(["4S 5H 5S 5D 5C"]) # with multiple decks, both hands with identical four of a kind, tie determined by kicker expect hands = ["3S 3H 2S 3D 3C", "3S 3H 4S 3D 3C"] - result = best_hands hands - result == Ok ["3S 3H 4S 3D 3C"] + result = best_hands(hands) + result == Ok(["3S 3H 4S 3D 3C"]) # straight flush beats four of a kind expect hands = ["4S 5H 5S 5D 5C", "7S 8S 9S 6S 10S"] - result = best_hands hands - result == Ok ["7S 8S 9S 6S 10S"] + result = best_hands(hands) + result == Ok(["7S 8S 9S 6S 10S"]) # aces can end a straight flush (10 J Q K A) expect hands = ["KC AH AS AD AC", "10C JC QC KC AC"] - result = best_hands hands - result == Ok ["10C JC QC KC AC"] + result = best_hands(hands) + result == Ok(["10C JC QC KC AC"]) # aces can start a straight flush (A 2 3 4 5) expect hands = ["KS AH AS AD AC", "4H AH 3H 2H 5H"] - result = best_hands hands - result == Ok ["4H AH 3H 2H 5H"] + result = best_hands(hands) + result == Ok(["4H AH 3H 2H 5H"]) # aces cannot be in the middle of a straight flush (Q K A 2 3) expect hands = ["2C AC QC 10C KC", "QH KH AH 2H 3H"] - result = best_hands hands - result == Ok ["2C AC QC 10C KC"] + result = best_hands(hands) + result == Ok(["2C AC QC 10C KC"]) # both hands have a straight flush, tie goes to highest-ranked card expect hands = ["4H 6H 7H 8H 5H", "5S 7S 8S 9S 6S"] - result = best_hands hands - result == Ok ["5S 7S 8S 9S 6S"] + result = best_hands(hands) + result == Ok(["5S 7S 8S 9S 6S"]) # even though an ace is usually high, a 5-high straight flush is the lowest-scoring straight flush expect hands = ["2H 3H 4H 5H 6H", "4D AD 3D 2D 5D"] - result = best_hands hands - result == Ok ["2H 3H 4H 5H 6H"] + result = best_hands(hands) + result == Ok(["2H 3H 4H 5H 6H"]) diff --git a/exercises/practice/prime-factors/.meta/template.j2 b/exercises/practice/prime-factors/.meta/template.j2 index a8cb222b..b4b90411 100644 --- a/exercises/practice/prime-factors/.meta/template.j2 +++ b/exercises/practice/prime-factors/.meta/template.j2 @@ -7,7 +7,7 @@ import {{ exercise | to_pascal }} exposing [{{ exercise | to_snake }}] {% for case in cases -%} # {{ case["description"] }} expect - result = {{ exercise | to_snake }} {{ case["input"]["value"] | to_roc }} + result = {{ exercise | to_snake }}({{ case["input"]["value"] | to_roc }}) result == {{ case["expected"] | to_roc }} {% endfor %} diff --git a/exercises/practice/prime-factors/prime-factors-test.roc b/exercises/practice/prime-factors/prime-factors-test.roc index 51a06cf9..9aa693bf 100644 --- a/exercises/practice/prime-factors/prime-factors-test.roc +++ b/exercises/practice/prime-factors/prime-factors-test.roc @@ -8,67 +8,67 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line! "" + Stdout.line!("") import PrimeFactors exposing [prime_factors] # no factors expect - result = prime_factors 1 + result = prime_factors(1) result == [] # prime number expect - result = prime_factors 2 + result = prime_factors(2) result == [2] # another prime number expect - result = prime_factors 3 + result = prime_factors(3) result == [3] # square of a prime expect - result = prime_factors 9 + result = prime_factors(9) result == [3, 3] # product of first prime expect - result = prime_factors 4 + result = prime_factors(4) result == [2, 2] # cube of a prime expect - result = prime_factors 8 + result = prime_factors(8) result == [2, 2, 2] # product of second prime expect - result = prime_factors 27 + result = prime_factors(27) result == [3, 3, 3] # product of third prime expect - result = prime_factors 625 + result = prime_factors(625) result == [5, 5, 5, 5] # product of first and second prime expect - result = prime_factors 6 + result = prime_factors(6) result == [2, 3] # product of primes and non-primes expect - result = prime_factors 12 + result = prime_factors(12) result == [2, 2, 3] # product of primes expect - result = prime_factors 901255 + result = prime_factors(901255) result == [5, 17, 23, 461] # factors include a large prime expect - result = prime_factors 93819012551 + result = prime_factors(93819012551) result == [11, 9539, 894119] diff --git a/exercises/practice/protein-translation/.meta/template.j2 b/exercises/practice/protein-translation/.meta/template.j2 index cb28adcf..9b602769 100644 --- a/exercises/practice/protein-translation/.meta/template.j2 +++ b/exercises/practice/protein-translation/.meta/template.j2 @@ -12,7 +12,7 @@ expect {%- if case["expected"]["error"] %} result |> Result.is_err {%- else %} - result == Ok [{%- for aminoAcid in case["expected"] -%}{{ aminoAcid | to_pascal }}, {%- endfor %}] + result == Ok([{%- for aminoAcid in case["expected"] -%}{{ aminoAcid | to_pascal }}, {%- endfor %}]) {%- endif %} {% endfor %} diff --git a/exercises/practice/protein-translation/protein-translation-test.roc b/exercises/practice/protein-translation/protein-translation-test.roc index d5162f48..58b71eaf 100644 --- a/exercises/practice/protein-translation/protein-translation-test.roc +++ b/exercises/practice/protein-translation/protein-translation-test.roc @@ -8,7 +8,7 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line! "" + Stdout.line!("") import ProteinTranslation exposing [to_protein] @@ -16,163 +16,163 @@ import ProteinTranslation exposing [to_protein] expect rna = "" result = rna |> to_protein - result == Ok [] + result == Ok([]) # Methionine RNA sequence expect rna = "AUG" result = rna |> to_protein - result == Ok [Methionine] + result == Ok([Methionine]) # Phenylalanine RNA sequence 1 expect rna = "UUU" result = rna |> to_protein - result == Ok [Phenylalanine] + result == Ok([Phenylalanine]) # Phenylalanine RNA sequence 2 expect rna = "UUC" result = rna |> to_protein - result == Ok [Phenylalanine] + result == Ok([Phenylalanine]) # Leucine RNA sequence 1 expect rna = "UUA" result = rna |> to_protein - result == Ok [Leucine] + result == Ok([Leucine]) # Leucine RNA sequence 2 expect rna = "UUG" result = rna |> to_protein - result == Ok [Leucine] + result == Ok([Leucine]) # Serine RNA sequence 1 expect rna = "UCU" result = rna |> to_protein - result == Ok [Serine] + result == Ok([Serine]) # Serine RNA sequence 2 expect rna = "UCC" result = rna |> to_protein - result == Ok [Serine] + result == Ok([Serine]) # Serine RNA sequence 3 expect rna = "UCA" result = rna |> to_protein - result == Ok [Serine] + result == Ok([Serine]) # Serine RNA sequence 4 expect rna = "UCG" result = rna |> to_protein - result == Ok [Serine] + result == Ok([Serine]) # Tyrosine RNA sequence 1 expect rna = "UAU" result = rna |> to_protein - result == Ok [Tyrosine] + result == Ok([Tyrosine]) # Tyrosine RNA sequence 2 expect rna = "UAC" result = rna |> to_protein - result == Ok [Tyrosine] + result == Ok([Tyrosine]) # Cysteine RNA sequence 1 expect rna = "UGU" result = rna |> to_protein - result == Ok [Cysteine] + result == Ok([Cysteine]) # Cysteine RNA sequence 2 expect rna = "UGC" result = rna |> to_protein - result == Ok [Cysteine] + result == Ok([Cysteine]) # Tryptophan RNA sequence expect rna = "UGG" result = rna |> to_protein - result == Ok [Tryptophan] + result == Ok([Tryptophan]) # STOP codon RNA sequence 1 expect rna = "UAA" result = rna |> to_protein - result == Ok [] + result == Ok([]) # STOP codon RNA sequence 2 expect rna = "UAG" result = rna |> to_protein - result == Ok [] + result == Ok([]) # STOP codon RNA sequence 3 expect rna = "UGA" result = rna |> to_protein - result == Ok [] + result == Ok([]) # Sequence of two protein codons translates into proteins expect rna = "UUUUUU" result = rna |> to_protein - result == Ok [Phenylalanine, Phenylalanine] + result == Ok([Phenylalanine, Phenylalanine]) # Sequence of two different protein codons translates into proteins expect rna = "UUAUUG" result = rna |> to_protein - result == Ok [Leucine, Leucine] + result == Ok([Leucine, Leucine]) # Translate RNA strand into correct protein list expect rna = "AUGUUUUGG" result = rna |> to_protein - result == Ok [Methionine, Phenylalanine, Tryptophan] + result == Ok([Methionine, Phenylalanine, Tryptophan]) # Translation stops if STOP codon at beginning of sequence expect rna = "UAGUGG" result = rna |> to_protein - result == Ok [] + result == Ok([]) # Translation stops if STOP codon at end of two-codon sequence expect rna = "UGGUAG" result = rna |> to_protein - result == Ok [Tryptophan] + result == Ok([Tryptophan]) # Translation stops if STOP codon at end of three-codon sequence expect rna = "AUGUUUUAA" result = rna |> to_protein - result == Ok [Methionine, Phenylalanine] + result == Ok([Methionine, Phenylalanine]) # Translation stops if STOP codon in middle of three-codon sequence expect rna = "UGGUAGUGG" result = rna |> to_protein - result == Ok [Tryptophan] + result == Ok([Tryptophan]) # Translation stops if STOP codon in middle of six-codon sequence expect rna = "UGGUGUUAUUAAUGGUUU" result = rna |> to_protein - result == Ok [Tryptophan, Cysteine, Tyrosine] + result == Ok([Tryptophan, Cysteine, Tyrosine]) # Sequence of two non-STOP codons does not translate to a STOP codon expect rna = "AUGAUG" result = rna |> to_protein - result == Ok [Methionine, Methionine] + result == Ok([Methionine, Methionine]) # Unknown amino acids, not part of a codon, can't translate expect @@ -190,5 +190,5 @@ expect expect rna = "UUCUUCUAAUGGU" result = rna |> to_protein - result == Ok [Phenylalanine, Phenylalanine] + result == Ok([Phenylalanine, Phenylalanine]) diff --git a/exercises/practice/proverb/.meta/template.j2 b/exercises/practice/proverb/.meta/template.j2 index 3e054cec..5c274011 100644 --- a/exercises/practice/proverb/.meta/template.j2 +++ b/exercises/practice/proverb/.meta/template.j2 @@ -7,7 +7,7 @@ import {{ exercise | to_pascal }} exposing [{{ cases[0]["property"] | to_snake } {% for case in cases -%} # {{ case["description"] }} expect - result = {{ case["property"] | to_snake }} {{ case["input"]["strings"] | to_roc }} + result = {{ case["property"] | to_snake }}({{ case["input"]["strings"] | to_roc }}) expected = {{ case["expected"] | to_roc_multiline_string | indent(8) }} result == expected diff --git a/exercises/practice/proverb/proverb-test.roc b/exercises/practice/proverb/proverb-test.roc index 13619ad8..7e025b3e 100644 --- a/exercises/practice/proverb/proverb-test.roc +++ b/exercises/practice/proverb/proverb-test.roc @@ -8,25 +8,25 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line! "" + Stdout.line!("") import Proverb exposing [recite] # zero pieces expect - result = recite [] + result = recite([]) expected = "" result == expected # one piece expect - result = recite ["nail"] + result = recite(["nail"]) expected = "And all for the want of a nail." result == expected # two pieces expect - result = recite ["nail", "shoe"] + result = recite(["nail", "shoe"]) expected = """ For want of a nail the shoe was lost. @@ -36,7 +36,7 @@ expect # three pieces expect - result = recite ["nail", "shoe", "horse"] + result = recite(["nail", "shoe", "horse"]) expected = """ For want of a nail the shoe was lost. @@ -47,7 +47,7 @@ expect # full proverb expect - result = recite ["nail", "shoe", "horse", "rider", "message", "battle", "kingdom"] + result = recite(["nail", "shoe", "horse", "rider", "message", "battle", "kingdom"]) expected = """ For want of a nail the shoe was lost. @@ -62,7 +62,7 @@ expect # four pieces modernized expect - result = recite ["pin", "gun", "soldier", "battle"] + result = recite(["pin", "gun", "soldier", "battle"]) expected = """ For want of a pin the gun was lost. diff --git a/exercises/practice/pythagorean-triplet/.meta/template.j2 b/exercises/practice/pythagorean-triplet/.meta/template.j2 index c7359479..8f4bf448 100644 --- a/exercises/practice/pythagorean-triplet/.meta/template.j2 +++ b/exercises/practice/pythagorean-triplet/.meta/template.j2 @@ -7,7 +7,7 @@ import {{ exercise | to_pascal }} exposing [{{ cases[0]["property"] | to_snake } {% for case in cases -%} # {{ case["description"] }} expect - result = {{ case["property"] | to_snake }} {{ case["input"]["n"] }} + result = {{ case["property"] | to_snake }}({{ case["input"]["n"] }}) expected = Set.from_list [{%- for triplet in case["expected"] %} ({{ triplet[0] }}, {{ triplet[1] }}, {{ triplet[2] }}), {%- endfor %}] diff --git a/exercises/practice/pythagorean-triplet/pythagorean-triplet-test.roc b/exercises/practice/pythagorean-triplet/pythagorean-triplet-test.roc index 4efbb485..c730453f 100644 --- a/exercises/practice/pythagorean-triplet/pythagorean-triplet-test.roc +++ b/exercises/practice/pythagorean-triplet/pythagorean-triplet-test.roc @@ -8,13 +8,13 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line! "" + Stdout.line!("") import PythagoreanTriplet exposing [triplets_with_sum] # triplets whose sum is 12 expect - result = triplets_with_sum 12 + result = triplets_with_sum(12) expected = Set.from_list [ (3, 4, 5), ] @@ -22,7 +22,7 @@ expect # triplets whose sum is 108 expect - result = triplets_with_sum 108 + result = triplets_with_sum(108) expected = Set.from_list [ (27, 36, 45), ] @@ -30,7 +30,7 @@ expect # triplets whose sum is 1000 expect - result = triplets_with_sum 1000 + result = triplets_with_sum(1000) expected = Set.from_list [ (200, 375, 425), ] @@ -38,13 +38,13 @@ expect # no matching triplets for 1001 expect - result = triplets_with_sum 1001 + result = triplets_with_sum(1001) expected = Set.from_list [] result == expected # returns all matching triplets expect - result = triplets_with_sum 90 + result = triplets_with_sum(90) expected = Set.from_list [ (9, 40, 41), (15, 36, 39), @@ -53,7 +53,7 @@ expect # several matching triplets expect - result = triplets_with_sum 840 + result = triplets_with_sum(840) expected = Set.from_list [ (40, 399, 401), (56, 390, 394), @@ -68,7 +68,7 @@ expect # triplets for large number expect - result = triplets_with_sum 30000 + result = triplets_with_sum(30000) expected = Set.from_list [ (1200, 14375, 14425), (1875, 14000, 14125), diff --git a/exercises/practice/queen-attack/.meta/template.j2 b/exercises/practice/queen-attack/.meta/template.j2 index 04d53c77..96f19398 100644 --- a/exercises/practice/queen-attack/.meta/template.j2 +++ b/exercises/practice/queen-attack/.meta/template.j2 @@ -14,16 +14,16 @@ import {{ exercise | to_pascal }} exposing [create, rank, file, queen_can_attack {%- if case["property"] == "create" %} {%- if case["expected"] == 0 %} expect - maybeSquare = create "{{ plugins.to_square(case["input"]["queen"]) }}" - result = maybeSquare |> Result.try \square -> - Ok (rank square) - result == Ok {{ plugins.to_rank(case["input"]["queen"]["position"]["row"]) }} + maybeSquare = create("{{ plugins.to_square(case["input"]["queen"]) }}") + result = maybeSquare |> Result.try |square| + Ok((rank square)) + result == Ok({{ plugins.to_rank(case["input"]["queen"]["position"]["row"]) }}) expect maybeSquare = create "{{ plugins.to_square(case["input"]["queen"]) }}" - result = maybeSquare |> Result.try \square -> - Ok (file square) - result == Ok '{{ plugins.to_file(case["input"]["queen"]["position"]["column"]) }}' + result = maybeSquare |> Result.try |square| + Ok(file square) + result == Ok('{{ plugins.to_file(case["input"]["queen"]["position"]["column"]) }}') {%- else %} expect result = create "{{ plugins.to_square(case["input"]["queen"]) }}" @@ -31,10 +31,10 @@ expect {%- endif %} {%- elif case["property"] == "canAttack" %} expect - maybeSquare1 = create "{{ plugins.to_square(case["input"]["white_queen"]) }}" - maybeSquare2 = create "{{ plugins.to_square(case["input"]["black_queen"]) }}" + maybeSquare1 = create("{{ plugins.to_square(case["input"]["white_queen"]) }}") + maybeSquare2 = create("{{ plugins.to_square(case["input"]["black_queen"]) }}") result = when (maybeSquare1, maybeSquare2) is - (Ok square1, Ok square2) -> + (Ok(square1), Ok(square2)) -> square1 |> queen_can_attack square2 _ -> crash "Unreachable: {{ plugins.to_square(case["input"]["white_queen"]) }} and {{ plugins.to_square(case["input"]["black_queen"]) }} are both valid squares" result == {{ case["expected"] | to_roc }} diff --git a/exercises/practice/queen-attack/queen-attack-test.roc b/exercises/practice/queen-attack/queen-attack-test.roc index dfe18b29..21563511 100644 --- a/exercises/practice/queen-attack/queen-attack-test.roc +++ b/exercises/practice/queen-attack/queen-attack-test.roc @@ -8,7 +8,7 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line! "" + Stdout.line!("") import QueenAttack exposing [create, rank, file, queen_can_attack] @@ -18,20 +18,20 @@ import QueenAttack exposing [create, rank, file, queen_can_attack] # queen with a valid position expect - maybeSquare = create "C6" + maybeSquare = create("C6") result = maybeSquare |> Result.try |square| - Ok (rank square) - result == Ok 6 + Ok(rank square) + result == Ok(6) expect maybeSquare = create "C6" result = maybeSquare |> Result.try |square| - Ok (file square) - result == Ok 'C' + Ok(file square) + result == Ok('C') # queen must have row on board expect @@ -49,11 +49,11 @@ expect # cannot attack expect - maybeSquare1 = create "E6" - maybeSquare2 = create "G2" + maybeSquare1 = create("E6") + maybeSquare2 = create("G2") result = when (maybeSquare1, maybeSquare2) is - (Ok square1, Ok square2) -> + (Ok(square1), Ok(square2)) -> square1 |> queen_can_attack square2 _ -> crash "Unreachable: E6 and G2 are both valid squares" @@ -61,11 +61,11 @@ expect # can attack on same row expect - maybeSquare1 = create "E6" - maybeSquare2 = create "G6" + maybeSquare1 = create("E6") + maybeSquare2 = create("G6") result = when (maybeSquare1, maybeSquare2) is - (Ok square1, Ok square2) -> + (Ok(square1), Ok(square2)) -> square1 |> queen_can_attack square2 _ -> crash "Unreachable: E6 and G6 are both valid squares" @@ -73,11 +73,11 @@ expect # can attack on same column expect - maybeSquare1 = create "F4" - maybeSquare2 = create "F6" + maybeSquare1 = create("F4") + maybeSquare2 = create("F6") result = when (maybeSquare1, maybeSquare2) is - (Ok square1, Ok square2) -> + (Ok(square1), Ok(square2)) -> square1 |> queen_can_attack square2 _ -> crash "Unreachable: F4 and F6 are both valid squares" @@ -85,11 +85,11 @@ expect # can attack on first diagonal expect - maybeSquare1 = create "C6" - maybeSquare2 = create "E8" + maybeSquare1 = create("C6") + maybeSquare2 = create("E8") result = when (maybeSquare1, maybeSquare2) is - (Ok square1, Ok square2) -> + (Ok(square1), Ok(square2)) -> square1 |> queen_can_attack square2 _ -> crash "Unreachable: C6 and E8 are both valid squares" @@ -97,11 +97,11 @@ expect # can attack on second diagonal expect - maybeSquare1 = create "C6" - maybeSquare2 = create "B5" + maybeSquare1 = create("C6") + maybeSquare2 = create("B5") result = when (maybeSquare1, maybeSquare2) is - (Ok square1, Ok square2) -> + (Ok(square1), Ok(square2)) -> square1 |> queen_can_attack square2 _ -> crash "Unreachable: C6 and B5 are both valid squares" @@ -109,11 +109,11 @@ expect # can attack on third diagonal expect - maybeSquare1 = create "C6" - maybeSquare2 = create "B7" + maybeSquare1 = create("C6") + maybeSquare2 = create("B7") result = when (maybeSquare1, maybeSquare2) is - (Ok square1, Ok square2) -> + (Ok(square1), Ok(square2)) -> square1 |> queen_can_attack square2 _ -> crash "Unreachable: C6 and B7 are both valid squares" @@ -121,11 +121,11 @@ expect # can attack on fourth diagonal expect - maybeSquare1 = create "H7" - maybeSquare2 = create "G8" + maybeSquare1 = create("H7") + maybeSquare2 = create("G8") result = when (maybeSquare1, maybeSquare2) is - (Ok square1, Ok square2) -> + (Ok(square1), Ok(square2)) -> square1 |> queen_can_attack square2 _ -> crash "Unreachable: H7 and G8 are both valid squares" @@ -133,11 +133,11 @@ expect # cannot attack if falling diagonals are only the same when reflected across the longest falling diagonal expect - maybeSquare1 = create "B4" - maybeSquare2 = create "F6" + maybeSquare1 = create("B4") + maybeSquare2 = create("F6") result = when (maybeSquare1, maybeSquare2) is - (Ok square1, Ok square2) -> + (Ok(square1), Ok(square2)) -> square1 |> queen_can_attack square2 _ -> crash "Unreachable: B4 and F6 are both valid squares" diff --git a/exercises/practice/rail-fence-cipher/.meta/template.j2 b/exercises/practice/rail-fence-cipher/.meta/template.j2 index 8507ae7c..ca87fee9 100644 --- a/exercises/practice/rail-fence-cipher/.meta/template.j2 +++ b/exercises/practice/rail-fence-cipher/.meta/template.j2 @@ -13,7 +13,7 @@ import {{ exercise | to_pascal }} exposing [encode, decode] # {{ case["description"] }} expect message = {{ case["input"]["msg"] | to_roc }} - result = message |> {{ case["property"] | to_snake }} {{ case["input"]["rails"] | to_roc }} + result = message |> {{ case["property"] | to_snake }}({{ case["input"]["rails"] | to_roc }}) expected = Ok {{ case["expected"] | to_roc }} result == expected diff --git a/exercises/practice/rail-fence-cipher/rail-fence-cipher-test.roc b/exercises/practice/rail-fence-cipher/rail-fence-cipher-test.roc index 397248ab..fa424793 100644 --- a/exercises/practice/rail-fence-cipher/rail-fence-cipher-test.roc +++ b/exercises/practice/rail-fence-cipher/rail-fence-cipher-test.roc @@ -8,7 +8,7 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line! "" + Stdout.line!("") import RailFenceCipher exposing [encode, decode] @@ -19,21 +19,21 @@ import RailFenceCipher exposing [encode, decode] # encode with two rails expect message = "XOXOXOXOXOXOXOXOXO" - result = message |> encode 2 + result = message |> encode(2) expected = Ok "XXXXXXXXXOOOOOOOOO" result == expected # encode with three rails expect message = "WEAREDISCOVEREDFLEEATONCE" - result = message |> encode 3 + result = message |> encode(3) expected = Ok "WECRLTEERDSOEEFEAOCAIVDEN" result == expected # encode with ending in the middle expect message = "EXERCISES" - result = message |> encode 4 + result = message |> encode(4) expected = Ok "ESXIEECSR" result == expected @@ -44,21 +44,21 @@ expect # decode with three rails expect message = "TEITELHDVLSNHDTISEIIEA" - result = message |> decode 3 + result = message |> decode(3) expected = Ok "THEDEVILISINTHEDETAILS" result == expected # decode with five rails expect message = "EIEXMSMESAORIWSCE" - result = message |> decode 5 + result = message |> decode(5) expected = Ok "EXERCISMISAWESOME" result == expected # decode with six rails expect message = "133714114238148966225439541018335470986172518171757571896261" - result = message |> decode 6 + result = message |> decode(6) expected = Ok "112358132134558914423337761098715972584418167651094617711286" result == expected diff --git a/exercises/practice/raindrops/.meta/template.j2 b/exercises/practice/raindrops/.meta/template.j2 index 60457cf6..e8b3010e 100644 --- a/exercises/practice/raindrops/.meta/template.j2 +++ b/exercises/practice/raindrops/.meta/template.j2 @@ -7,7 +7,7 @@ import {{ exercise | to_pascal }} exposing [convert] {% for case in cases -%} # {{ case["description"] }} expect - result = {{ case["property"] | to_snake }} {{ case["input"]["number"] }} + result = {{ case["property"] | to_snake }}({{ case["input"]["number"] }}) result == {{ case["expected"] | to_roc }} {% endfor %} diff --git a/exercises/practice/raindrops/raindrops-test.roc b/exercises/practice/raindrops/raindrops-test.roc index bc5c2d6c..c68ab387 100644 --- a/exercises/practice/raindrops/raindrops-test.roc +++ b/exercises/practice/raindrops/raindrops-test.roc @@ -8,97 +8,97 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line! "" + Stdout.line!("") import Raindrops exposing [convert] # the sound for 1 is 1 expect - result = convert 1 + result = convert(1) result == "1" # the sound for 3 is Pling expect - result = convert 3 + result = convert(3) result == "Pling" # the sound for 5 is Plang expect - result = convert 5 + result = convert(5) result == "Plang" # the sound for 7 is Plong expect - result = convert 7 + result = convert(7) result == "Plong" # the sound for 6 is Pling as it has a factor 3 expect - result = convert 6 + result = convert(6) result == "Pling" # 2 to the power 3 does not make a raindrop sound as 3 is the exponent not the base expect - result = convert 8 + result = convert(8) result == "8" # the sound for 9 is Pling as it has a factor 3 expect - result = convert 9 + result = convert(9) result == "Pling" # the sound for 10 is Plang as it has a factor 5 expect - result = convert 10 + result = convert(10) result == "Plang" # the sound for 14 is Plong as it has a factor of 7 expect - result = convert 14 + result = convert(14) result == "Plong" # the sound for 15 is PlingPlang as it has factors 3 and 5 expect - result = convert 15 + result = convert(15) result == "PlingPlang" # the sound for 21 is PlingPlong as it has factors 3 and 7 expect - result = convert 21 + result = convert(21) result == "PlingPlong" # the sound for 25 is Plang as it has a factor 5 expect - result = convert 25 + result = convert(25) result == "Plang" # the sound for 27 is Pling as it has a factor 3 expect - result = convert 27 + result = convert(27) result == "Pling" # the sound for 35 is PlangPlong as it has factors 5 and 7 expect - result = convert 35 + result = convert(35) result == "PlangPlong" # the sound for 49 is Plong as it has a factor 7 expect - result = convert 49 + result = convert(49) result == "Plong" # the sound for 52 is 52 expect - result = convert 52 + result = convert(52) result == "52" # the sound for 105 is PlingPlangPlong as it has factors 3, 5 and 7 expect - result = convert 105 + result = convert(105) result == "PlingPlangPlong" # the sound for 3125 is Plang as it has a factor 5 expect - result = convert 3125 + result = convert(3125) result == "Plang" diff --git a/exercises/practice/rational-numbers/.meta/template.j2 b/exercises/practice/rational-numbers/.meta/template.j2 index ede1f929..bebc0bad 100644 --- a/exercises/practice/rational-numbers/.meta/template.j2 +++ b/exercises/practice/rational-numbers/.meta/template.j2 @@ -20,12 +20,12 @@ import {{ exercise | to_pascal }} exposing [add, sub, mul, div, abs, exp, exp_re # {{ case["description"] }} expect {%- if "r1" in case["input"] %} - result = {{ plugins.to_roc_rational(case["input"]["r1"]) }} |> {{ property_map[case["property"]] | to_snake }} ({{ plugins.to_roc_rational(case["input"]["r2"]) }}) + result = {{ plugins.to_roc_rational(case["input"]["r1"]) }} |> {{ property_map[case["property"]] | to_snake }}(({{ plugins.to_roc_rational(case["input"]["r2"]) }})) {%- elif "r" in case["input"] %} {%- if "x" in case["input"] %} - result = {{ case["input"]["x"] | to_roc }} |> {{ property_map[case["property"]] | to_snake }} ({{ plugins.to_roc_rational(case["input"]["r"]) }}) + result = {{ case["input"]["x"] | to_roc }} |> {{ property_map[case["property"]] | to_snake }}(({{ plugins.to_roc_rational(case["input"]["r"]) }})) {%- elif "n" in case["input"] %} - result = {{ plugins.to_roc_rational(case["input"]["r"]) }} |> {{ property_map[case["property"]] | to_snake }} {{ case["input"]["n"] | to_roc }} + result = {{ plugins.to_roc_rational(case["input"]["r"]) }} |> {{ property_map[case["property"]] | to_snake }}({{ case["input"]["n"] | to_roc }}) {%- else %} result = {{ plugins.to_roc_rational(case["input"]["r"]) }} |> {{ property_map[case["property"]] | to_snake }} {%- endif %} diff --git a/exercises/practice/rational-numbers/rational-numbers-test.roc b/exercises/practice/rational-numbers/rational-numbers-test.roc index c3b8571d..2ce6a548 100644 --- a/exercises/practice/rational-numbers/rational-numbers-test.roc +++ b/exercises/practice/rational-numbers/rational-numbers-test.roc @@ -8,7 +8,7 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line! "" + Stdout.line!("") import RationalNumbers exposing [add, sub, mul, div, abs, exp, exp_real, reduce] @@ -18,92 +18,92 @@ import RationalNumbers exposing [add, sub, mul, div, abs, exp, exp_real, reduce] # Add two positive rational numbers expect - result = Rational 1 2 |> add (Rational 2 3) + result = Rational 1 2 |> add(Rational 2 3) result == Rational 7 6 # Add a positive rational number and a negative rational number expect - result = Rational 1 2 |> add (Rational -2 3) + result = Rational 1 2 |> add(Rational -2 3) result == Rational -1 6 # Add two negative rational numbers expect - result = Rational -1 2 |> add (Rational -2 3) + result = Rational -1 2 |> add(Rational -2 3) result == Rational -7 6 # Add a rational number to its additive inverse expect - result = Rational 1 2 |> add (Rational -1 2) + result = Rational 1 2 |> add(Rational -1 2) result == Rational 0 1 # Subtract two positive rational numbers expect - result = Rational 1 2 |> sub (Rational 2 3) + result = Rational 1 2 |> sub(Rational 2 3) result == Rational -1 6 # Subtract a positive rational number and a negative rational number expect - result = Rational 1 2 |> sub (Rational -2 3) + result = Rational 1 2 |> sub(Rational -2 3) result == Rational 7 6 # Subtract two negative rational numbers expect - result = Rational -1 2 |> sub (Rational -2 3) + result = Rational -1 2 |> sub(Rational -2 3) result == Rational 1 6 # Subtract a rational number from itself expect - result = Rational 1 2 |> sub (Rational 1 2) + result = Rational 1 2 |> sub(Rational 1 2) result == Rational 0 1 # Multiply two positive rational numbers expect - result = Rational 1 2 |> mul (Rational 2 3) + result = Rational 1 2 |> mul(Rational 2 3) result == Rational 1 3 # Multiply a negative rational number by a positive rational number expect - result = Rational -1 2 |> mul (Rational 2 3) + result = Rational -1 2 |> mul(Rational 2 3) result == Rational -1 3 # Multiply two negative rational numbers expect - result = Rational -1 2 |> mul (Rational -2 3) + result = Rational -1 2 |> mul(Rational -2 3) result == Rational 1 3 # Multiply a rational number by its reciprocal expect - result = Rational 1 2 |> mul (Rational 2 1) + result = Rational 1 2 |> mul(Rational 2 1) result == Rational 1 1 # Multiply a rational number by 1 expect - result = Rational 1 2 |> mul (Rational 1 1) + result = Rational 1 2 |> mul(Rational 1 1) result == Rational 1 2 # Multiply a rational number by 0 expect - result = Rational 1 2 |> mul (Rational 0 1) + result = Rational 1 2 |> mul(Rational 0 1) result == Rational 0 1 # Divide two positive rational numbers expect - result = Rational 1 2 |> div (Rational 2 3) + result = Rational 1 2 |> div(Rational 2 3) result == Rational 3 4 # Divide a positive rational number by a negative rational number expect - result = Rational 1 2 |> div (Rational -2 3) + result = Rational 1 2 |> div(Rational -2 3) result == Rational -3 4 # Divide two negative rational numbers expect - result = Rational -1 2 |> div (Rational -2 3) + result = Rational -1 2 |> div(Rational -2 3) result == Rational 3 4 # Divide a rational number by 1 expect - result = Rational 1 2 |> div (Rational 1 1) + result = Rational 1 2 |> div(Rational 1 1) result == Rational 1 2 ## @@ -146,47 +146,47 @@ expect # Raise a positive rational number to a positive integer power expect - result = Rational 1 2 |> exp 3 + result = Rational 1 2 |> exp(3) result == Rational 1 8 # Raise a negative rational number to a positive integer power expect - result = Rational -1 2 |> exp 3 + result = Rational -1 2 |> exp(3) result == Rational -1 8 # Raise a positive rational number to a negative integer power expect - result = Rational 3 5 |> exp -2 + result = Rational 3 5 |> exp(-2) result == Rational 25 9 # Raise a negative rational number to an even negative integer power expect - result = Rational -3 5 |> exp -2 + result = Rational -3 5 |> exp(-2) result == Rational 25 9 # Raise a negative rational number to an odd negative integer power expect - result = Rational -3 5 |> exp -3 + result = Rational -3 5 |> exp(-3) result == Rational -125 27 # Raise zero to an integer power expect - result = Rational 0 1 |> exp 5 + result = Rational 0 1 |> exp(5) result == Rational 0 1 # Raise one to an integer power expect - result = Rational 1 1 |> exp 4 + result = Rational 1 1 |> exp(4) result == Rational 1 1 # Raise a positive rational number to the power of zero expect - result = Rational 1 2 |> exp 0 + result = Rational 1 2 |> exp(0) result == Rational 1 1 # Raise a negative rational number to the power of zero expect - result = Rational -1 2 |> exp 0 + result = Rational -1 2 |> exp(0) result == Rational 1 1 ## @@ -195,17 +195,17 @@ expect # Raise a real number to a positive rational number expect - result = 8 |> exp_real (Rational 4 3) + result = 8 |> exp_real(Rational 4 3) result |> Num.is_approx_eq 16.0f64 {} # Raise a real number to a negative rational number expect - result = 9 |> exp_real (Rational -1 2) + result = 9 |> exp_real(Rational -1 2) result |> Num.is_approx_eq 0.3333333333333333f64 {} # Raise a real number to a zero rational number expect - result = 2 |> exp_real (Rational 0 1) + result = 2 |> exp_real(Rational 0 1) result |> Num.is_approx_eq 1.0f64 {} ## diff --git a/exercises/practice/rectangles/.meta/template.j2 b/exercises/practice/rectangles/.meta/template.j2 index 20dd6b49..53918371 100644 --- a/exercises/practice/rectangles/.meta/template.j2 +++ b/exercises/practice/rectangles/.meta/template.j2 @@ -7,7 +7,7 @@ import {{ exercise | to_pascal }} exposing [{{ cases[0]["property"] | to_snake } {% for case in cases -%} # {{ case["description"] }} expect - result = {{ case["property"] | to_snake }} {{ case["input"]["strings"] | to_roc_multiline_string | indent(8) }} + result = {{ case["property"] | to_snake }}({{ case["input"]["strings"] | to_roc_multiline_string | indent(8) }}) result == {{ case["expected"] | to_roc }} {% endfor %} diff --git a/exercises/practice/rectangles/rectangles-test.roc b/exercises/practice/rectangles/rectangles-test.roc index 22c7a3de..4071ad2d 100644 --- a/exercises/practice/rectangles/rectangles-test.roc +++ b/exercises/practice/rectangles/rectangles-test.roc @@ -8,126 +8,135 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line! "" + Stdout.line!("") import Rectangles exposing [rectangles] # no rows expect - result = rectangles "" + result = rectangles("") result == 0 # no columns expect - result = rectangles "" + result = rectangles("") result == 0 # no rectangles expect - result = rectangles " " + result = rectangles(" ") result == 0 # one rectangle expect - result = rectangles + result = rectangles( """ +-+ | | +-+ - """ + """, + ) result == 1 # two rectangles without shared parts expect - result = rectangles + result = rectangles( """ +-+ | | +-+-+ | | +-+ - """ + """, + ) result == 2 # five rectangles with shared parts expect - result = rectangles + result = rectangles( """ +-+ | | +-+-+ | | | +-+-+ - """ + """, + ) result == 5 # rectangle of height 1 is counted expect - result = rectangles + result = rectangles( """ +--+ +--+ - """ + """, + ) result == 1 # rectangle of width 1 is counted expect - result = rectangles + result = rectangles( """ ++ || ++ - """ + """, + ) result == 1 # 1x1 square is counted expect - result = rectangles + result = rectangles( """ ++ ++ - """ + """, + ) result == 1 # only complete rectangles are counted expect - result = rectangles + result = rectangles( """ +-+ | +-+-+ | | - +-+-+ - """ + """, + ) result == 1 # rectangles can be of different sizes expect - result = rectangles + result = rectangles( """ +------+----+ | | | +---+--+ | | | | +---+-------+ - """ + """, + ) result == 3 # corner is required for a rectangle to be complete expect - result = rectangles + result = rectangles( """ +------+----+ | | | +------+ | | | | +---+-------+ - """ + """, + ) result == 2 # large input with many rectangles expect - result = rectangles + result = rectangles( """ +---+--+----+ | +--+----+ @@ -137,12 +146,13 @@ expect +---+--+--+-+ +------+ | | +-+ - """ + """, + ) result == 60 # rectangles must have four sides expect - result = rectangles + result = rectangles( """ +-+ +-+ | | | | @@ -151,6 +161,7 @@ expect +-+-+-+ | | | | +-+ +-+ - """ + """, + ) result == 5 diff --git a/exercises/practice/resistor-color-duo/.meta/template.j2 b/exercises/practice/resistor-color-duo/.meta/template.j2 index cd0e6e00..b548a358 100644 --- a/exercises/practice/resistor-color-duo/.meta/template.j2 +++ b/exercises/practice/resistor-color-duo/.meta/template.j2 @@ -7,7 +7,7 @@ import {{ exercise | to_pascal }} exposing [value] {% for case in cases -%} # {{ case["description"] }} expect - result = {{ case["property"] | to_snake }} {{ case["input"]["colors"][0] | to_pascal }} {{ case["input"]["colors"][1] | to_pascal }} + result = {{ case["property"] | to_snake }}({{ case["input"]["colors"][0] | to_pascal }}, {{ case["input"]["colors"][1] | to_pascal }}) result == {{ case["expected"] }} {% endfor %} diff --git a/exercises/practice/resistor-color-duo/resistor-color-duo-test.roc b/exercises/practice/resistor-color-duo/resistor-color-duo-test.roc index 8402f1b6..b8bfe65c 100644 --- a/exercises/practice/resistor-color-duo/resistor-color-duo-test.roc +++ b/exercises/practice/resistor-color-duo/resistor-color-duo-test.roc @@ -8,37 +8,37 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line! "" + Stdout.line!("") import ResistorColorDuo exposing [value] # Brown and black expect - result = value Brown Black + result = value(Brown, Black) result == 10 # Blue and grey expect - result = value Blue Grey + result = value(Blue, Grey) result == 68 # Yellow and violet expect - result = value Yellow Violet + result = value(Yellow, Violet) result == 47 # White and red expect - result = value White Red + result = value(White, Red) result == 92 # Orange and orange expect - result = value Orange Orange + result = value(Orange, Orange) result == 33 # Black and brown, one-digit expect - result = value Black Brown + result = value(Black, Brown) result == 1 diff --git a/exercises/practice/resistor-color/.meta/template.j2 b/exercises/practice/resistor-color/.meta/template.j2 index f6726327..2717e885 100644 --- a/exercises/practice/resistor-color/.meta/template.j2 +++ b/exercises/practice/resistor-color/.meta/template.j2 @@ -20,7 +20,7 @@ expect {% for subcase in case["cases"] -%} # {{ subcase["description"] }} expect - result = {{ subcase["property"] | to_snake }} {{ subcase["input"]["color"] | to_roc }} + result = {{ subcase["property"] | to_snake }}({{ subcase["input"]["color"] | to_roc }}) result == Ok {{ subcase["expected"] }} {% endfor %} diff --git a/exercises/practice/resistor-color/resistor-color-test.roc b/exercises/practice/resistor-color/resistor-color-test.roc index 255774ca..cbe606a8 100644 --- a/exercises/practice/resistor-color/resistor-color-test.roc +++ b/exercises/practice/resistor-color/resistor-color-test.roc @@ -8,7 +8,7 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line! "" + Stdout.line!("") import ResistorColor exposing [color_code, colors] @@ -18,17 +18,17 @@ import ResistorColor exposing [color_code, colors] # Black expect - result = color_code "black" + result = color_code("black") result == Ok 0 # White expect - result = color_code "white" + result = color_code("white") result == Ok 9 # Orange expect - result = color_code "orange" + result = color_code("orange") result == Ok 3 ## diff --git a/exercises/practice/rest-api/.meta/template.j2 b/exercises/practice/rest-api/.meta/template.j2 index d21b167c..6bc17fc3 100644 --- a/exercises/practice/rest-api/.meta/template.j2 +++ b/exercises/practice/rest-api/.meta/template.j2 @@ -7,8 +7,8 @@ import {{ exercise | to_pascal }} exposing [get, post] standardizeResult = |result| result |> Result.try |string| string - |> Str.replace_each ".0," "," - |> Str.replace_each ".0}" "}" + |> Str.replace_each(".0,", ",") + |> Str.replace_each(".0}", "}") |> Str.to_utf8 |> List.drop_if |c| [' ', '\t', '\n'] |> List.contains c |> Str.from_utf8 @@ -41,13 +41,13 @@ expect {%- endfor %} ] } - result = database |> {{ case["property"] | to_snake }} { + result = database |> {{ case["property"] | to_snake }}({ url: {{ case["input"]["url"] | to_roc }}, {%- if case["input"].get("payload", {}) != {} %} payload: {{ case["input"]["payload"] | tojson | to_roc }} {%- endif %} - } |> standardizeResult - expected = Ok {{ case["expected"] | tojson | replace(".0,", ",") | replace(".0}", "}") | replace(" ", "") | to_roc }} + }) |> standardizeResult + expected = Ok({{ case["expected"] | tojson | replace(".0,", ",") | replace(".0}", "}") | replace(" ", "") | to_roc }}) result == expected {% endfor %} diff --git a/exercises/practice/rest-api/rest-api-test.roc b/exercises/practice/rest-api/rest-api-test.roc index 04341533..ac38a88d 100644 --- a/exercises/practice/rest-api/rest-api-test.roc +++ b/exercises/practice/rest-api/rest-api-test.roc @@ -9,7 +9,7 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line! "" + Stdout.line!("") import RestApi exposing [get, post] @@ -17,8 +17,8 @@ standardizeResult = |result| result |> Result.try |string| string - |> Str.replace_each ".0," "," - |> Str.replace_each ".0}" "}" + |> Str.replace_each(".0,", ",") + |> Str.replace_each(".0}", "}") |> Str.to_utf8 |> List.drop_if |c| [' ', '\t', '\n'] |> List.contains c |> Str.from_utf8 @@ -35,11 +35,13 @@ expect } result = database - |> get { - url: "/users", - } + |> get( + { + url: "/users", + }, + ) |> standardizeResult - expected = Ok "{\"users\":[]}" + expected = Ok("{\"users\":[]}") result == expected # add user @@ -50,12 +52,14 @@ expect } result = database - |> post { - url: "/add", - payload: "{\"user\": \"Adam\"}", - } + |> post( + { + url: "/add", + payload: "{\"user\": \"Adam\"}", + }, + ) |> standardizeResult - expected = Ok "{\"balance\":0,\"name\":\"Adam\",\"owed_by\":{},\"owes\":{}}" + expected = Ok("{\"balance\":0,\"name\":\"Adam\",\"owed_by\":{},\"owes\":{}}") result == expected # get single user @@ -78,12 +82,14 @@ expect } result = database - |> get { - url: "/users", - payload: "{\"users\": [\"Bob\"]}", - } + |> get( + { + url: "/users", + payload: "{\"users\": [\"Bob\"]}", + }, + ) |> standardizeResult - expected = Ok "{\"users\":[{\"balance\":0,\"name\":\"Bob\",\"owed_by\":{},\"owes\":{}}]}" + expected = Ok("{\"users\":[{\"balance\":0,\"name\":\"Bob\",\"owed_by\":{},\"owes\":{}}]}") result == expected ## @@ -110,12 +116,14 @@ expect } result = database - |> post { - url: "/iou", - payload: "{\"amount\": 3.0, \"borrower\": \"Bob\", \"lender\": \"Adam\"}", - } + |> post( + { + url: "/iou", + payload: "{\"amount\": 3.0, \"borrower\": \"Bob\", \"lender\": \"Adam\"}", + }, + ) |> standardizeResult - expected = Ok "{\"users\":[{\"balance\":3,\"name\":\"Adam\",\"owed_by\":{\"Bob\":3},\"owes\":{}},{\"balance\":-3,\"name\":\"Bob\",\"owed_by\":{},\"owes\":{\"Adam\":3}}]}" + expected = Ok("{\"users\":[{\"balance\":3,\"name\":\"Adam\",\"owed_by\":{\"Bob\":3},\"owes\":{}},{\"balance\":-3,\"name\":\"Bob\",\"owed_by\":{},\"owes\":{\"Adam\":3}}]}") result == expected # borrower has negative balance @@ -148,12 +156,14 @@ expect } result = database - |> post { - url: "/iou", - payload: "{\"amount\": 3.0, \"borrower\": \"Bob\", \"lender\": \"Adam\"}", - } + |> post( + { + url: "/iou", + payload: "{\"amount\": 3.0, \"borrower\": \"Bob\", \"lender\": \"Adam\"}", + }, + ) |> standardizeResult - expected = Ok "{\"users\":[{\"balance\":3,\"name\":\"Adam\",\"owed_by\":{\"Bob\":3},\"owes\":{}},{\"balance\":-6,\"name\":\"Bob\",\"owed_by\":{},\"owes\":{\"Adam\":3,\"Chuck\":3}}]}" + expected = Ok("{\"users\":[{\"balance\":3,\"name\":\"Adam\",\"owed_by\":{\"Bob\":3},\"owes\":{}},{\"balance\":-6,\"name\":\"Bob\",\"owed_by\":{},\"owes\":{\"Adam\":3,\"Chuck\":3}}]}") result == expected # lender has negative balance @@ -186,12 +196,14 @@ expect } result = database - |> post { - url: "/iou", - payload: "{\"amount\": 3.0, \"borrower\": \"Adam\", \"lender\": \"Bob\"}", - } + |> post( + { + url: "/iou", + payload: "{\"amount\": 3.0, \"borrower\": \"Adam\", \"lender\": \"Bob\"}", + }, + ) |> standardizeResult - expected = Ok "{\"users\":[{\"balance\":-3,\"name\":\"Adam\",\"owed_by\":{},\"owes\":{\"Bob\":3}},{\"balance\":0,\"name\":\"Bob\",\"owed_by\":{\"Adam\":3},\"owes\":{\"Chuck\":3}}]}" + expected = Ok("{\"users\":[{\"balance\":-3,\"name\":\"Adam\",\"owed_by\":{},\"owes\":{\"Bob\":3}},{\"balance\":0,\"name\":\"Bob\",\"owed_by\":{\"Adam\":3},\"owes\":{\"Chuck\":3}}]}") result == expected # lender owes borrower @@ -218,12 +230,14 @@ expect } result = database - |> post { - url: "/iou", - payload: "{\"amount\": 2.0, \"borrower\": \"Bob\", \"lender\": \"Adam\"}", - } + |> post( + { + url: "/iou", + payload: "{\"amount\": 2.0, \"borrower\": \"Bob\", \"lender\": \"Adam\"}", + }, + ) |> standardizeResult - expected = Ok "{\"users\":[{\"balance\":-1,\"name\":\"Adam\",\"owed_by\":{},\"owes\":{\"Bob\":1}},{\"balance\":1,\"name\":\"Bob\",\"owed_by\":{\"Adam\":1},\"owes\":{}}]}" + expected = Ok("{\"users\":[{\"balance\":-1,\"name\":\"Adam\",\"owed_by\":{},\"owes\":{\"Bob\":1}},{\"balance\":1,\"name\":\"Bob\",\"owed_by\":{\"Adam\":1},\"owes\":{}}]}") result == expected # lender owes borrower less than new loan @@ -250,12 +264,14 @@ expect } result = database - |> post { - url: "/iou", - payload: "{\"amount\": 4.0, \"borrower\": \"Bob\", \"lender\": \"Adam\"}", - } + |> post( + { + url: "/iou", + payload: "{\"amount\": 4.0, \"borrower\": \"Bob\", \"lender\": \"Adam\"}", + }, + ) |> standardizeResult - expected = Ok "{\"users\":[{\"balance\":1,\"name\":\"Adam\",\"owed_by\":{\"Bob\":1},\"owes\":{}},{\"balance\":-1,\"name\":\"Bob\",\"owed_by\":{},\"owes\":{\"Adam\":1}}]}" + expected = Ok("{\"users\":[{\"balance\":1,\"name\":\"Adam\",\"owed_by\":{\"Bob\":1},\"owes\":{}},{\"balance\":-1,\"name\":\"Bob\",\"owed_by\":{},\"owes\":{\"Adam\":1}}]}") result == expected # lender owes borrower same as new loan @@ -282,11 +298,13 @@ expect } result = database - |> post { - url: "/iou", - payload: "{\"amount\": 3.0, \"borrower\": \"Bob\", \"lender\": \"Adam\"}", - } + |> post( + { + url: "/iou", + payload: "{\"amount\": 3.0, \"borrower\": \"Bob\", \"lender\": \"Adam\"}", + }, + ) |> standardizeResult - expected = Ok "{\"users\":[{\"balance\":0,\"name\":\"Adam\",\"owed_by\":{},\"owes\":{}},{\"balance\":0,\"name\":\"Bob\",\"owed_by\":{},\"owes\":{}}]}" + expected = Ok("{\"users\":[{\"balance\":0,\"name\":\"Adam\",\"owed_by\":{},\"owes\":{}},{\"balance\":0,\"name\":\"Bob\",\"owed_by\":{},\"owes\":{}}]}") result == expected diff --git a/exercises/practice/reverse-string/.meta/template.j2 b/exercises/practice/reverse-string/.meta/template.j2 index 946f8506..07e0a8df 100644 --- a/exercises/practice/reverse-string/.meta/template.j2 +++ b/exercises/practice/reverse-string/.meta/template.j2 @@ -7,7 +7,7 @@ import {{ exercise | to_pascal }} exposing [reverse] {% for case in cases -%} # {{ case["description"] }} expect - result = {{ case["property"] | to_snake }} {{ case["input"]["value"] | to_roc }} + result = {{ case["property"] | to_snake }}({{ case["input"]["value"] | to_roc }}) result == {{ case["expected"] | to_roc }} {% endfor %} diff --git a/exercises/practice/reverse-string/reverse-string-test.roc b/exercises/practice/reverse-string/reverse-string-test.roc index 170ea04e..8359486c 100644 --- a/exercises/practice/reverse-string/reverse-string-test.roc +++ b/exercises/practice/reverse-string/reverse-string-test.roc @@ -9,52 +9,52 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line! "" + Stdout.line!("") import ReverseString exposing [reverse] # an empty string expect - result = reverse "" + result = reverse("") result == "" # a word expect - result = reverse "robot" + result = reverse("robot") result == "tobor" # a capitalized word expect - result = reverse "Ramen" + result = reverse("Ramen") result == "nemaR" # a sentence with punctuation expect - result = reverse "I'm hungry!" + result = reverse("I'm hungry!") result == "!yrgnuh m'I" # a palindrome expect - result = reverse "racecar" + result = reverse("racecar") result == "racecar" # an even-sized word expect - result = reverse "drawer" + result = reverse("drawer") result == "reward" # wide characters expect - result = reverse "子猫" + result = reverse("子猫") result == "猫子" # grapheme cluster with pre-combined form expect - result = reverse "Würstchenstand" + result = reverse("Würstchenstand") result == "dnatsnehctsrüW" # grapheme clusters expect - result = reverse "ผู้เขียนโปรแกรม" + result = reverse("ผู้เขียนโปรแกรม") result == "มรกแรปโนยขีเผู้" diff --git a/exercises/practice/rna-transcription/.meta/template.j2 b/exercises/practice/rna-transcription/.meta/template.j2 index c8bcae59..f88481ec 100644 --- a/exercises/practice/rna-transcription/.meta/template.j2 +++ b/exercises/practice/rna-transcription/.meta/template.j2 @@ -7,7 +7,7 @@ import {{ exercise | to_pascal }} exposing [to_rna] {% for case in cases -%} # {{ case["description"] }} expect - result = {{ case["property"] | to_snake }} {{ case["input"]["dna"] | to_roc }} + result = {{ case["property"] | to_snake }}({{ case["input"]["dna"] | to_roc }}) result == {{ case["expected"] | to_roc }} {% endfor %} diff --git a/exercises/practice/rna-transcription/rna-transcription-test.roc b/exercises/practice/rna-transcription/rna-transcription-test.roc index 5f070dd5..b167a7fb 100644 --- a/exercises/practice/rna-transcription/rna-transcription-test.roc +++ b/exercises/practice/rna-transcription/rna-transcription-test.roc @@ -8,37 +8,37 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line! "" + Stdout.line!("") import RnaTranscription exposing [to_rna] # Empty RNA sequence expect - result = to_rna "" + result = to_rna("") result == "" # RNA complement of cytosine is guanine expect - result = to_rna "C" + result = to_rna("C") result == "G" # RNA complement of guanine is cytosine expect - result = to_rna "G" + result = to_rna("G") result == "C" # RNA complement of thymine is adenine expect - result = to_rna "T" + result = to_rna("T") result == "A" # RNA complement of adenine is uracil expect - result = to_rna "A" + result = to_rna("A") result == "U" # RNA complement expect - result = to_rna "ACGTGGTCTTAA" + result = to_rna("ACGTGGTCTTAA") result == "UGCACCAGAAUU" diff --git a/exercises/practice/robot-simulator/robot-simulator-test.roc b/exercises/practice/robot-simulator/robot-simulator-test.roc index 8b25c0e8..35235a16 100644 --- a/exercises/practice/robot-simulator/robot-simulator-test.roc +++ b/exercises/practice/robot-simulator/robot-simulator-test.roc @@ -8,7 +8,7 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line! "" + Stdout.line!("") import RobotSimulator exposing [create, move] diff --git a/exercises/practice/roman-numerals/.meta/template.j2 b/exercises/practice/roman-numerals/.meta/template.j2 index bc1c769e..1c850941 100644 --- a/exercises/practice/roman-numerals/.meta/template.j2 +++ b/exercises/practice/roman-numerals/.meta/template.j2 @@ -7,7 +7,7 @@ import {{ exercise | to_pascal }} exposing [{{ cases[0]["property"] | to_snake } {% for case in cases -%} # {{ case["description"] }} expect - result = {{ case["property"] | to_snake }} {{ case["input"]["number"] | to_roc }} + result = {{ case["property"] | to_snake }}({{ case["input"]["number"] | to_roc }}) result == Ok {{ case["expected"] | to_roc }} {% endfor %} diff --git a/exercises/practice/roman-numerals/roman-numerals-test.roc b/exercises/practice/roman-numerals/roman-numerals-test.roc index b48a5c50..8b5ebf73 100644 --- a/exercises/practice/roman-numerals/roman-numerals-test.roc +++ b/exercises/practice/roman-numerals/roman-numerals-test.roc @@ -8,142 +8,142 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line! "" + Stdout.line!("") import RomanNumerals exposing [roman] # 1 is I expect - result = roman 1 + result = roman(1) result == Ok "I" # 2 is II expect - result = roman 2 + result = roman(2) result == Ok "II" # 3 is III expect - result = roman 3 + result = roman(3) result == Ok "III" # 4 is IV expect - result = roman 4 + result = roman(4) result == Ok "IV" # 5 is V expect - result = roman 5 + result = roman(5) result == Ok "V" # 6 is VI expect - result = roman 6 + result = roman(6) result == Ok "VI" # 9 is IX expect - result = roman 9 + result = roman(9) result == Ok "IX" # 16 is XVI expect - result = roman 16 + result = roman(16) result == Ok "XVI" # 27 is XXVII expect - result = roman 27 + result = roman(27) result == Ok "XXVII" # 48 is XLVIII expect - result = roman 48 + result = roman(48) result == Ok "XLVIII" # 49 is XLIX expect - result = roman 49 + result = roman(49) result == Ok "XLIX" # 59 is LIX expect - result = roman 59 + result = roman(59) result == Ok "LIX" # 66 is LXVI expect - result = roman 66 + result = roman(66) result == Ok "LXVI" # 93 is XCIII expect - result = roman 93 + result = roman(93) result == Ok "XCIII" # 141 is CXLI expect - result = roman 141 + result = roman(141) result == Ok "CXLI" # 163 is CLXIII expect - result = roman 163 + result = roman(163) result == Ok "CLXIII" # 166 is CLXVI expect - result = roman 166 + result = roman(166) result == Ok "CLXVI" # 402 is CDII expect - result = roman 402 + result = roman(402) result == Ok "CDII" # 575 is DLXXV expect - result = roman 575 + result = roman(575) result == Ok "DLXXV" # 666 is DCLXVI expect - result = roman 666 + result = roman(666) result == Ok "DCLXVI" # 911 is CMXI expect - result = roman 911 + result = roman(911) result == Ok "CMXI" # 1024 is MXXIV expect - result = roman 1024 + result = roman(1024) result == Ok "MXXIV" # 1666 is MDCLXVI expect - result = roman 1666 + result = roman(1666) result == Ok "MDCLXVI" # 3000 is MMM expect - result = roman 3000 + result = roman(3000) result == Ok "MMM" # 3001 is MMMI expect - result = roman 3001 + result = roman(3001) result == Ok "MMMI" # 3888 is MMMDCCCLXXXVIII expect - result = roman 3888 + result = roman(3888) result == Ok "MMMDCCCLXXXVIII" # 3999 is MMMCMXCIX expect - result = roman 3999 + result = roman(3999) result == Ok "MMMCMXCIX" diff --git a/exercises/practice/rotational-cipher/.meta/template.j2 b/exercises/practice/rotational-cipher/.meta/template.j2 index 26a225db..6fb226c6 100644 --- a/exercises/practice/rotational-cipher/.meta/template.j2 +++ b/exercises/practice/rotational-cipher/.meta/template.j2 @@ -7,7 +7,7 @@ import {{ exercise | to_pascal }} exposing [rotate] {% for case in cases -%} # {{ case["description"] }} expect - result = {{ case["property"] | to_snake }} {{ case["input"]["text"] | to_roc }} {{ case["input"]["shiftKey"] }} + result = {{ case["property"] | to_snake }}({{ case["input"]["text"] | to_roc }}, {{ case["input"]["shiftKey"] }}) result == {{ case["expected"] | to_roc }} {% endfor %} diff --git a/exercises/practice/rotational-cipher/rotational-cipher-test.roc b/exercises/practice/rotational-cipher/rotational-cipher-test.roc index e652379a..72a1e639 100644 --- a/exercises/practice/rotational-cipher/rotational-cipher-test.roc +++ b/exercises/practice/rotational-cipher/rotational-cipher-test.roc @@ -8,57 +8,57 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line! "" + Stdout.line!("") import RotationalCipher exposing [rotate] # rotate a by 0, same output as input expect - result = rotate "a" 0 + result = rotate("a", 0) result == "a" # rotate a by 1 expect - result = rotate "a" 1 + result = rotate("a", 1) result == "b" # rotate a by 26, same output as input expect - result = rotate "a" 26 + result = rotate("a", 26) result == "a" # rotate m by 13 expect - result = rotate "m" 13 + result = rotate("m", 13) result == "z" # rotate n by 13 with wrap around alphabet expect - result = rotate "n" 13 + result = rotate("n", 13) result == "a" # rotate capital letters expect - result = rotate "OMG" 5 + result = rotate("OMG", 5) result == "TRL" # rotate spaces expect - result = rotate "O M G" 5 + result = rotate("O M G", 5) result == "T R L" # rotate numbers expect - result = rotate "Testing 1 2 3 testing" 4 + result = rotate("Testing 1 2 3 testing", 4) result == "Xiwxmrk 1 2 3 xiwxmrk" # rotate punctuation expect - result = rotate "Let's eat, Grandma!" 21 + result = rotate("Let's eat, Grandma!", 21) result == "Gzo'n zvo, Bmviyhv!" # rotate all letters expect - result = rotate "The quick brown fox jumps over the lazy dog." 13 + result = rotate("The quick brown fox jumps over the lazy dog.", 13) result == "Gur dhvpx oebja sbk whzcf bire gur ynml qbt." diff --git a/exercises/practice/run-length-encoding/.meta/template.j2 b/exercises/practice/run-length-encoding/.meta/template.j2 index b8176fd1..61c5c793 100644 --- a/exercises/practice/run-length-encoding/.meta/template.j2 +++ b/exercises/practice/run-length-encoding/.meta/template.j2 @@ -14,12 +14,12 @@ import {{ exercise | to_pascal }} exposing [encode, decode] expect string = {{ case["input"]["string"] | to_roc }} {%- if case["property"] == "consistency" %} - result = string |> encode |> Result.try decode - result == Ok string + result = string |> encode |> Result.try(decode) + result == Ok(string) {%- else %} result = string |> {{ case["property"] | to_snake }} expected = {{ case["expected"] | to_roc }} - result == Ok expected + result == Ok(expected) {%- endif %} {% endfor %} diff --git a/exercises/practice/run-length-encoding/run-length-encoding-test.roc b/exercises/practice/run-length-encoding/run-length-encoding-test.roc index 81411606..9f3e660d 100644 --- a/exercises/practice/run-length-encoding/run-length-encoding-test.roc +++ b/exercises/practice/run-length-encoding/run-length-encoding-test.roc @@ -8,7 +8,7 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line! "" + Stdout.line!("") import RunLengthEncoding exposing [encode, decode] @@ -21,42 +21,42 @@ expect string = "" result = string |> encode expected = "" - result == Ok expected + result == Ok(expected) # single characters only are encoded without count expect string = "XYZ" result = string |> encode expected = "XYZ" - result == Ok expected + result == Ok(expected) # string with no single characters expect string = "AABBBCCCC" result = string |> encode expected = "2A3B4C" - result == Ok expected + result == Ok(expected) # single characters mixed with repeated characters expect string = "WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWB" result = string |> encode expected = "12WB12W3B24WB" - result == Ok expected + result == Ok(expected) # multiple whitespace mixed in string expect string = " hsqq qww " result = string |> encode expected = "2 hs2q q2w2 " - result == Ok expected + result == Ok(expected) # lowercase characters expect string = "aabbbcccc" result = string |> encode expected = "2a3b4c" - result == Ok expected + result == Ok(expected) ## ## run-length decode a string @@ -67,42 +67,42 @@ expect string = "" result = string |> decode expected = "" - result == Ok expected + result == Ok(expected) # single characters only expect string = "XYZ" result = string |> decode expected = "XYZ" - result == Ok expected + result == Ok(expected) # string with no single characters expect string = "2A3B4C" result = string |> decode expected = "AABBBCCCC" - result == Ok expected + result == Ok(expected) # single characters with repeated characters expect string = "12WB12W3B24WB" result = string |> decode expected = "WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWB" - result == Ok expected + result == Ok(expected) # multiple whitespace mixed in string expect string = "2 hs2q q2w2 " result = string |> decode expected = " hsqq qww " - result == Ok expected + result == Ok(expected) # lowercase string expect string = "2a3b4c" result = string |> decode expected = "aabbbcccc" - result == Ok expected + result == Ok(expected) ## ## encode and then decode @@ -111,6 +111,6 @@ expect # encode followed by decode gives original string expect string = "zzz ZZ zZ" - result = string |> encode |> Result.try decode - result == Ok string + result = string |> encode |> Result.try(decode) + result == Ok(string) diff --git a/exercises/practice/saddle-points/saddle-points-test.roc b/exercises/practice/saddle-points/saddle-points-test.roc index 3acbbd4f..20f182e8 100644 --- a/exercises/practice/saddle-points/saddle-points-test.roc +++ b/exercises/practice/saddle-points/saddle-points-test.roc @@ -8,7 +8,7 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line! "" + Stdout.line!("") import SaddlePoints exposing [saddle_points] diff --git a/exercises/practice/say/.meta/template.j2 b/exercises/practice/say/.meta/template.j2 index 8e03ae6d..7f6649e8 100644 --- a/exercises/practice/say/.meta/template.j2 +++ b/exercises/practice/say/.meta/template.j2 @@ -7,7 +7,7 @@ import {{ exercise | to_pascal }} exposing [{{ cases[0]["property"] | to_snake } {% for case in cases -%} # {{ case["description"] }} expect - result = {{ case["property"] | to_snake }} {{ case["input"]["number"] | to_roc }} + result = {{ case["property"] | to_snake }}({{ case["input"]["number"] | to_roc }}) {%- if case["expected"]["error"] %} result |> Result.is_err {%- else %} diff --git a/exercises/practice/say/say-test.roc b/exercises/practice/say/say-test.roc index 90e939a4..0e3ff4ed 100644 --- a/exercises/practice/say/say-test.roc +++ b/exercises/practice/say/say-test.roc @@ -8,97 +8,97 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line! "" + Stdout.line!("") import Say exposing [say] # zero expect - result = say 0 + result = say(0) result == Ok "zero" # one expect - result = say 1 + result = say(1) result == Ok "one" # fourteen expect - result = say 14 + result = say(14) result == Ok "fourteen" # twenty expect - result = say 20 + result = say(20) result == Ok "twenty" # twenty-two expect - result = say 22 + result = say(22) result == Ok "twenty-two" # thirty expect - result = say 30 + result = say(30) result == Ok "thirty" # ninety-nine expect - result = say 99 + result = say(99) result == Ok "ninety-nine" # one hundred expect - result = say 100 + result = say(100) result == Ok "one hundred" # one hundred twenty-three expect - result = say 123 + result = say(123) result == Ok "one hundred twenty-three" # two hundred expect - result = say 200 + result = say(200) result == Ok "two hundred" # nine hundred ninety-nine expect - result = say 999 + result = say(999) result == Ok "nine hundred ninety-nine" # one thousand expect - result = say 1000 + result = say(1000) result == Ok "one thousand" # one thousand two hundred thirty-four expect - result = say 1234 + result = say(1234) result == Ok "one thousand two hundred thirty-four" # one million expect - result = say 1000000 + result = say(1000000) result == Ok "one million" # one million two thousand three hundred forty-five expect - result = say 1002345 + result = say(1002345) result == Ok "one million two thousand three hundred forty-five" # one billion expect - result = say 1000000000 + result = say(1000000000) result == Ok "one billion" # a big number expect - result = say 987654321123 + result = say(987654321123) result == Ok "nine hundred eighty-seven billion six hundred fifty-four million three hundred twenty-one thousand one hundred twenty-three" # numbers above 999,999,999,999 are out of range expect - result = say 1000000000000 + result = say(1000000000000) result |> Result.is_err diff --git a/exercises/practice/scrabble-score/.meta/template.j2 b/exercises/practice/scrabble-score/.meta/template.j2 index bbb6d670..26c059c0 100644 --- a/exercises/practice/scrabble-score/.meta/template.j2 +++ b/exercises/practice/scrabble-score/.meta/template.j2 @@ -7,7 +7,7 @@ import {{ exercise | to_pascal }} exposing [{{ cases[0]["property"] | to_snake } {% for case in cases -%} # {{ case["description"] }} expect - result = {{ case["property"] | to_snake }} {{ case["input"]["word"] | to_roc }} + result = {{ case["property"] | to_snake }}({{ case["input"]["word"] | to_roc }}) result == {{ case["expected"] | to_roc }} {% endfor %} diff --git a/exercises/practice/scrabble-score/scrabble-score-test.roc b/exercises/practice/scrabble-score/scrabble-score-test.roc index 690b9b91..e0221aa2 100644 --- a/exercises/practice/scrabble-score/scrabble-score-test.roc +++ b/exercises/practice/scrabble-score/scrabble-score-test.roc @@ -8,62 +8,62 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line! "" + Stdout.line!("") import ScrabbleScore exposing [score] # lowercase letter expect - result = score "a" + result = score("a") result == 1 # uppercase letter expect - result = score "A" + result = score("A") result == 1 # valuable letter expect - result = score "f" + result = score("f") result == 4 # short word expect - result = score "at" + result = score("at") result == 2 # short, valuable word expect - result = score "zoo" + result = score("zoo") result == 12 # medium word expect - result = score "street" + result = score("street") result == 6 # medium, valuable word expect - result = score "quirky" + result = score("quirky") result == 22 # long, mixed-case word expect - result = score "OxyphenButazone" + result = score("OxyphenButazone") result == 41 # english-like word expect - result = score "pinata" + result = score("pinata") result == 8 # empty input expect - result = score "" + result = score("") result == 0 # entire alphabet available expect - result = score "abcdefghijklmnopqrstuvwxyz" + result = score("abcdefghijklmnopqrstuvwxyz") result == 87 diff --git a/exercises/practice/secret-handshake/.meta/template.j2 b/exercises/practice/secret-handshake/.meta/template.j2 index 72590767..a4eea5d5 100644 --- a/exercises/practice/secret-handshake/.meta/template.j2 +++ b/exercises/practice/secret-handshake/.meta/template.j2 @@ -7,7 +7,7 @@ import {{ exercise | to_pascal }} exposing [{{ cases[0]["property"] | to_snake } {% for case in cases -%} # {{ case["description"] }} expect - result = {{ case["property"] | to_snake }} {{ case["input"]["number"] }} + result = {{ case["property"] | to_snake }}({{ case["input"]["number"] }}) result == {{ case["expected"] | to_roc }} {% endfor %} diff --git a/exercises/practice/secret-handshake/secret-handshake-test.roc b/exercises/practice/secret-handshake/secret-handshake-test.roc index 2c599cd8..a84bb20a 100644 --- a/exercises/practice/secret-handshake/secret-handshake-test.roc +++ b/exercises/practice/secret-handshake/secret-handshake-test.roc @@ -8,62 +8,62 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line! "" + Stdout.line!("") import SecretHandshake exposing [commands] # wink for 1 expect - result = commands 1 + result = commands(1) result == ["wink"] # double blink for 10 expect - result = commands 2 + result = commands(2) result == ["double blink"] # close your eyes for 100 expect - result = commands 4 + result = commands(4) result == ["close your eyes"] # jump for 1000 expect - result = commands 8 + result = commands(8) result == ["jump"] # combine two actions expect - result = commands 3 + result = commands(3) result == ["wink", "double blink"] # reverse two actions expect - result = commands 19 + result = commands(19) result == ["double blink", "wink"] # reversing one action gives the same action expect - result = commands 24 + result = commands(24) result == ["jump"] # reversing no actions still gives no actions expect - result = commands 16 + result = commands(16) result == [] # all possible actions expect - result = commands 15 + result = commands(15) result == ["wink", "double blink", "close your eyes", "jump"] # reverse all possible actions expect - result = commands 31 + result = commands(31) result == ["jump", "close your eyes", "double blink", "wink"] # do nothing for zero expect - result = commands 0 + result = commands(0) result == [] diff --git a/exercises/practice/series/.meta/template.j2 b/exercises/practice/series/.meta/template.j2 index 4e1b83c7..bc3bea6a 100644 --- a/exercises/practice/series/.meta/template.j2 +++ b/exercises/practice/series/.meta/template.j2 @@ -8,7 +8,7 @@ import {{ exercise | to_pascal }} exposing [{{ cases[0]["property"] | to_snake } # {{ case["description"] }} {%- if case["expected"]["error"] %} – just return an empty list{%- endif %} expect - result = {{ case["input"]["series"] | to_roc }} |> {{ case["property"] | to_snake }} {{ case["input"]["sliceLength"] | to_roc }} + result = {{ case["input"]["series"] | to_roc }} |> {{ case["property"] | to_snake }}({{ case["input"]["sliceLength"] | to_roc }}) {%- if case["expected"]["error"] %} result == [] {%- else %} diff --git a/exercises/practice/series/series-test.roc b/exercises/practice/series/series-test.roc index 49ed397e..4b956f3a 100644 --- a/exercises/practice/series/series-test.roc +++ b/exercises/practice/series/series-test.roc @@ -8,57 +8,57 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line! "" + Stdout.line!("") import Series exposing [slices] # slices of one from one expect - result = "1" |> slices 1 + result = "1" |> slices(1) result == ["1"] # slices of one from two expect - result = "12" |> slices 1 + result = "12" |> slices(1) result == ["1", "2"] # slices of two expect - result = "35" |> slices 2 + result = "35" |> slices(2) result == ["35"] # slices of two overlap expect - result = "9142" |> slices 2 + result = "9142" |> slices(2) result == ["91", "14", "42"] # slices can include duplicates expect - result = "777777" |> slices 3 + result = "777777" |> slices(3) result == ["777", "777", "777", "777"] # slices of a long series expect - result = "918493904243" |> slices 5 + result = "918493904243" |> slices(5) result == ["91849", "18493", "84939", "49390", "93904", "39042", "90424", "04243"] # slice length is too large – just return an empty list expect - result = "12345" |> slices 6 + result = "12345" |> slices(6) result == [] # slice length is way too large – just return an empty list expect - result = "12345" |> slices 42 + result = "12345" |> slices(42) result == [] # slice length cannot be zero – just return an empty list expect - result = "12345" |> slices 0 + result = "12345" |> slices(0) result == [] # empty series is invalid – just return an empty list expect - result = "" |> slices 1 + result = "" |> slices(1) result == [] diff --git a/exercises/practice/sgf-parsing/sgf-parsing-test.roc b/exercises/practice/sgf-parsing/sgf-parsing-test.roc index 82f301de..93ae8277 100644 --- a/exercises/practice/sgf-parsing/sgf-parsing-test.roc +++ b/exercises/practice/sgf-parsing/sgf-parsing-test.roc @@ -9,7 +9,7 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line! "" + Stdout.line!("") import SgfParsing exposing [parse] diff --git a/exercises/practice/sieve/.meta/template.j2 b/exercises/practice/sieve/.meta/template.j2 index fb13bc79..353a7c2a 100644 --- a/exercises/practice/sieve/.meta/template.j2 +++ b/exercises/practice/sieve/.meta/template.j2 @@ -7,7 +7,7 @@ import {{ exercise | to_pascal }} exposing [{{ cases[0]["property"] | to_snake } {% for case in cases -%} # {{ case["description"] }} expect - result = {{ case["property"] | to_snake }} {{ case["input"]["limit"] | to_roc }} + result = {{ case["property"] | to_snake }}({{ case["input"]["limit"] | to_roc }}) result == {{ case["expected"] | to_roc }} {% endfor %} diff --git a/exercises/practice/sieve/sieve-test.roc b/exercises/practice/sieve/sieve-test.roc index 68208ce9..74eefd05 100644 --- a/exercises/practice/sieve/sieve-test.roc +++ b/exercises/practice/sieve/sieve-test.roc @@ -8,32 +8,32 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line! "" + Stdout.line!("") import Sieve exposing [primes] # no primes under two expect - result = primes 1 + result = primes(1) result == [] # find first prime expect - result = primes 2 + result = primes(2) result == [2] # find primes up to 10 expect - result = primes 10 + result = primes(10) result == [2, 3, 5, 7] # limit is prime expect - result = primes 13 + result = primes(13) result == [2, 3, 5, 7, 11, 13] # find primes up to 1000 expect - result = primes 1000 + result = primes(1000) result == [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997] diff --git a/exercises/practice/space-age/.meta/template.j2 b/exercises/practice/space-age/.meta/template.j2 index 278c2aa1..d589ff9d 100644 --- a/exercises/practice/space-age/.meta/template.j2 +++ b/exercises/practice/space-age/.meta/template.j2 @@ -7,7 +7,7 @@ import {{ exercise | to_pascal }} exposing [{{ cases[0]["property"] | to_snake } {% for case in cases -%} # {{ case["description"] }} expect - result = {{ case["property"] | to_snake }} {{ case["input"]["planet"] | to_pascal }} {{ case["input"]["seconds"] }} - Num.is_approx_eq result {{ case["expected"] }} { atol: 0.01 } + result = {{ case["property"] | to_snake }}({{ case["input"]["planet"] | to_pascal }}, {{ case["input"]["seconds"] }}) + Num.is_approx_eq(result, {{ case["expected"] }}, { atol: 0.01 }) {% endfor %} diff --git a/exercises/practice/space-age/space-age-test.roc b/exercises/practice/space-age/space-age-test.roc index 108f184e..0766e91a 100644 --- a/exercises/practice/space-age/space-age-test.roc +++ b/exercises/practice/space-age/space-age-test.roc @@ -8,47 +8,47 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line! "" + Stdout.line!("") import SpaceAge exposing [age] # age on Earth expect - result = age Earth 1000000000 - Num.is_approx_eq result 31.69 { atol: 0.01 } + result = age(Earth, 1000000000) + Num.is_approx_eq(result, 31.69, { atol: 0.01 }) # age on Mercury expect - result = age Mercury 2134835688 - Num.is_approx_eq result 280.88 { atol: 0.01 } + result = age(Mercury, 2134835688) + Num.is_approx_eq(result, 280.88, { atol: 0.01 }) # age on Venus expect - result = age Venus 189839836 - Num.is_approx_eq result 9.78 { atol: 0.01 } + result = age(Venus, 189839836) + Num.is_approx_eq(result, 9.78, { atol: 0.01 }) # age on Mars expect - result = age Mars 2129871239 - Num.is_approx_eq result 35.88 { atol: 0.01 } + result = age(Mars, 2129871239) + Num.is_approx_eq(result, 35.88, { atol: 0.01 }) # age on Jupiter expect - result = age Jupiter 901876382 - Num.is_approx_eq result 2.41 { atol: 0.01 } + result = age(Jupiter, 901876382) + Num.is_approx_eq(result, 2.41, { atol: 0.01 }) # age on Saturn expect - result = age Saturn 2000000000 - Num.is_approx_eq result 2.15 { atol: 0.01 } + result = age(Saturn, 2000000000) + Num.is_approx_eq(result, 2.15, { atol: 0.01 }) # age on Uranus expect - result = age Uranus 1210123456 - Num.is_approx_eq result 0.46 { atol: 0.01 } + result = age(Uranus, 1210123456) + Num.is_approx_eq(result, 0.46, { atol: 0.01 }) # age on Neptune expect - result = age Neptune 1821023456 - Num.is_approx_eq result 0.35 { atol: 0.01 } + result = age(Neptune, 1821023456) + Num.is_approx_eq(result, 0.35, { atol: 0.01 }) diff --git a/exercises/practice/spiral-matrix/.meta/template.j2 b/exercises/practice/spiral-matrix/.meta/template.j2 index f9e1eaea..9f973930 100644 --- a/exercises/practice/spiral-matrix/.meta/template.j2 +++ b/exercises/practice/spiral-matrix/.meta/template.j2 @@ -7,7 +7,7 @@ import {{ exercise | to_pascal }} exposing [{{ cases[0]["property"] | to_snake } {% for case in cases -%} # {{ case["description"] }} expect - result = {{ case["property"] | to_snake }} {{ case["input"]["size"] }} + result = {{ case["property"] | to_snake }}({{ case["input"]["size"] }}) {%- if case["expected"] == [] %} result == [] {%- else %} diff --git a/exercises/practice/spiral-matrix/spiral-matrix-test.roc b/exercises/practice/spiral-matrix/spiral-matrix-test.roc index cd99fb25..2cc84c85 100644 --- a/exercises/practice/spiral-matrix/spiral-matrix-test.roc +++ b/exercises/practice/spiral-matrix/spiral-matrix-test.roc @@ -8,18 +8,18 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line! "" + Stdout.line!("") import SpiralMatrix exposing [spiral_matrix] # empty spiral expect - result = spiral_matrix 0 + result = spiral_matrix(0) result == [] # trivial spiral expect - result = spiral_matrix 1 + result = spiral_matrix(1) expected = [ [1], ] @@ -27,7 +27,7 @@ expect # spiral of size 2 expect - result = spiral_matrix 2 + result = spiral_matrix(2) expected = [ [1, 2], [4, 3], @@ -36,7 +36,7 @@ expect # spiral of size 3 expect - result = spiral_matrix 3 + result = spiral_matrix(3) expected = [ [1, 2, 3], [8, 9, 4], @@ -46,7 +46,7 @@ expect # spiral of size 4 expect - result = spiral_matrix 4 + result = spiral_matrix(4) expected = [ [1, 2, 3, 4], [12, 13, 14, 5], @@ -57,7 +57,7 @@ expect # spiral of size 5 expect - result = spiral_matrix 5 + result = spiral_matrix(5) expected = [ [1, 2, 3, 4, 5], [16, 17, 18, 19, 6], diff --git a/exercises/practice/square-root/.meta/template.j2 b/exercises/practice/square-root/.meta/template.j2 index 3bd17669..9f905aa8 100644 --- a/exercises/practice/square-root/.meta/template.j2 +++ b/exercises/practice/square-root/.meta/template.j2 @@ -7,7 +7,7 @@ import {{ exercise | to_pascal }} exposing [{{ cases[0]["property"] | to_snake } {% for case in cases -%} # {{ case["description"] }} expect - result = {{ case["property"] | to_snake }} {{ case["input"]["radicand"] | to_roc }} + result = {{ case["property"] | to_snake }}({{ case["input"]["radicand"] | to_roc }}) result == {{ case["expected"] | to_roc }} {% endfor %} diff --git a/exercises/practice/square-root/square-root-test.roc b/exercises/practice/square-root/square-root-test.roc index d3645245..4d407995 100644 --- a/exercises/practice/square-root/square-root-test.roc +++ b/exercises/practice/square-root/square-root-test.roc @@ -8,37 +8,37 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line! "" + Stdout.line!("") import SquareRoot exposing [square_root] # root of 1 expect - result = square_root 1 + result = square_root(1) result == 1 # root of 4 expect - result = square_root 4 + result = square_root(4) result == 2 # root of 25 expect - result = square_root 25 + result = square_root(25) result == 5 # root of 81 expect - result = square_root 81 + result = square_root(81) result == 9 # root of 196 expect - result = square_root 196 + result = square_root(196) result == 14 # root of 65025 expect - result = square_root 65025 + result = square_root(65025) result == 255 diff --git a/exercises/practice/strain/.meta/template.j2 b/exercises/practice/strain/.meta/template.j2 index 92f38777..36aab54f 100644 --- a/exercises/practice/strain/.meta/template.j2 +++ b/exercises/practice/strain/.meta/template.j2 @@ -18,7 +18,7 @@ import {{ exercise | to_pascal }} exposing [keep, discard] # {{ case["description"] }} expect list = {{ case["input"]["list"] | to_roc }} - result = list |> {{ case["property"] | to_snake }} {{ function_map[case["input"]["predicate"]] }} + result = list |> {{ case["property"] | to_snake }}({{ function_map[case["input"]["predicate"]] }}) expected = {{ case["expected"] | to_roc }} result == expected diff --git a/exercises/practice/strain/strain-test.roc b/exercises/practice/strain/strain-test.roc index b0e544be..a075345a 100644 --- a/exercises/practice/strain/strain-test.roc +++ b/exercises/practice/strain/strain-test.roc @@ -8,105 +8,105 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line! "" + Stdout.line!("") import Strain exposing [keep, discard] # keep on empty list returns empty list expect list = [] - result = list |> keep |_| Bool.true + result = list |> keep(|_| Bool.true) expected = [] result == expected # keeps everything expect list = [1, 3, 5] - result = list |> keep |_| Bool.true + result = list |> keep(|_| Bool.true) expected = [1, 3, 5] result == expected # keeps nothing expect list = [1, 3, 5] - result = list |> keep |_| Bool.false + result = list |> keep(|_| Bool.false) expected = [] result == expected # keeps first and last expect list = [1, 2, 3] - result = list |> keep |x| x % 2 == 1 + result = list |> keep(|x| x % 2 == 1) expected = [1, 3] result == expected # keeps neither first nor last expect list = [1, 2, 3] - result = list |> keep |x| x % 2 == 0 + result = list |> keep(|x| x % 2 == 0) expected = [2] result == expected # keeps strings expect list = ["apple", "zebra", "banana", "zombies", "cherimoya", "zealot"] - result = list |> keep |x| x |> Str.starts_with "z" + result = list |> keep(|x| x |> Str.starts_with "z") expected = ["zebra", "zombies", "zealot"] result == expected # keeps lists expect list = [[1, 2, 3], [5, 5, 5], [5, 1, 2], [2, 1, 2], [1, 5, 2], [2, 2, 1], [1, 2, 5]] - result = list |> keep |x| x |> List.contains 5 + result = list |> keep(|x| x |> List.contains 5) expected = [[5, 5, 5], [5, 1, 2], [1, 5, 2], [1, 2, 5]] result == expected # discard on empty list returns empty list expect list = [] - result = list |> discard |_| Bool.true + result = list |> discard(|_| Bool.true) expected = [] result == expected # discards everything expect list = [1, 3, 5] - result = list |> discard |_| Bool.true + result = list |> discard(|_| Bool.true) expected = [] result == expected # discards nothing expect list = [1, 3, 5] - result = list |> discard |_| Bool.false + result = list |> discard(|_| Bool.false) expected = [1, 3, 5] result == expected # discards first and last expect list = [1, 2, 3] - result = list |> discard |x| x % 2 == 1 + result = list |> discard(|x| x % 2 == 1) expected = [2] result == expected # discards neither first nor last expect list = [1, 2, 3] - result = list |> discard |x| x % 2 == 0 + result = list |> discard(|x| x % 2 == 0) expected = [1, 3] result == expected # discards strings expect list = ["apple", "zebra", "banana", "zombies", "cherimoya", "zealot"] - result = list |> discard |x| x |> Str.starts_with "z" + result = list |> discard(|x| x |> Str.starts_with "z") expected = ["apple", "banana", "cherimoya"] result == expected # discards lists expect list = [[1, 2, 3], [5, 5, 5], [5, 1, 2], [2, 1, 2], [1, 5, 2], [2, 2, 1], [1, 2, 5]] - result = list |> discard |x| x |> List.contains 5 + result = list |> discard(|x| x |> List.contains 5) expected = [[1, 2, 3], [2, 1, 2], [2, 2, 1]] result == expected diff --git a/exercises/practice/sublist/.meta/template.j2 b/exercises/practice/sublist/.meta/template.j2 index d197d628..9b1776c0 100644 --- a/exercises/practice/sublist/.meta/template.j2 +++ b/exercises/practice/sublist/.meta/template.j2 @@ -7,7 +7,7 @@ import {{ exercise | to_pascal }} exposing [{{ cases[0]["property"] | to_snake } {% for case in cases -%} # {{ case["description"] }} expect - result = {{ case["input"]["listOne"] | to_roc }} |> {{ case["property"] | to_snake }} {{ case["input"]["listTwo"] | to_roc }} + result = {{ case["input"]["listOne"] | to_roc }} |> {{ case["property"] | to_snake }}({{ case["input"]["listTwo"] | to_roc }}) result == {{ case["expected"] | to_pascal }} {% endfor %} diff --git a/exercises/practice/sublist/sublist-test.roc b/exercises/practice/sublist/sublist-test.roc index c4481739..5ac4197d 100644 --- a/exercises/practice/sublist/sublist-test.roc +++ b/exercises/practice/sublist/sublist-test.roc @@ -8,97 +8,97 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line! "" + Stdout.line!("") import Sublist exposing [sublist] # empty lists expect - result = [] |> sublist [] + result = [] |> sublist([]) result == Equal # empty list within non empty list expect - result = [] |> sublist [1, 2, 3] + result = [] |> sublist([1, 2, 3]) result == Sublist # non empty list contains empty list expect - result = [1, 2, 3] |> sublist [] + result = [1, 2, 3] |> sublist([]) result == Superlist # list equals itself expect - result = [1, 2, 3] |> sublist [1, 2, 3] + result = [1, 2, 3] |> sublist([1, 2, 3]) result == Equal # different lists expect - result = [1, 2, 3] |> sublist [2, 3, 4] + result = [1, 2, 3] |> sublist([2, 3, 4]) result == Unequal # false start expect - result = [1, 2, 5] |> sublist [0, 1, 2, 3, 1, 2, 5, 6] + result = [1, 2, 5] |> sublist([0, 1, 2, 3, 1, 2, 5, 6]) result == Sublist # consecutive expect - result = [1, 1, 2] |> sublist [0, 1, 1, 1, 2, 1, 2] + result = [1, 1, 2] |> sublist([0, 1, 1, 1, 2, 1, 2]) result == Sublist # sublist at start expect - result = [0, 1, 2] |> sublist [0, 1, 2, 3, 4, 5] + result = [0, 1, 2] |> sublist([0, 1, 2, 3, 4, 5]) result == Sublist # sublist in middle expect - result = [2, 3, 4] |> sublist [0, 1, 2, 3, 4, 5] + result = [2, 3, 4] |> sublist([0, 1, 2, 3, 4, 5]) result == Sublist # sublist at end expect - result = [3, 4, 5] |> sublist [0, 1, 2, 3, 4, 5] + result = [3, 4, 5] |> sublist([0, 1, 2, 3, 4, 5]) result == Sublist # at start of superlist expect - result = [0, 1, 2, 3, 4, 5] |> sublist [0, 1, 2] + result = [0, 1, 2, 3, 4, 5] |> sublist([0, 1, 2]) result == Superlist # in middle of superlist expect - result = [0, 1, 2, 3, 4, 5] |> sublist [2, 3] + result = [0, 1, 2, 3, 4, 5] |> sublist([2, 3]) result == Superlist # at end of superlist expect - result = [0, 1, 2, 3, 4, 5] |> sublist [3, 4, 5] + result = [0, 1, 2, 3, 4, 5] |> sublist([3, 4, 5]) result == Superlist # first list missing element from second list expect - result = [1, 3] |> sublist [1, 2, 3] + result = [1, 3] |> sublist([1, 2, 3]) result == Unequal # second list missing element from first list expect - result = [1, 2, 3] |> sublist [1, 3] + result = [1, 2, 3] |> sublist([1, 3]) result == Unequal # first list missing additional digits from second list expect - result = [1, 2] |> sublist [1, 22] + result = [1, 2] |> sublist([1, 22]) result == Unequal # order matters to a list expect - result = [1, 2, 3] |> sublist [3, 2, 1] + result = [1, 2, 3] |> sublist([3, 2, 1]) result == Unequal # same digits but different numbers expect - result = [1, 0, 1] |> sublist [10, 1] + result = [1, 0, 1] |> sublist([10, 1]) result == Unequal diff --git a/exercises/practice/sum-of-multiples/.meta/template.j2 b/exercises/practice/sum-of-multiples/.meta/template.j2 index 4ce89bda..52e64a81 100644 --- a/exercises/practice/sum-of-multiples/.meta/template.j2 +++ b/exercises/practice/sum-of-multiples/.meta/template.j2 @@ -7,7 +7,7 @@ import {{ exercise | to_pascal }} exposing [{{ exercise | to_snake }}] {% for case in cases -%} # {{ case["description"] }} expect - result = {{ case["input"]["factors"] | to_roc }} |> {{ exercise | to_snake }} {{ case["input"]["limit"] }} + result = {{ case["input"]["factors"] | to_roc }} |> {{ exercise | to_snake }}({{ case["input"]["limit"] }}) result == {{ case["expected"] | to_roc }} {% endfor %} diff --git a/exercises/practice/sum-of-multiples/sum-of-multiples-test.roc b/exercises/practice/sum-of-multiples/sum-of-multiples-test.roc index c03131cf..1c07b3f3 100644 --- a/exercises/practice/sum-of-multiples/sum-of-multiples-test.roc +++ b/exercises/practice/sum-of-multiples/sum-of-multiples-test.roc @@ -8,87 +8,87 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line! "" + Stdout.line!("") import SumOfMultiples exposing [sum_of_multiples] # no multiples within limit expect - result = [3, 5] |> sum_of_multiples 1 + result = [3, 5] |> sum_of_multiples(1) result == 0 # one factor has multiples within limit expect - result = [3, 5] |> sum_of_multiples 4 + result = [3, 5] |> sum_of_multiples(4) result == 3 # more than one multiple within limit expect - result = [3] |> sum_of_multiples 7 + result = [3] |> sum_of_multiples(7) result == 9 # more than one factor with multiples within limit expect - result = [3, 5] |> sum_of_multiples 10 + result = [3, 5] |> sum_of_multiples(10) result == 23 # each multiple is only counted once expect - result = [3, 5] |> sum_of_multiples 100 + result = [3, 5] |> sum_of_multiples(100) result == 2318 # a much larger limit expect - result = [3, 5] |> sum_of_multiples 1000 + result = [3, 5] |> sum_of_multiples(1000) result == 233168 # three factors expect - result = [7, 13, 17] |> sum_of_multiples 20 + result = [7, 13, 17] |> sum_of_multiples(20) result == 51 # factors not relatively prime expect - result = [4, 6] |> sum_of_multiples 15 + result = [4, 6] |> sum_of_multiples(15) result == 30 # some pairs of factors relatively prime and some not expect - result = [5, 6, 8] |> sum_of_multiples 150 + result = [5, 6, 8] |> sum_of_multiples(150) result == 4419 # one factor is a multiple of another expect - result = [5, 25] |> sum_of_multiples 51 + result = [5, 25] |> sum_of_multiples(51) result == 275 # much larger factors expect - result = [43, 47] |> sum_of_multiples 10000 + result = [43, 47] |> sum_of_multiples(10000) result == 2203160 # all numbers are multiples of 1 expect - result = [1] |> sum_of_multiples 100 + result = [1] |> sum_of_multiples(100) result == 4950 # no factors means an empty sum expect - result = [] |> sum_of_multiples 10000 + result = [] |> sum_of_multiples(10000) result == 0 # the only multiple of 0 is 0 expect - result = [0] |> sum_of_multiples 1 + result = [0] |> sum_of_multiples(1) result == 0 # the factor 0 does not affect the sum of multiples of other factors expect - result = [3, 0] |> sum_of_multiples 4 + result = [3, 0] |> sum_of_multiples(4) result == 3 # solutions using include-exclude must extend to cardinality greater than 3 expect - result = [2, 3, 5, 7, 11] |> sum_of_multiples 10000 + result = [2, 3, 5, 7, 11] |> sum_of_multiples(10000) result == 39614537 diff --git a/exercises/practice/tournament/.meta/template.j2 b/exercises/practice/tournament/.meta/template.j2 index 00f52ebf..0a8f88be 100644 --- a/exercises/practice/tournament/.meta/template.j2 +++ b/exercises/practice/tournament/.meta/template.j2 @@ -8,8 +8,8 @@ import {{ exercise | to_pascal }} exposing [{{ cases[0]["property"] | to_snake } # {{ case["description"] }} expect table = {{ case["input"]["rows"] | to_roc_multiline_string | indent(8) }} - result = {{ case["property"] | to_snake }} table - expected = Ok {{ case["expected"] | to_roc_multiline_string | indent(8) }} + result = {{ case["property"] | to_snake }}(table) + expected = Ok({{ case["expected"] | to_roc_multiline_string | indent(8) }}) result == expected {% endfor %} diff --git a/exercises/practice/tournament/tournament-test.roc b/exercises/practice/tournament/tournament-test.roc index a3b3f7ad..78e4c438 100644 --- a/exercises/practice/tournament/tournament-test.roc +++ b/exercises/practice/tournament/tournament-test.roc @@ -8,63 +8,67 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line! "" + Stdout.line!("") import Tournament exposing [tally] # just the header if no input expect table = "" - result = tally table - expected = Ok "Team | MP | W | D | L | P" + result = tally(table) + expected = Ok("Team | MP | W | D | L | P") result == expected # a win is three points, a loss is zero points expect table = "Allegoric Alaskans;Blithering Badgers;win" - result = tally table - expected = Ok + result = tally(table) + expected = Ok( """ Team | MP | W | D | L | P Allegoric Alaskans | 1 | 1 | 0 | 0 | 3 Blithering Badgers | 1 | 0 | 0 | 1 | 0 - """ + """, + ) result == expected # a win can also be expressed as a loss expect table = "Blithering Badgers;Allegoric Alaskans;loss" - result = tally table - expected = Ok + result = tally(table) + expected = Ok( """ Team | MP | W | D | L | P Allegoric Alaskans | 1 | 1 | 0 | 0 | 3 Blithering Badgers | 1 | 0 | 0 | 1 | 0 - """ + """, + ) result == expected # a different team can win expect table = "Blithering Badgers;Allegoric Alaskans;win" - result = tally table - expected = Ok + result = tally(table) + expected = Ok( """ Team | MP | W | D | L | P Blithering Badgers | 1 | 1 | 0 | 0 | 3 Allegoric Alaskans | 1 | 0 | 0 | 1 | 0 - """ + """, + ) result == expected # a draw is one point each expect table = "Allegoric Alaskans;Blithering Badgers;draw" - result = tally table - expected = Ok + result = tally(table) + expected = Ok( """ Team | MP | W | D | L | P Allegoric Alaskans | 1 | 0 | 1 | 0 | 1 Blithering Badgers | 1 | 0 | 1 | 0 | 1 - """ + """, + ) result == expected # There can be more than one match @@ -74,13 +78,14 @@ expect Allegoric Alaskans;Blithering Badgers;win Allegoric Alaskans;Blithering Badgers;win """ - result = tally table - expected = Ok + result = tally(table) + expected = Ok( """ Team | MP | W | D | L | P Allegoric Alaskans | 2 | 2 | 0 | 0 | 6 Blithering Badgers | 2 | 0 | 0 | 2 | 0 - """ + """, + ) result == expected # There can be more than one winner @@ -90,13 +95,14 @@ expect Allegoric Alaskans;Blithering Badgers;loss Allegoric Alaskans;Blithering Badgers;win """ - result = tally table - expected = Ok + result = tally(table) + expected = Ok( """ Team | MP | W | D | L | P Allegoric Alaskans | 2 | 1 | 0 | 1 | 3 Blithering Badgers | 2 | 1 | 0 | 1 | 3 - """ + """, + ) result == expected # There can be more than two teams @@ -107,14 +113,15 @@ expect Blithering Badgers;Courageous Californians;win Courageous Californians;Allegoric Alaskans;loss """ - result = tally table - expected = Ok + result = tally(table) + expected = Ok( """ Team | MP | W | D | L | P Allegoric Alaskans | 2 | 2 | 0 | 0 | 6 Blithering Badgers | 2 | 1 | 0 | 1 | 3 Courageous Californians | 2 | 0 | 0 | 2 | 0 - """ + """, + ) result == expected # typical input @@ -128,15 +135,16 @@ expect Blithering Badgers;Devastating Donkeys;loss Allegoric Alaskans;Courageous Californians;win """ - result = tally table - expected = Ok + result = tally(table) + expected = Ok( """ Team | MP | W | D | L | P Devastating Donkeys | 3 | 2 | 1 | 0 | 7 Allegoric Alaskans | 3 | 2 | 0 | 1 | 6 Blithering Badgers | 3 | 1 | 0 | 2 | 3 Courageous Californians | 3 | 0 | 1 | 2 | 1 - """ + """, + ) result == expected # incomplete competition (not all pairs have played) @@ -148,15 +156,16 @@ expect Courageous Californians;Blithering Badgers;draw Allegoric Alaskans;Courageous Californians;win """ - result = tally table - expected = Ok + result = tally(table) + expected = Ok( """ Team | MP | W | D | L | P Allegoric Alaskans | 3 | 2 | 0 | 1 | 6 Blithering Badgers | 2 | 1 | 1 | 0 | 4 Courageous Californians | 2 | 0 | 1 | 1 | 1 Devastating Donkeys | 1 | 0 | 0 | 1 | 0 - """ + """, + ) result == expected # ties broken alphabetically @@ -170,15 +179,16 @@ expect Blithering Badgers;Devastating Donkeys;draw Allegoric Alaskans;Courageous Californians;draw """ - result = tally table - expected = Ok + result = tally(table) + expected = Ok( """ Team | MP | W | D | L | P Allegoric Alaskans | 3 | 2 | 1 | 0 | 7 Courageous Californians | 3 | 2 | 1 | 0 | 7 Blithering Badgers | 3 | 0 | 1 | 2 | 1 Devastating Donkeys | 3 | 0 | 1 | 2 | 1 - """ + """, + ) result == expected # ensure points sorted numerically @@ -191,12 +201,13 @@ expect Devastating Donkeys;Blithering Badgers;win Blithering Badgers;Devastating Donkeys;win """ - result = tally table - expected = Ok + result = tally(table) + expected = Ok( """ Team | MP | W | D | L | P Devastating Donkeys | 5 | 4 | 0 | 1 | 12 Blithering Badgers | 5 | 1 | 0 | 4 | 3 - """ + """, + ) result == expected diff --git a/exercises/practice/transpose/.meta/template.j2 b/exercises/practice/transpose/.meta/template.j2 index bbe9f773..4ea165d5 100644 --- a/exercises/practice/transpose/.meta/template.j2 +++ b/exercises/practice/transpose/.meta/template.j2 @@ -7,8 +7,8 @@ import {{ exercise | to_pascal }} exposing [{{ cases[0]["property"] | to_snake } {% for case in cases -%} # {{ case["description"] }} expect - input = {{ case["input"]["lines"] | to_roc_multiline_string | replace(" ", "□") | indent(8) }} |> Str.replace_each "□" " " - result = {{ case["property"] | to_snake }} input |> Str.replace_each " " "□" + input = {{ case["input"]["lines"] | to_roc_multiline_string | replace(" ", "□") | indent(8) }} |> Str.replace_each("□", " ") + result = {{ case["property"] | to_snake }}(input) |> Str.replace_each(" ", "□") expected = {{ case["expected"] | to_roc_multiline_string | replace(" ", "□") | indent(8) }} result == expected diff --git a/exercises/practice/transpose/transpose-test.roc b/exercises/practice/transpose/transpose-test.roc index 278239f8..8f42e735 100644 --- a/exercises/practice/transpose/transpose-test.roc +++ b/exercises/practice/transpose/transpose-test.roc @@ -8,21 +8,21 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line! "" + Stdout.line!("") import Transpose exposing [transpose] # empty string expect - input = "" |> Str.replace_each "□" " " - result = transpose input |> Str.replace_each " " "□" + input = "" |> Str.replace_each("□", " ") + result = transpose(input) |> Str.replace_each(" ", "□") expected = "" result == expected # two characters in a row expect - input = "A1" |> Str.replace_each "□" " " - result = transpose input |> Str.replace_each " " "□" + input = "A1" |> Str.replace_each("□", " ") + result = transpose(input) |> Str.replace_each(" ", "□") expected = """ A @@ -37,8 +37,8 @@ expect A 1 """ - |> Str.replace_each "□" " " - result = transpose input |> Str.replace_each " " "□" + |> Str.replace_each("□", " ") + result = transpose(input) |> Str.replace_each(" ", "□") expected = "A1" result == expected @@ -49,8 +49,8 @@ expect ABC 123 """ - |> Str.replace_each "□" " " - result = transpose input |> Str.replace_each " " "□" + |> Str.replace_each("□", " ") + result = transpose(input) |> Str.replace_each(" ", "□") expected = """ A1 @@ -61,8 +61,8 @@ expect # single line expect - input = "Single□line." |> Str.replace_each "□" " " - result = transpose input |> Str.replace_each " " "□" + input = "Single□line." |> Str.replace_each("□", " ") + result = transpose(input) |> Str.replace_each(" ", "□") expected = """ S @@ -87,8 +87,8 @@ expect The□fourth□line. The□fifth□line. """ - |> Str.replace_each "□" " " - result = transpose input |> Str.replace_each " " "□" + |> Str.replace_each("□", " ") + result = transpose(input) |> Str.replace_each(" ", "□") expected = """ TT @@ -117,8 +117,8 @@ expect The□first□line. The□second□line. """ - |> Str.replace_each "□" " " - result = transpose input |> Str.replace_each " " "□" + |> Str.replace_each("□", " ") + result = transpose(input) |> Str.replace_each(" ", "□") expected = """ TT @@ -149,8 +149,8 @@ expect A□longer□line. A□line. """ - |> Str.replace_each "□" " " - result = transpose input |> Str.replace_each " " "□" + |> Str.replace_each("□", " ") + result = transpose(input) |> Str.replace_each(" ", "□") expected = """ TAAA @@ -183,8 +183,8 @@ expect RESIN TREND """ - |> Str.replace_each "□" " " - result = transpose input |> Str.replace_each " " "□" + |> Str.replace_each("□", " ") + result = transpose(input) |> Str.replace_each(" ", "□") expected = """ HEART @@ -204,8 +204,8 @@ expect BLOOMING SEPTETTE """ - |> Str.replace_each "□" " " - result = transpose input |> Str.replace_each " " "□" + |> Str.replace_each("□", " ") + result = transpose(input) |> Str.replace_each(" ", "□") expected = """ FOBS @@ -230,8 +230,8 @@ expect EEEEE RRRRRR """ - |> Str.replace_each "□" " " - result = transpose input |> Str.replace_each " " "□" + |> Str.replace_each("□", " ") + result = transpose(input) |> Str.replace_each(" ", "□") expected = """ TEASER @@ -254,8 +254,8 @@ expect 555555 66666 """ - |> Str.replace_each "□" " " - result = transpose input |> Str.replace_each " " "□" + |> Str.replace_each("□", " ") + result = transpose(input) |> Str.replace_each(" ", "□") expected = """ 123456 diff --git a/exercises/practice/triangle/triangle-test.roc b/exercises/practice/triangle/triangle-test.roc index 18bee26d..527c8d9e 100644 --- a/exercises/practice/triangle/triangle-test.roc +++ b/exercises/practice/triangle/triangle-test.roc @@ -8,7 +8,7 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line! "" + Stdout.line!("") import Triangle exposing [is_equilateral, is_isosceles, is_scalene] diff --git a/exercises/practice/two-bucket/.meta/template.j2 b/exercises/practice/two-bucket/.meta/template.j2 index 195a3bf1..0847d62c 100644 --- a/exercises/practice/two-bucket/.meta/template.j2 +++ b/exercises/practice/two-bucket/.meta/template.j2 @@ -7,20 +7,20 @@ import {{ exercise | to_pascal }} exposing [{{ cases[0]["property"] | to_snake } {% for case in cases -%} # {{ case["description"] }} expect - result = {{ case["property"] | to_snake }} { + result = {{ case["property"] | to_snake }}({ bucket_one: {{ case["input"]["bucketOne"] }}, bucket_two: {{ case["input"]["bucketTwo"] }}, goal: {{ case["input"]["goal"] }}, start_bucket: {{ case["input"]["startBucket"] | to_pascal }}, - } + }) {%- if case["expected"]["error"] %} result |> Result.is_err {%- else %} - expected = Ok { + expected = Ok({ moves: {{ case["expected"]["moves"] }}, goal_bucket: {{ case["expected"]["goalBucket"] | to_pascal }}, other_bucket: {{ case["expected"]["otherBucket"] }}, - } + }) result == expected {%- endif %} diff --git a/exercises/practice/two-bucket/two-bucket-test.roc b/exercises/practice/two-bucket/two-bucket-test.roc index ec41d6d7..a0e48824 100644 --- a/exercises/practice/two-bucket/two-bucket-test.roc +++ b/exercises/practice/two-bucket/two-bucket-test.roc @@ -8,132 +8,164 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line! "" + Stdout.line!("") import TwoBucket exposing [measure] # Measure using bucket one of size 3 and bucket two of size 5 - start with bucket one expect - result = measure { - bucket_one: 3, - bucket_two: 5, - goal: 1, - start_bucket: One, - } - expected = Ok { - moves: 4, - goal_bucket: One, - other_bucket: 5, - } + result = measure( + { + bucket_one: 3, + bucket_two: 5, + goal: 1, + start_bucket: One, + }, + ) + expected = Ok( + { + moves: 4, + goal_bucket: One, + other_bucket: 5, + }, + ) result == expected # Measure using bucket one of size 3 and bucket two of size 5 - start with bucket two expect - result = measure { - bucket_one: 3, - bucket_two: 5, - goal: 1, - start_bucket: Two, - } - expected = Ok { - moves: 8, - goal_bucket: Two, - other_bucket: 3, - } + result = measure( + { + bucket_one: 3, + bucket_two: 5, + goal: 1, + start_bucket: Two, + }, + ) + expected = Ok( + { + moves: 8, + goal_bucket: Two, + other_bucket: 3, + }, + ) result == expected # Measure using bucket one of size 7 and bucket two of size 11 - start with bucket one expect - result = measure { - bucket_one: 7, - bucket_two: 11, - goal: 2, - start_bucket: One, - } - expected = Ok { - moves: 14, - goal_bucket: One, - other_bucket: 11, - } + result = measure( + { + bucket_one: 7, + bucket_two: 11, + goal: 2, + start_bucket: One, + }, + ) + expected = Ok( + { + moves: 14, + goal_bucket: One, + other_bucket: 11, + }, + ) result == expected # Measure using bucket one of size 7 and bucket two of size 11 - start with bucket two expect - result = measure { - bucket_one: 7, - bucket_two: 11, - goal: 2, - start_bucket: Two, - } - expected = Ok { - moves: 18, - goal_bucket: Two, - other_bucket: 7, - } + result = measure( + { + bucket_one: 7, + bucket_two: 11, + goal: 2, + start_bucket: Two, + }, + ) + expected = Ok( + { + moves: 18, + goal_bucket: Two, + other_bucket: 7, + }, + ) result == expected # Measure one step using bucket one of size 1 and bucket two of size 3 - start with bucket two expect - result = measure { - bucket_one: 1, - bucket_two: 3, - goal: 3, - start_bucket: Two, - } - expected = Ok { - moves: 1, - goal_bucket: Two, - other_bucket: 0, - } + result = measure( + { + bucket_one: 1, + bucket_two: 3, + goal: 3, + start_bucket: Two, + }, + ) + expected = Ok( + { + moves: 1, + goal_bucket: Two, + other_bucket: 0, + }, + ) result == expected # Measure using bucket one of size 2 and bucket two of size 3 - start with bucket one and end with bucket two expect - result = measure { - bucket_one: 2, - bucket_two: 3, - goal: 3, - start_bucket: One, - } - expected = Ok { - moves: 2, - goal_bucket: Two, - other_bucket: 2, - } + result = measure( + { + bucket_one: 2, + bucket_two: 3, + goal: 3, + start_bucket: One, + }, + ) + expected = Ok( + { + moves: 2, + goal_bucket: Two, + other_bucket: 2, + }, + ) result == expected # Not possible to reach the goal expect - result = measure { - bucket_one: 6, - bucket_two: 15, - goal: 5, - start_bucket: One, - } + result = measure( + { + bucket_one: 6, + bucket_two: 15, + goal: 5, + start_bucket: One, + }, + ) result |> Result.is_err # With the same buckets but a different goal, then it is possible expect - result = measure { - bucket_one: 6, - bucket_two: 15, - goal: 9, - start_bucket: One, - } - expected = Ok { - moves: 10, - goal_bucket: Two, - other_bucket: 0, - } + result = measure( + { + bucket_one: 6, + bucket_two: 15, + goal: 9, + start_bucket: One, + }, + ) + expected = Ok( + { + moves: 10, + goal_bucket: Two, + other_bucket: 0, + }, + ) result == expected # Goal larger than both buckets is impossible expect - result = measure { - bucket_one: 5, - bucket_two: 7, - goal: 8, - start_bucket: One, - } + result = measure( + { + bucket_one: 5, + bucket_two: 7, + goal: 8, + start_bucket: One, + }, + ) result |> Result.is_err diff --git a/exercises/practice/two-fer/.meta/template.j2 b/exercises/practice/two-fer/.meta/template.j2 index d343bb76..fc892b19 100644 --- a/exercises/practice/two-fer/.meta/template.j2 +++ b/exercises/practice/two-fer/.meta/template.j2 @@ -10,7 +10,7 @@ expect {%- if case["input"]["name"] == None %} result = {{ case["property"] | to_snake }} Anonymous {%- else %} - result = {{ case["property"] | to_snake }} (Name {{ case["input"]["name"] | to_roc }}) + result = {{ case["property"] | to_snake }}((Name {{ case["input"]["name"] | to_roc }})) {%- endif %} result == {{ case["expected"] | to_roc }} diff --git a/exercises/practice/two-fer/two-fer-test.roc b/exercises/practice/two-fer/two-fer-test.roc index c17b71d2..ccc9b29b 100644 --- a/exercises/practice/two-fer/two-fer-test.roc +++ b/exercises/practice/two-fer/two-fer-test.roc @@ -8,7 +8,7 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line! "" + Stdout.line!("") import TwoFer exposing [two_fer] @@ -19,11 +19,11 @@ expect # a name given expect - result = two_fer (Name "Alice") + result = two_fer(Name "Alice") result == "One for Alice, one for me." # another name given expect - result = two_fer (Name "Bob") + result = two_fer(Name "Bob") result == "One for Bob, one for me." diff --git a/exercises/practice/variable-length-quantity/variable-length-quantity-test.roc b/exercises/practice/variable-length-quantity/variable-length-quantity-test.roc index 8b56ef85..de37bb05 100644 --- a/exercises/practice/variable-length-quantity/variable-length-quantity-test.roc +++ b/exercises/practice/variable-length-quantity/variable-length-quantity-test.roc @@ -8,7 +8,7 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line! "" + Stdout.line!("") import VariableLengthQuantity exposing [encode, decode] diff --git a/exercises/practice/word-count/.meta/template.j2 b/exercises/practice/word-count/.meta/template.j2 index cf7fb559..a1812179 100644 --- a/exercises/practice/word-count/.meta/template.j2 +++ b/exercises/practice/word-count/.meta/template.j2 @@ -7,7 +7,7 @@ import {{ exercise | to_pascal }} exposing [{{ cases[0]["property"] | to_snake } {% for case in cases -%} # {{ case["description"] }} expect - result = {{ case["property"] | to_snake }} {{ case["input"]["sentence"] | to_roc }} + result = {{ case["property"] | to_snake }}({{ case["input"]["sentence"] | to_roc }}) expected = Dict.from_list [ {%- for word, count in case["expected"].items() %} ({{ word | to_roc }}, {{ count }}), diff --git a/exercises/practice/word-count/word-count-test.roc b/exercises/practice/word-count/word-count-test.roc index 52fd46bb..092bf181 100644 --- a/exercises/practice/word-count/word-count-test.roc +++ b/exercises/practice/word-count/word-count-test.roc @@ -8,13 +8,13 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line! "" + Stdout.line!("") import WordCount exposing [count_words] # count one word expect - result = count_words "word" + result = count_words("word") expected = Dict.from_list [ ("word", 1), ] @@ -22,7 +22,7 @@ expect # count one of each word expect - result = count_words "one of each" + result = count_words("one of each") expected = Dict.from_list [ ("one", 1), ("of", 1), @@ -32,7 +32,7 @@ expect # multiple occurrences of a word expect - result = count_words "one fish two fish red fish blue fish" + result = count_words("one fish two fish red fish blue fish") expected = Dict.from_list [ ("one", 1), ("fish", 4), @@ -44,7 +44,7 @@ expect # handles cramped lists expect - result = count_words "one,two,three" + result = count_words("one,two,three") expected = Dict.from_list [ ("one", 1), ("two", 1), @@ -54,7 +54,7 @@ expect # handles expanded lists expect - result = count_words "one,\ntwo,\nthree" + result = count_words("one,\ntwo,\nthree") expected = Dict.from_list [ ("one", 1), ("two", 1), @@ -64,7 +64,7 @@ expect # ignore punctuation expect - result = count_words "car: carpet as java: javascript!!&@$%^&" + result = count_words("car: carpet as java: javascript!!&@$%^&") expected = Dict.from_list [ ("car", 1), ("carpet", 1), @@ -76,7 +76,7 @@ expect # include numbers expect - result = count_words "testing, 1, 2 testing" + result = count_words("testing, 1, 2 testing") expected = Dict.from_list [ ("testing", 2), ("1", 1), @@ -86,7 +86,7 @@ expect # normalize case expect - result = count_words "go Go GO Stop stop" + result = count_words("go Go GO Stop stop") expected = Dict.from_list [ ("go", 3), ("stop", 2), @@ -95,7 +95,7 @@ expect # with apostrophes expect - result = count_words "'First: don't laugh. Then: don't cry. You're getting it.'" + result = count_words("'First: don't laugh. Then: don't cry. You're getting it.'") expected = Dict.from_list [ ("first", 1), ("don't", 2), @@ -110,7 +110,7 @@ expect # with quotations expect - result = count_words "Joe can't tell between 'large' and large." + result = count_words("Joe can't tell between 'large' and large.") expected = Dict.from_list [ ("joe", 1), ("can't", 1), @@ -123,7 +123,7 @@ expect # substrings from the beginning expect - result = count_words "Joe can't tell between app, apple and a." + result = count_words("Joe can't tell between app, apple and a.") expected = Dict.from_list [ ("joe", 1), ("can't", 1), @@ -138,7 +138,7 @@ expect # multiple spaces not detected as a word expect - result = count_words " multiple whitespaces" + result = count_words(" multiple whitespaces") expected = Dict.from_list [ ("multiple", 1), ("whitespaces", 1), @@ -147,7 +147,7 @@ expect # alternating word separators not detected as a word expect - result = count_words ",\n,one,\n ,two \n 'three'" + result = count_words(",\n,one,\n ,two \n 'three'") expected = Dict.from_list [ ("one", 1), ("two", 1), @@ -157,7 +157,7 @@ expect # quotation for word with apostrophe expect - result = count_words "can, can't, 'can't'" + result = count_words("can, can't, 'can't'") expected = Dict.from_list [ ("can", 1), ("can't", 2), diff --git a/exercises/practice/word-search/word-search-test.roc b/exercises/practice/word-search/word-search-test.roc index 7a7bc632..0b4c44a3 100644 --- a/exercises/practice/word-search/word-search-test.roc +++ b/exercises/practice/word-search/word-search-test.roc @@ -8,7 +8,7 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line! "" + Stdout.line!("") import WordSearch exposing [search] diff --git a/exercises/practice/wordy/.meta/template.j2 b/exercises/practice/wordy/.meta/template.j2 index 490fffd3..a6fbe2fe 100644 --- a/exercises/practice/wordy/.meta/template.j2 +++ b/exercises/practice/wordy/.meta/template.j2 @@ -7,7 +7,7 @@ import {{ exercise | to_pascal }} exposing [answer] {% for case in cases -%} # {{ case["description"] }} expect - result = {{ case["property"] | to_snake }} {{ case["input"]["question"] | to_roc }} + result = {{ case["property"] | to_snake }}({{ case["input"]["question"] | to_roc }}) {%- if case["expected"]["error"] %} Result.is_err result {%- else %} diff --git a/exercises/practice/wordy/wordy-test.roc b/exercises/practice/wordy/wordy-test.roc index e556470d..7a09a8dd 100644 --- a/exercises/practice/wordy/wordy-test.roc +++ b/exercises/practice/wordy/wordy-test.roc @@ -8,142 +8,142 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line! "" + Stdout.line!("") import Wordy exposing [answer] # just a number expect - result = answer "What is 5?" + result = answer("What is 5?") result == Ok 5 # just a zero expect - result = answer "What is 0?" + result = answer("What is 0?") result == Ok 0 # just a negative number expect - result = answer "What is -123?" + result = answer("What is -123?") result == Ok -123 # addition expect - result = answer "What is 1 plus 1?" + result = answer("What is 1 plus 1?") result == Ok 2 # addition with a left hand zero expect - result = answer "What is 0 plus 2?" + result = answer("What is 0 plus 2?") result == Ok 2 # addition with a right hand zero expect - result = answer "What is 3 plus 0?" + result = answer("What is 3 plus 0?") result == Ok 3 # more addition expect - result = answer "What is 53 plus 2?" + result = answer("What is 53 plus 2?") result == Ok 55 # addition with negative numbers expect - result = answer "What is -1 plus -10?" + result = answer("What is -1 plus -10?") result == Ok -11 # large addition expect - result = answer "What is 123 plus 45678?" + result = answer("What is 123 plus 45678?") result == Ok 45801 # subtraction expect - result = answer "What is 4 minus -12?" + result = answer("What is 4 minus -12?") result == Ok 16 # multiplication expect - result = answer "What is -3 multiplied by 25?" + result = answer("What is -3 multiplied by 25?") result == Ok -75 # division expect - result = answer "What is 33 divided by -3?" + result = answer("What is 33 divided by -3?") result == Ok -11 # multiple additions expect - result = answer "What is 1 plus 1 plus 1?" + result = answer("What is 1 plus 1 plus 1?") result == Ok 3 # addition and subtraction expect - result = answer "What is 1 plus 5 minus -2?" + result = answer("What is 1 plus 5 minus -2?") result == Ok 8 # multiple subtraction expect - result = answer "What is 20 minus 4 minus 13?" + result = answer("What is 20 minus 4 minus 13?") result == Ok 3 # subtraction then addition expect - result = answer "What is 17 minus 6 plus 3?" + result = answer("What is 17 minus 6 plus 3?") result == Ok 14 # multiple multiplication expect - result = answer "What is 2 multiplied by -2 multiplied by 3?" + result = answer("What is 2 multiplied by -2 multiplied by 3?") result == Ok -12 # addition and multiplication expect - result = answer "What is -3 plus 7 multiplied by -2?" + result = answer("What is -3 plus 7 multiplied by -2?") result == Ok -8 # multiple division expect - result = answer "What is -12 divided by 2 divided by -3?" + result = answer("What is -12 divided by 2 divided by -3?") result == Ok 2 # unknown operation expect - result = answer "What is 52 cubed?" + result = answer("What is 52 cubed?") Result.is_err result # Non math question expect - result = answer "Who is the President of the United States?" + result = answer("Who is the President of the United States?") Result.is_err result # reject problem missing an operand expect - result = answer "What is 1 plus?" + result = answer("What is 1 plus?") Result.is_err result # reject problem with no operands or operators expect - result = answer "What is?" + result = answer("What is?") Result.is_err result # reject two operations in a row expect - result = answer "What is 1 plus plus 2?" + result = answer("What is 1 plus plus 2?") Result.is_err result # reject two numbers in a row expect - result = answer "What is 1 plus 2 1?" + result = answer("What is 1 plus 2 1?") Result.is_err result # reject postfix notation expect - result = answer "What is 1 2 plus?" + result = answer("What is 1 2 plus?") Result.is_err result # reject prefix notation expect - result = answer "What is plus 1 2?" + result = answer("What is plus 1 2?") Result.is_err result diff --git a/exercises/practice/yacht/.meta/template.j2 b/exercises/practice/yacht/.meta/template.j2 index aa104614..a429ba1b 100644 --- a/exercises/practice/yacht/.meta/template.j2 +++ b/exercises/practice/yacht/.meta/template.j2 @@ -7,7 +7,7 @@ import {{ exercise | to_pascal }} exposing [{{ cases[0]["property"] | to_snake } {% for case in cases -%} # {{ case["description"] }} expect - result = {{ case["input"]["dice"] | to_roc }} |> {{ case["property"] | to_snake }} {{ case["input"]["category"] | to_pascal }} + result = {{ case["input"]["dice"] | to_roc }} |> {{ case["property"] | to_snake }}({{ case["input"]["category"] | to_pascal }}) result == {{ case["expected"] | to_roc }} {% endfor %} diff --git a/exercises/practice/yacht/yacht-test.roc b/exercises/practice/yacht/yacht-test.roc index c51a9066..f663e7c3 100644 --- a/exercises/practice/yacht/yacht-test.roc +++ b/exercises/practice/yacht/yacht-test.roc @@ -8,152 +8,152 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line! "" + Stdout.line!("") import Yacht exposing [score] # Yacht expect - result = [5, 5, 5, 5, 5] |> score Yacht + result = [5, 5, 5, 5, 5] |> score(Yacht) result == 50 # Not Yacht expect - result = [1, 3, 3, 2, 5] |> score Yacht + result = [1, 3, 3, 2, 5] |> score(Yacht) result == 0 # Ones expect - result = [1, 1, 1, 3, 5] |> score Ones + result = [1, 1, 1, 3, 5] |> score(Ones) result == 3 # Ones, out of order expect - result = [3, 1, 1, 5, 1] |> score Ones + result = [3, 1, 1, 5, 1] |> score(Ones) result == 3 # No ones expect - result = [4, 3, 6, 5, 5] |> score Ones + result = [4, 3, 6, 5, 5] |> score(Ones) result == 0 # Twos expect - result = [2, 3, 4, 5, 6] |> score Twos + result = [2, 3, 4, 5, 6] |> score(Twos) result == 2 # Fours expect - result = [1, 4, 1, 4, 1] |> score Fours + result = [1, 4, 1, 4, 1] |> score(Fours) result == 8 # Yacht counted as threes expect - result = [3, 3, 3, 3, 3] |> score Threes + result = [3, 3, 3, 3, 3] |> score(Threes) result == 15 # Yacht of 3s counted as fives expect - result = [3, 3, 3, 3, 3] |> score Fives + result = [3, 3, 3, 3, 3] |> score(Fives) result == 0 # Fives expect - result = [1, 5, 3, 5, 3] |> score Fives + result = [1, 5, 3, 5, 3] |> score(Fives) result == 10 # Sixes expect - result = [2, 3, 4, 5, 6] |> score Sixes + result = [2, 3, 4, 5, 6] |> score(Sixes) result == 6 # Full house two small, three big expect - result = [2, 2, 4, 4, 4] |> score FullHouse + result = [2, 2, 4, 4, 4] |> score(FullHouse) result == 16 # Full house three small, two big expect - result = [5, 3, 3, 5, 3] |> score FullHouse + result = [5, 3, 3, 5, 3] |> score(FullHouse) result == 19 # Two pair is not a full house expect - result = [2, 2, 4, 4, 5] |> score FullHouse + result = [2, 2, 4, 4, 5] |> score(FullHouse) result == 0 # Four of a kind is not a full house expect - result = [1, 4, 4, 4, 4] |> score FullHouse + result = [1, 4, 4, 4, 4] |> score(FullHouse) result == 0 # Yacht is not a full house expect - result = [2, 2, 2, 2, 2] |> score FullHouse + result = [2, 2, 2, 2, 2] |> score(FullHouse) result == 0 # Four of a Kind expect - result = [6, 6, 4, 6, 6] |> score FourOfAKind + result = [6, 6, 4, 6, 6] |> score(FourOfAKind) result == 24 # Yacht can be scored as Four of a Kind expect - result = [3, 3, 3, 3, 3] |> score FourOfAKind + result = [3, 3, 3, 3, 3] |> score(FourOfAKind) result == 12 # Full house is not Four of a Kind expect - result = [3, 3, 3, 5, 5] |> score FourOfAKind + result = [3, 3, 3, 5, 5] |> score(FourOfAKind) result == 0 # Little Straight expect - result = [3, 5, 4, 1, 2] |> score LittleStraight + result = [3, 5, 4, 1, 2] |> score(LittleStraight) result == 30 # Little Straight as Big Straight expect - result = [1, 2, 3, 4, 5] |> score BigStraight + result = [1, 2, 3, 4, 5] |> score(BigStraight) result == 0 # Four in order but not a little straight expect - result = [1, 1, 2, 3, 4] |> score LittleStraight + result = [1, 1, 2, 3, 4] |> score(LittleStraight) result == 0 # No pairs but not a little straight expect - result = [1, 2, 3, 4, 6] |> score LittleStraight + result = [1, 2, 3, 4, 6] |> score(LittleStraight) result == 0 # Minimum is 1, maximum is 5, but not a little straight expect - result = [1, 1, 3, 4, 5] |> score LittleStraight + result = [1, 1, 3, 4, 5] |> score(LittleStraight) result == 0 # Big Straight expect - result = [4, 6, 2, 5, 3] |> score BigStraight + result = [4, 6, 2, 5, 3] |> score(BigStraight) result == 30 # Big Straight as little straight expect - result = [6, 5, 4, 3, 2] |> score LittleStraight + result = [6, 5, 4, 3, 2] |> score(LittleStraight) result == 0 # No pairs but not a big straight expect - result = [6, 5, 4, 3, 1] |> score BigStraight + result = [6, 5, 4, 3, 1] |> score(BigStraight) result == 0 # Choice expect - result = [3, 3, 5, 6, 6] |> score Choice + result = [3, 3, 5, 6, 6] |> score(Choice) result == 23 # Yacht as choice expect - result = [2, 2, 2, 2, 2] |> score Choice + result = [2, 2, 2, 2, 2] |> score(Choice) result == 10 diff --git a/exercises/practice/zebra-puzzle/zebra-puzzle-test.roc b/exercises/practice/zebra-puzzle/zebra-puzzle-test.roc index ac83904a..796fe340 100644 --- a/exercises/practice/zebra-puzzle/zebra-puzzle-test.roc +++ b/exercises/practice/zebra-puzzle/zebra-puzzle-test.roc @@ -8,7 +8,7 @@ app [main!] { import pf.Stdout main! = |_args| - Stdout.line! "" + Stdout.line!("") import ZebraPuzzle exposing [owns_zebra, drinks_water] From 505921218bb560652acac80b715293f46c552871 Mon Sep 17 00:00:00 2001 From: Anton-4 <17049058+Anton-4@users.noreply.github.com> Date: Sat, 26 Jul 2025 18:48:50 +0200 Subject: [PATCH 4/8] more syntax updates --- .../practice/accumulate/.meta/template.j2 | 14 +- .../practice/accumulate/accumulate-test.roc | 14 +- .../practice/affine-cipher/.meta/template.j2 | 4 +- .../affine-cipher/affine-cipher-test.roc | 60 +++---- .../practice/allergies/.meta/template.j2 | 4 +- .../practice/allergies/allergies-test.roc | 100 +++++------ .../practice/alphametics/.meta/template.j2 | 6 +- .../practice/alphametics/alphametics-test.roc | 170 ++++++++++-------- .../practice/atbash-cipher/.meta/template.j2 | 2 +- .../atbash-cipher/atbash-cipher-test.roc | 28 +-- .../binary-search-tree/.meta/template.j2 | 10 +- .../binary-search-tree-test.roc | 164 ++++++++++------- .../practice/binary-search/.meta/template.j2 | 4 +- .../binary-search/binary-search-test.roc | 22 +-- exercises/practice/binary/.meta/template.j2 | 2 +- exercises/practice/binary/binary-test.roc | 18 +- exercises/practice/bowling/.meta/template.j2 | 25 +-- exercises/practice/bowling/bowling-test.roc | 117 +++++++----- exercises/practice/change/.meta/template.j2 | 2 +- exercises/practice/change/change-test.roc | 20 +-- .../circular-buffer/.meta/template.j2 | 2 +- .../circular-buffer/circular-buffer-test.roc | 28 +-- .../collatz-conjecture/.meta/template.j2 | 2 +- .../collatz-conjecture-test.roc | 8 +- exercises/practice/connect/.meta/template.j2 | 2 +- exercises/practice/connect/connect-test.roc | 12 +- exercises/practice/dominoes/.meta/template.j2 | 29 +-- exercises/practice/dominoes/dominoes-test.roc | 65 +++---- exercises/practice/forth/.meta/template.j2 | 2 +- exercises/practice/forth/forth-test.roc | 72 ++++---- .../practice/go-counting/.meta/template.j2 | 12 +- .../practice/go-counting/go-counting-test.roc | 130 ++++++++------ exercises/practice/grains/.meta/template.j2 | 2 +- exercises/practice/grains/grains-test.roc | 14 +- .../practice/high-scores/.meta/template.j2 | 2 +- .../practice/high-scores/high-scores-test.roc | 4 +- .../kindergarten-garden/.meta/template.j2 | 2 +- .../kindergarten-garden-test.roc | 34 ++-- .../largest-series-product/.meta/template.j2 | 2 +- .../largest-series-product-test.roc | 22 +-- exercises/practice/matrix/.meta/template.j2 | 2 +- exercises/practice/matrix/matrix-test.roc | 16 +- .../practice/micro-blog/.meta/template.j2 | 2 +- .../practice/micro-blog/micro-blog-test.roc | 24 +-- .../practice/nth-prime/.meta/template.j2 | 2 +- .../practice/nth-prime/nth-prime-test.roc | 8 +- .../nucleotide-count/.meta/template.j2 | 2 +- .../nucleotide-count-test.roc | 8 +- .../practice/ocr-numbers/.meta/template.j2 | 2 +- .../practice/ocr-numbers/ocr-numbers-test.roc | 30 ++-- .../perfect-numbers/.meta/template.j2 | 2 +- .../perfect-numbers/perfect-numbers-test.roc | 22 +-- .../practice/phone-number/.meta/template.j2 | 2 +- .../phone-number/phone-number-test.roc | 10 +- .../rail-fence-cipher/.meta/template.j2 | 2 +- .../rail-fence-cipher-test.roc | 12 +- .../practice/resistor-color/.meta/template.j2 | 2 +- .../resistor-color/resistor-color-test.roc | 6 +- .../practice/roman-numerals/.meta/template.j2 | 2 +- .../roman-numerals/roman-numerals-test.roc | 54 +++--- exercises/practice/say/.meta/template.j2 | 2 +- exercises/practice/say/say-test.roc | 34 ++-- .../practice/sgf-parsing/.meta/template.j2 | 2 +- .../practice/sgf-parsing/sgf-parsing-test.roc | 34 ++-- .../.meta/template.j2 | 2 +- .../variable-length-quantity-test.roc | 12 +- exercises/practice/wordy/.meta/template.j2 | 4 +- exercises/practice/wordy/wordy-test.roc | 54 +++--- .../practice/zebra-puzzle/.meta/template.j2 | 2 +- .../zebra-puzzle/zebra-puzzle-test.roc | 4 +- 70 files changed, 842 insertions(+), 750 deletions(-) diff --git a/exercises/practice/accumulate/.meta/template.j2 b/exercises/practice/accumulate/.meta/template.j2 index f3225606..450806a5 100644 --- a/exercises/practice/accumulate/.meta/template.j2 +++ b/exercises/practice/accumulate/.meta/template.j2 @@ -21,7 +21,7 @@ expect reverse : Str -> Str reverse = |str| - Str.to_utf8 str + Str.to_utf8(str) |> List.reverse |> Str.from_utf8 |> Result.with_default("") @@ -29,10 +29,12 @@ reverse = |str| to_upper : Str -> Str to_upper = |str| Str.to_utf8 str - |> List.map |byte| - if 'a' <= byte && byte <= 'z' then - byte - 'a' + 'A' - else - byte + |> List.map( + |byte| + if 'a' <= byte && byte <= 'z' then + byte - 'a' + 'A' + else + byte + ) |> Str.from_utf8 |> Result.with_default("") diff --git a/exercises/practice/accumulate/accumulate-test.roc b/exercises/practice/accumulate/accumulate-test.roc index 678a6373..0605d796 100644 --- a/exercises/practice/accumulate/accumulate-test.roc +++ b/exercises/practice/accumulate/accumulate-test.roc @@ -51,7 +51,7 @@ expect reverse : Str -> Str reverse = |str| - Str.to_utf8 str + Str.to_utf8(str) |> List.reverse |> Str.from_utf8 |> Result.with_default("") @@ -59,10 +59,12 @@ reverse = |str| to_upper : Str -> Str to_upper = |str| Str.to_utf8 str - |> List.map |byte| - if 'a' <= byte and byte <= 'z' then - byte - 'a' + 'A' - else - byte + |> List.map( + |byte| + if 'a' <= byte and byte <= 'z' then + byte - 'a' + 'A' + else + byte, + ) |> Str.from_utf8 |> Result.with_default("") diff --git a/exercises/practice/affine-cipher/.meta/template.j2 b/exercises/practice/affine-cipher/.meta/template.j2 index 1f738429..764b52b8 100644 --- a/exercises/practice/affine-cipher/.meta/template.j2 +++ b/exercises/practice/affine-cipher/.meta/template.j2 @@ -14,11 +14,11 @@ import {{ exercise | to_pascal }} exposing [encode, decode] expect phrase = {{ case["input"]["phrase"] | to_roc }} key = {a: {{ case["input"]["key"]["a"] }}, b: {{ case["input"]["key"]["b"] }}} - result = {{ case["property"] | to_snake }} phrase key + result = {{ case["property"] | to_snake }}(phrase, key) {%- if case["expected"]["error"] %} result |> Result.is_err {%- else %} - expected = Ok {{ case["expected"] | to_roc }} + expected = Ok({{ case["expected"] | to_roc }}) result == expected {%- endif %} diff --git a/exercises/practice/affine-cipher/affine-cipher-test.roc b/exercises/practice/affine-cipher/affine-cipher-test.roc index 4a99d7a2..402ca1e8 100644 --- a/exercises/practice/affine-cipher/affine-cipher-test.roc +++ b/exercises/practice/affine-cipher/affine-cipher-test.roc @@ -20,71 +20,71 @@ import AffineCipher exposing [encode, decode] expect phrase = "yes" key = { a: 5, b: 7 } - result = encode phrase key - expected = Ok "xbt" + result = encode(phrase, key) + expected = Ok("xbt") result == expected # encode no expect phrase = "no" key = { a: 15, b: 18 } - result = encode phrase key - expected = Ok "fu" + result = encode(phrase, key) + expected = Ok("fu") result == expected # encode OMG expect phrase = "OMG" key = { a: 21, b: 3 } - result = encode phrase key - expected = Ok "lvz" + result = encode(phrase, key) + expected = Ok("lvz") result == expected # encode O M G expect phrase = "O M G" key = { a: 25, b: 47 } - result = encode phrase key - expected = Ok "hjp" + result = encode(phrase, key) + expected = Ok("hjp") result == expected # encode mindblowingly expect phrase = "mindblowingly" key = { a: 11, b: 15 } - result = encode phrase key - expected = Ok "rzcwa gnxzc dgt" + result = encode(phrase, key) + expected = Ok("rzcwa gnxzc dgt") result == expected # encode numbers expect phrase = "Testing,1 2 3, testing." key = { a: 3, b: 4 } - result = encode phrase key - expected = Ok "jqgjc rw123 jqgjc rw" + result = encode(phrase, key) + expected = Ok("jqgjc rw123 jqgjc rw") result == expected # encode deep thought expect phrase = "Truth is fiction." key = { a: 5, b: 17 } - result = encode phrase key - expected = Ok "iynia fdqfb ifje" + result = encode(phrase, key) + expected = Ok("iynia fdqfb ifje") result == expected # encode all the letters expect phrase = "The quick brown fox jumps over the lazy dog." key = { a: 17, b: 33 } - result = encode phrase key - expected = Ok "swxtj npvyk lruol iejdc blaxk swxmh qzglf" + result = encode(phrase, key) + expected = Ok("swxtj npvyk lruol iejdc blaxk swxmh qzglf") result == expected # encode with a not coprime to m expect phrase = "This is a test." key = { a: 6, b: 17 } - result = encode phrase key + result = encode(phrase, key) result |> Result.is_err ## @@ -95,54 +95,54 @@ expect expect phrase = "tytgn fjr" key = { a: 3, b: 7 } - result = decode phrase key - expected = Ok "exercism" + result = decode(phrase, key) + expected = Ok("exercism") result == expected # decode a sentence expect phrase = "qdwju nqcro muwhn odqun oppmd aunwd o" key = { a: 19, b: 16 } - result = decode phrase key - expected = Ok "anobstacleisoftenasteppingstone" + result = decode(phrase, key) + expected = Ok("anobstacleisoftenasteppingstone") result == expected # decode numbers expect phrase = "odpoz ub123 odpoz ub" key = { a: 25, b: 7 } - result = decode phrase key - expected = Ok "testing123testing" + result = decode(phrase, key) + expected = Ok("testing123testing") result == expected # decode all the letters expect phrase = "swxtj npvyk lruol iejdc blaxk swxmh qzglf" key = { a: 17, b: 33 } - result = decode phrase key - expected = Ok "thequickbrownfoxjumpsoverthelazydog" + result = decode(phrase, key) + expected = Ok("thequickbrownfoxjumpsoverthelazydog") result == expected # decode with no spaces in input expect phrase = "swxtjnpvyklruoliejdcblaxkswxmhqzglf" key = { a: 17, b: 33 } - result = decode phrase key - expected = Ok "thequickbrownfoxjumpsoverthelazydog" + result = decode(phrase, key) + expected = Ok("thequickbrownfoxjumpsoverthelazydog") result == expected # decode with too many spaces expect phrase = "vszzm cly yd cg qdp" key = { a: 15, b: 16 } - result = decode phrase key - expected = Ok "jollygreengiant" + result = decode(phrase, key) + expected = Ok("jollygreengiant") result == expected # decode with a not coprime to m expect phrase = "Test" key = { a: 13, b: 5 } - result = decode phrase key + result = decode(phrase, key) result |> Result.is_err diff --git a/exercises/practice/allergies/.meta/template.j2 b/exercises/practice/allergies/.meta/template.j2 index b59ce358..504099c2 100644 --- a/exercises/practice/allergies/.meta/template.j2 +++ b/exercises/practice/allergies/.meta/template.j2 @@ -9,11 +9,11 @@ import {{ exercise | to_pascal }} exposing [allergic_to, set] # {{ outerCase["description"] }} {{ case["description"] | default('') }} expect {%- if case["property"] == "allergicTo" %} - result = allergic_to {{ case["input"]["item"] | to_pascal }} {{ case["input"]["score"] | to_roc }} + result = allergic_to({{ case["input"]["item"] | to_pascal }}, {{ case["input"]["score"] | to_roc }}) result == {{ case["expected"] | to_roc }} {%- else %} result = set {{ case["input"]["score"] }} - result == Set.from_list [{{ case["expected"] | map('to_pascal') | join(", ") }}] + result == Set.from_list([{{ case["expected"] | map('to_pascal') | join(", ") }}]) {%- endif %} {% endfor %} diff --git a/exercises/practice/allergies/allergies-test.roc b/exercises/practice/allergies/allergies-test.roc index 9207f7cf..8bcd2743 100644 --- a/exercises/practice/allergies/allergies-test.roc +++ b/exercises/practice/allergies/allergies-test.roc @@ -14,251 +14,251 @@ import Allergies exposing [allergic_to, set] # testing for eggs allergy not allergic to anything expect - result = allergic_to Eggs 0 + result = allergic_to(Eggs, 0) result == Bool.false # testing for eggs allergy allergic only to eggs expect - result = allergic_to Eggs 1 + result = allergic_to(Eggs, 1) result == Bool.true # testing for eggs allergy allergic to eggs and something else expect - result = allergic_to Eggs 3 + result = allergic_to(Eggs, 3) result == Bool.true # testing for eggs allergy allergic to something, but not eggs expect - result = allergic_to Eggs 2 + result = allergic_to(Eggs, 2) result == Bool.false # testing for eggs allergy allergic to everything expect - result = allergic_to Eggs 255 + result = allergic_to(Eggs, 255) result == Bool.true # testing for peanuts allergy not allergic to anything expect - result = allergic_to Peanuts 0 + result = allergic_to(Peanuts, 0) result == Bool.false # testing for peanuts allergy allergic only to peanuts expect - result = allergic_to Peanuts 2 + result = allergic_to(Peanuts, 2) result == Bool.true # testing for peanuts allergy allergic to peanuts and something else expect - result = allergic_to Peanuts 7 + result = allergic_to(Peanuts, 7) result == Bool.true # testing for peanuts allergy allergic to something, but not peanuts expect - result = allergic_to Peanuts 5 + result = allergic_to(Peanuts, 5) result == Bool.false # testing for peanuts allergy allergic to everything expect - result = allergic_to Peanuts 255 + result = allergic_to(Peanuts, 255) result == Bool.true # testing for shellfish allergy not allergic to anything expect - result = allergic_to Shellfish 0 + result = allergic_to(Shellfish, 0) result == Bool.false # testing for shellfish allergy allergic only to shellfish expect - result = allergic_to Shellfish 4 + result = allergic_to(Shellfish, 4) result == Bool.true # testing for shellfish allergy allergic to shellfish and something else expect - result = allergic_to Shellfish 14 + result = allergic_to(Shellfish, 14) result == Bool.true # testing for shellfish allergy allergic to something, but not shellfish expect - result = allergic_to Shellfish 10 + result = allergic_to(Shellfish, 10) result == Bool.false # testing for shellfish allergy allergic to everything expect - result = allergic_to Shellfish 255 + result = allergic_to(Shellfish, 255) result == Bool.true # testing for strawberries allergy not allergic to anything expect - result = allergic_to Strawberries 0 + result = allergic_to(Strawberries, 0) result == Bool.false # testing for strawberries allergy allergic only to strawberries expect - result = allergic_to Strawberries 8 + result = allergic_to(Strawberries, 8) result == Bool.true # testing for strawberries allergy allergic to strawberries and something else expect - result = allergic_to Strawberries 28 + result = allergic_to(Strawberries, 28) result == Bool.true # testing for strawberries allergy allergic to something, but not strawberries expect - result = allergic_to Strawberries 20 + result = allergic_to(Strawberries, 20) result == Bool.false # testing for strawberries allergy allergic to everything expect - result = allergic_to Strawberries 255 + result = allergic_to(Strawberries, 255) result == Bool.true # testing for tomatoes allergy not allergic to anything expect - result = allergic_to Tomatoes 0 + result = allergic_to(Tomatoes, 0) result == Bool.false # testing for tomatoes allergy allergic only to tomatoes expect - result = allergic_to Tomatoes 16 + result = allergic_to(Tomatoes, 16) result == Bool.true # testing for tomatoes allergy allergic to tomatoes and something else expect - result = allergic_to Tomatoes 56 + result = allergic_to(Tomatoes, 56) result == Bool.true # testing for tomatoes allergy allergic to something, but not tomatoes expect - result = allergic_to Tomatoes 40 + result = allergic_to(Tomatoes, 40) result == Bool.false # testing for tomatoes allergy allergic to everything expect - result = allergic_to Tomatoes 255 + result = allergic_to(Tomatoes, 255) result == Bool.true # testing for chocolate allergy not allergic to anything expect - result = allergic_to Chocolate 0 + result = allergic_to(Chocolate, 0) result == Bool.false # testing for chocolate allergy allergic only to chocolate expect - result = allergic_to Chocolate 32 + result = allergic_to(Chocolate, 32) result == Bool.true # testing for chocolate allergy allergic to chocolate and something else expect - result = allergic_to Chocolate 112 + result = allergic_to(Chocolate, 112) result == Bool.true # testing for chocolate allergy allergic to something, but not chocolate expect - result = allergic_to Chocolate 80 + result = allergic_to(Chocolate, 80) result == Bool.false # testing for chocolate allergy allergic to everything expect - result = allergic_to Chocolate 255 + result = allergic_to(Chocolate, 255) result == Bool.true # testing for pollen allergy not allergic to anything expect - result = allergic_to Pollen 0 + result = allergic_to(Pollen, 0) result == Bool.false # testing for pollen allergy allergic only to pollen expect - result = allergic_to Pollen 64 + result = allergic_to(Pollen, 64) result == Bool.true # testing for pollen allergy allergic to pollen and something else expect - result = allergic_to Pollen 224 + result = allergic_to(Pollen, 224) result == Bool.true # testing for pollen allergy allergic to something, but not pollen expect - result = allergic_to Pollen 160 + result = allergic_to(Pollen, 160) result == Bool.false # testing for pollen allergy allergic to everything expect - result = allergic_to Pollen 255 + result = allergic_to(Pollen, 255) result == Bool.true # testing for cats allergy not allergic to anything expect - result = allergic_to Cats 0 + result = allergic_to(Cats, 0) result == Bool.false # testing for cats allergy allergic only to cats expect - result = allergic_to Cats 128 + result = allergic_to(Cats, 128) result == Bool.true # testing for cats allergy allergic to cats and something else expect - result = allergic_to Cats 192 + result = allergic_to(Cats, 192) result == Bool.true # testing for cats allergy allergic to something, but not cats expect - result = allergic_to Cats 64 + result = allergic_to(Cats, 64) result == Bool.false # testing for cats allergy allergic to everything expect - result = allergic_to Cats 255 + result = allergic_to(Cats, 255) result == Bool.true # list when: no allergies expect result = set 0 - result == Set.from_list [] + result == Set.from_list([]) # list when: just eggs expect result = set 1 - result == Set.from_list [Eggs] + result == Set.from_list([Eggs]) # list when: just peanuts expect result = set 2 - result == Set.from_list [Peanuts] + result == Set.from_list([Peanuts]) # list when: just strawberries expect result = set 8 - result == Set.from_list [Strawberries] + result == Set.from_list([Strawberries]) # list when: eggs and peanuts expect result = set 3 - result == Set.from_list [Eggs, Peanuts] + result == Set.from_list([Eggs, Peanuts]) # list when: more than eggs but not peanuts expect result = set 5 - result == Set.from_list [Eggs, Shellfish] + result == Set.from_list([Eggs, Shellfish]) # list when: lots of stuff expect result = set 248 - result == Set.from_list [Strawberries, Tomatoes, Chocolate, Pollen, Cats] + result == Set.from_list([Strawberries, Tomatoes, Chocolate, Pollen, Cats]) # list when: everything expect result = set 255 - result == Set.from_list [Eggs, Peanuts, Shellfish, Strawberries, Tomatoes, Chocolate, Pollen, Cats] + result == Set.from_list([Eggs, Peanuts, Shellfish, Strawberries, Tomatoes, Chocolate, Pollen, Cats]) # list when: no allergen score parts expect result = set 509 - result == Set.from_list [Eggs, Shellfish, Strawberries, Tomatoes, Chocolate, Pollen, Cats] + result == Set.from_list([Eggs, Shellfish, Strawberries, Tomatoes, Chocolate, Pollen, Cats]) # list when: no allergen score parts without highest valid score expect result = set 257 - result == Set.from_list [Eggs] + result == Set.from_list([Eggs]) diff --git a/exercises/practice/alphametics/.meta/template.j2 b/exercises/practice/alphametics/.meta/template.j2 index f4f34165..543145f4 100644 --- a/exercises/practice/alphametics/.meta/template.j2 +++ b/exercises/practice/alphametics/.meta/template.j2 @@ -9,13 +9,13 @@ import {{ exercise | to_pascal }} exposing [{{ cases[0]["property"] | to_snake } expect result = {{ case["property"] | to_snake }}({{ case["input"]["puzzle"] | to_roc }}) {%- if case["expected"] %} - Result.with_default result [] |> Set.from_list == Set.from_list [ + Result.with_default(result, []) |> Set.from_list == Set.from_list([ {%- for letter, value in case["expected"].items() %} ('{{ letter }}', {{ value }}), {%- endfor %} - ] + ]) {%- else %} - Result.is_err result + Result.is_err(result) {%- endif %} {% endfor %} diff --git a/exercises/practice/alphametics/alphametics-test.roc b/exercises/practice/alphametics/alphametics-test.roc index a8379de9..dd11bee3 100644 --- a/exercises/practice/alphametics/alphametics-test.roc +++ b/exercises/practice/alphametics/alphametics-test.roc @@ -15,125 +15,141 @@ import Alphametics exposing [solve] # puzzle with three letters expect result = solve("I + BB == ILL") - Result.with_default result [] + Result.with_default(result, []) |> Set.from_list - == Set.from_list [ - ('I', 1), - ('B', 9), - ('L', 0), - ] + == Set.from_list( + [ + ('I', 1), + ('B', 9), + ('L', 0), + ], + ) # solution must have unique value for each letter expect result = solve("A == B") - Result.is_err result + Result.is_err(result) # leading zero solution is invalid expect result = solve("ACA + DD == BD") - Result.is_err result + Result.is_err(result) # puzzle with two digits final carry expect result = solve("A + A + A + A + A + A + A + A + A + A + A + B == BCC") - Result.with_default result [] + Result.with_default(result, []) |> Set.from_list - == Set.from_list [ - ('A', 9), - ('B', 1), - ('C', 0), - ] + == Set.from_list( + [ + ('A', 9), + ('B', 1), + ('C', 0), + ], + ) # puzzle with four letters expect result = solve("AS + A == MOM") - Result.with_default result [] + Result.with_default(result, []) |> Set.from_list - == Set.from_list [ - ('A', 9), - ('S', 2), - ('M', 1), - ('O', 0), - ] + == Set.from_list( + [ + ('A', 9), + ('S', 2), + ('M', 1), + ('O', 0), + ], + ) # puzzle with six letters expect result = solve("NO + NO + TOO == LATE") - Result.with_default result [] + Result.with_default(result, []) |> Set.from_list - == Set.from_list [ - ('N', 7), - ('O', 4), - ('T', 9), - ('L', 1), - ('A', 0), - ('E', 2), - ] + == Set.from_list( + [ + ('N', 7), + ('O', 4), + ('T', 9), + ('L', 1), + ('A', 0), + ('E', 2), + ], + ) # puzzle with seven letters expect result = solve("HE + SEES + THE == LIGHT") - Result.with_default result [] + Result.with_default(result, []) |> Set.from_list - == Set.from_list [ - ('E', 4), - ('G', 2), - ('H', 5), - ('I', 0), - ('L', 1), - ('S', 9), - ('T', 7), - ] + == Set.from_list( + [ + ('E', 4), + ('G', 2), + ('H', 5), + ('I', 0), + ('L', 1), + ('S', 9), + ('T', 7), + ], + ) # puzzle with eight letters expect result = solve("SEND + MORE == MONEY") - Result.with_default result [] + Result.with_default(result, []) |> Set.from_list - == Set.from_list [ - ('S', 9), - ('E', 5), - ('N', 6), - ('D', 7), - ('M', 1), - ('O', 0), - ('R', 8), - ('Y', 2), - ] + == Set.from_list( + [ + ('S', 9), + ('E', 5), + ('N', 6), + ('D', 7), + ('M', 1), + ('O', 0), + ('R', 8), + ('Y', 2), + ], + ) # puzzle with ten letters expect result = solve("AND + A + STRONG + OFFENSE + AS + A + GOOD == DEFENSE") - Result.with_default result [] + Result.with_default(result, []) |> Set.from_list - == Set.from_list [ - ('A', 5), - ('D', 3), - ('E', 4), - ('F', 7), - ('G', 8), - ('N', 0), - ('O', 2), - ('R', 1), - ('S', 6), - ('T', 9), - ] + == Set.from_list( + [ + ('A', 5), + ('D', 3), + ('E', 4), + ('F', 7), + ('G', 8), + ('N', 0), + ('O', 2), + ('R', 1), + ('S', 6), + ('T', 9), + ], + ) # puzzle with ten letters and 199 addends expect result = solve("THIS + A + FIRE + THEREFORE + FOR + ALL + HISTORIES + I + TELL + A + TALE + THAT + FALSIFIES + ITS + TITLE + TIS + A + LIE + THE + TALE + OF + THE + LAST + FIRE + HORSES + LATE + AFTER + THE + FIRST + FATHERS + FORESEE + THE + HORRORS + THE + LAST + FREE + TROLL + TERRIFIES + THE + HORSES + OF + FIRE + THE + TROLL + RESTS + AT + THE + HOLE + OF + LOSSES + IT + IS + THERE + THAT + SHE + STORES + ROLES + OF + LEATHERS + AFTER + SHE + SATISFIES + HER + HATE + OFF + THOSE + FEARS + A + TASTE + RISES + AS + SHE + HEARS + THE + LEAST + FAR + HORSE + THOSE + FAST + HORSES + THAT + FIRST + HEAR + THE + TROLL + FLEE + OFF + TO + THE + FOREST + THE + HORSES + THAT + ALERTS + RAISE + THE + STARES + OF + THE + OTHERS + AS + THE + TROLL + ASSAILS + AT + THE + TOTAL + SHIFT + HER + TEETH + TEAR + HOOF + OFF + TORSO + AS + THE + LAST + HORSE + FORFEITS + ITS + LIFE + THE + FIRST + FATHERS + HEAR + OF + THE + HORRORS + THEIR + FEARS + THAT + THE + FIRES + FOR + THEIR + FEASTS + ARREST + AS + THE + FIRST + FATHERS + RESETTLE + THE + LAST + OF + THE + FIRE + HORSES + THE + LAST + TROLL + HARASSES + THE + FOREST + HEART + FREE + AT + LAST + OF + THE + LAST + TROLL + ALL + OFFER + THEIR + FIRE + HEAT + TO + THE + ASSISTERS + FAR + OFF + THE + TROLL + FASTS + ITS + LIFE + SHORTER + AS + STARS + RISE + THE + HORSES + REST + SAFE + AFTER + ALL + SHARE + HOT + FISH + AS + THEIR + AFFILIATES + TAILOR + A + ROOFS + FOR + THEIR + SAFE == FORTRESSES") - Result.with_default result [] + Result.with_default(result, []) |> Set.from_list - == Set.from_list [ - ('A', 1), - ('E', 0), - ('F', 5), - ('H', 8), - ('I', 7), - ('L', 2), - ('O', 6), - ('R', 3), - ('S', 4), - ('T', 9), - ] + == Set.from_list( + [ + ('A', 1), + ('E', 0), + ('F', 5), + ('H', 8), + ('I', 7), + ('L', 2), + ('O', 6), + ('R', 3), + ('S', 4), + ('T', 9), + ], + ) diff --git a/exercises/practice/atbash-cipher/.meta/template.j2 b/exercises/practice/atbash-cipher/.meta/template.j2 index 278ded24..5c7ae3ef 100644 --- a/exercises/practice/atbash-cipher/.meta/template.j2 +++ b/exercises/practice/atbash-cipher/.meta/template.j2 @@ -15,7 +15,7 @@ expect phrase = {{ case["input"]["phrase"] | to_roc }} result = phrase |> {{ case["property"] | to_snake }} expected = {{ case["expected"] | to_roc }} - result == Ok expected + result == Ok(expected) {% endfor %} {% endfor %} diff --git a/exercises/practice/atbash-cipher/atbash-cipher-test.roc b/exercises/practice/atbash-cipher/atbash-cipher-test.roc index 1faad3e4..a59e7034 100644 --- a/exercises/practice/atbash-cipher/atbash-cipher-test.roc +++ b/exercises/practice/atbash-cipher/atbash-cipher-test.roc @@ -21,56 +21,56 @@ expect phrase = "yes" result = phrase |> encode expected = "bvh" - result == Ok expected + result == Ok(expected) # encode no expect phrase = "no" result = phrase |> encode expected = "ml" - result == Ok expected + result == Ok(expected) # encode OMG expect phrase = "OMG" result = phrase |> encode expected = "lnt" - result == Ok expected + result == Ok(expected) # encode spaces expect phrase = "O M G" result = phrase |> encode expected = "lnt" - result == Ok expected + result == Ok(expected) # encode mindblowingly expect phrase = "mindblowingly" result = phrase |> encode expected = "nrmwy oldrm tob" - result == Ok expected + result == Ok(expected) # encode numbers expect phrase = "Testing,1 2 3, testing." result = phrase |> encode expected = "gvhgr mt123 gvhgr mt" - result == Ok expected + result == Ok(expected) # encode deep thought expect phrase = "Truth is fiction." result = phrase |> encode expected = "gifgs rhurx grlm" - result == Ok expected + result == Ok(expected) # encode all the letters expect phrase = "The quick brown fox jumps over the lazy dog." result = phrase |> encode expected = "gsvjf rxpyi ldmul cqfnk hlevi gsvoz abwlt" - result == Ok expected + result == Ok(expected) ## ## decode @@ -81,40 +81,40 @@ expect phrase = "vcvix rhn" result = phrase |> decode expected = "exercism" - result == Ok expected + result == Ok(expected) # decode a sentence expect phrase = "zmlyh gzxov rhlug vmzhg vkkrm thglm v" result = phrase |> decode expected = "anobstacleisoftenasteppingstone" - result == Ok expected + result == Ok(expected) # decode numbers expect phrase = "gvhgr mt123 gvhgr mt" result = phrase |> decode expected = "testing123testing" - result == Ok expected + result == Ok(expected) # decode all the letters expect phrase = "gsvjf rxpyi ldmul cqfnk hlevi gsvoz abwlt" result = phrase |> decode expected = "thequickbrownfoxjumpsoverthelazydog" - result == Ok expected + result == Ok(expected) # decode with too many spaces expect phrase = "vc vix r hn" result = phrase |> decode expected = "exercism" - result == Ok expected + result == Ok(expected) # decode with no spaces expect phrase = "zmlyhgzxovrhlugvmzhgvkkrmthglmv" result = phrase |> decode expected = "anobstacleisoftenasteppingstone" - result == Ok expected + result == Ok(expected) diff --git a/exercises/practice/binary-search-tree/.meta/template.j2 b/exercises/practice/binary-search-tree/.meta/template.j2 index 52fea611..1abf72ce 100644 --- a/exercises/practice/binary-search-tree/.meta/template.j2 +++ b/exercises/practice/binary-search-tree/.meta/template.j2 @@ -9,11 +9,11 @@ import {{ exercise | to_pascal }} exposing [from_list, to_list] {%- endmacro %} {% macro to_tree(tree) -%} -{% if tree is none %}Nil{% else %}Node { +{% if tree is none %}Nil{% else %}Node({ value: {{ tree["data"] }}, left: {{ to_tree(tree["left"]) }}, right: {{ to_tree(tree["right"]) }}, -}{% endif %} +}){% endif %} {%- endmacro %} {% for supercase in cases %} @@ -33,12 +33,12 @@ import {{ exercise | to_pascal }} exposing [from_list, to_list] expect data = {{ to_int_list(subcase["input"]["treeData"]) }} {%- if subcase["property"] == "data" %} - result = data |> from_list + result = from_list(data) expected = {{ to_tree(subcase["expected"]) }} result == expected {%- else %} - tree = data |> from_list - result = tree |> to_list + tree = from_list(data) + result = to_list(tree) expected = {{ to_int_list(subcase["expected"]) }} result == expected {%- endif %} diff --git a/exercises/practice/binary-search-tree/binary-search-tree-test.roc b/exercises/practice/binary-search-tree/binary-search-tree-test.roc index 4503312c..2348f304 100644 --- a/exercises/practice/binary-search-tree/binary-search-tree-test.roc +++ b/exercises/practice/binary-search-tree/binary-search-tree-test.roc @@ -18,12 +18,14 @@ import BinarySearchTree exposing [from_list, to_list] expect data = [4] - result = data |> from_list - expected = Node { - value: 4, - left: Nil, - right: Nil, - } + result = from_list(data) + expected = Node( + { + value: 4, + left: Nil, + right: Nil, + }, + ) result == expected ## @@ -33,46 +35,58 @@ expect # smaller number at left node expect data = [4, 2] - result = data |> from_list - expected = Node { - value: 4, - left: Node { - value: 2, - left: Nil, + result = from_list(data) + expected = Node( + { + value: 4, + left: Node( + { + value: 2, + left: Nil, + right: Nil, + }, + ), right: Nil, }, - right: Nil, - } + ) result == expected # same number at left node expect data = [4, 4] - result = data |> from_list - expected = Node { - value: 4, - left: Node { + result = from_list(data) + expected = Node( + { value: 4, - left: Nil, + left: Node( + { + value: 4, + left: Nil, + right: Nil, + }, + ), right: Nil, }, - right: Nil, - } + ) result == expected # greater number at right node expect data = [4, 5] - result = data |> from_list - expected = Node { - value: 4, - left: Nil, - right: Node { - value: 5, + result = from_list(data) + expected = Node( + { + value: 4, left: Nil, - right: Nil, + right: Node( + { + value: 5, + left: Nil, + right: Nil, + }, + ), }, - } + ) result == expected ## @@ -81,36 +95,50 @@ expect expect data = [4, 2, 6, 1, 3, 5, 7] - result = data |> from_list - expected = Node { - value: 4, - left: Node { - value: 2, - left: Node { - value: 1, - left: Nil, - right: Nil, - }, - right: Node { - value: 3, - left: Nil, - right: Nil, - }, - }, - right: Node { - value: 6, - left: Node { - value: 5, - left: Nil, - right: Nil, - }, - right: Node { - value: 7, - left: Nil, - right: Nil, - }, + result = from_list(data) + expected = Node( + { + value: 4, + left: Node( + { + value: 2, + left: Node( + { + value: 1, + left: Nil, + right: Nil, + }, + ), + right: Node( + { + value: 3, + left: Nil, + right: Nil, + }, + ), + }, + ), + right: Node( + { + value: 6, + left: Node( + { + value: 5, + left: Nil, + right: Nil, + }, + ), + right: Node( + { + value: 7, + left: Nil, + right: Nil, + }, + ), + }, + ), }, - } + ) result == expected ## @@ -120,40 +148,40 @@ expect # can sort single number expect data = [2] - tree = data |> from_list - result = tree |> to_list + tree = from_list(data) + result = to_list(tree) expected = [2] result == expected # can sort if second number is smaller than first expect data = [2, 1] - tree = data |> from_list - result = tree |> to_list + tree = from_list(data) + result = to_list(tree) expected = [1, 2] result == expected # can sort if second number is same as first expect data = [2, 2] - tree = data |> from_list - result = tree |> to_list + tree = from_list(data) + result = to_list(tree) expected = [2, 2] result == expected # can sort if second number is greater than first expect data = [2, 3] - tree = data |> from_list - result = tree |> to_list + tree = from_list(data) + result = to_list(tree) expected = [2, 3] result == expected # can sort complex tree expect data = [2, 1, 3, 6, 7, 5] - tree = data |> from_list - result = tree |> to_list + tree = from_list(data) + result = to_list(tree) expected = [1, 2, 3, 5, 6, 7] result == expected diff --git a/exercises/practice/binary-search/.meta/template.j2 b/exercises/practice/binary-search/.meta/template.j2 index edb9f6d2..c24afc3a 100644 --- a/exercises/practice/binary-search/.meta/template.j2 +++ b/exercises/practice/binary-search/.meta/template.j2 @@ -9,9 +9,9 @@ import {{ exercise | to_pascal }} exposing [{{ cases[0]["property"] | to_snake } expect result = {{ case["input"]["array"] | to_roc }} |> {{ case["property"] | to_snake }}({{ case["input"]["value"] }}) {%- if case["expected"]["error"] %} - Result.is_err result + Result.is_err(result) {%- else %} - result == Ok {{ case["expected"] }} + result == Ok({{ case["expected"] }}) {%- endif %} {% endfor %} diff --git a/exercises/practice/binary-search/binary-search-test.roc b/exercises/practice/binary-search/binary-search-test.roc index 1d62a912..e0cb6353 100644 --- a/exercises/practice/binary-search/binary-search-test.roc +++ b/exercises/practice/binary-search/binary-search-test.roc @@ -15,55 +15,55 @@ import BinarySearch exposing [find] # finds a value in an array with one element expect result = [6] |> find(6) - result == Ok 0 + result == Ok(0) # finds a value in the middle of an array expect result = [1, 3, 4, 6, 8, 9, 11] |> find(6) - result == Ok 3 + result == Ok(3) # finds a value at the beginning of an array expect result = [1, 3, 4, 6, 8, 9, 11] |> find(1) - result == Ok 0 + result == Ok(0) # finds a value at the end of an array expect result = [1, 3, 4, 6, 8, 9, 11] |> find(11) - result == Ok 6 + result == Ok(6) # finds a value in an array of odd length expect result = [1, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 634] |> find(144) - result == Ok 9 + result == Ok(9) # finds a value in an array of even length expect result = [1, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377] |> find(21) - result == Ok 5 + result == Ok(5) # identifies that a value is not included in the array expect result = [1, 3, 4, 6, 8, 9, 11] |> find(7) - Result.is_err result + Result.is_err(result) # a value smaller than the array's smallest value is not found expect result = [1, 3, 4, 6, 8, 9, 11] |> find(0) - Result.is_err result + Result.is_err(result) # a value larger than the array's largest value is not found expect result = [1, 3, 4, 6, 8, 9, 11] |> find(13) - Result.is_err result + Result.is_err(result) # nothing is found in an empty array expect result = [] |> find(1) - Result.is_err result + Result.is_err(result) # nothing is found when the left and right bounds cross expect result = [1, 2] |> find(0) - Result.is_err result + Result.is_err(result) diff --git a/exercises/practice/binary/.meta/template.j2 b/exercises/practice/binary/.meta/template.j2 index b06b884c..4cca58ab 100644 --- a/exercises/practice/binary/.meta/template.j2 +++ b/exercises/practice/binary/.meta/template.j2 @@ -9,7 +9,7 @@ import {{ exercise | to_pascal }} exposing [{{ cases[0]["property"] | to_snake } expect result = {{ case["property"] | to_snake }}({{ case["input"]["binary"] | to_roc }}) {%- if case["expected"] is not none %} - result == Ok {{ case["expected"] | to_roc }} + result == Ok({{ case["expected"] | to_roc }}) {%- else %} result |> Result.is_err {%- endif %} diff --git a/exercises/practice/binary/binary-test.roc b/exercises/practice/binary/binary-test.roc index a9c9115f..f6095ef0 100644 --- a/exercises/practice/binary/binary-test.roc +++ b/exercises/practice/binary/binary-test.roc @@ -15,47 +15,47 @@ import Binary exposing [decimal] # binary 0 is decimal 0 expect result = decimal("0") - result == Ok 0 + result == Ok(0) # binary 1 is decimal 1 expect result = decimal("1") - result == Ok 1 + result == Ok(1) # binary 10 is decimal 2 expect result = decimal("10") - result == Ok 2 + result == Ok(2) # binary 11 is decimal 3 expect result = decimal("11") - result == Ok 3 + result == Ok(3) # binary 100 is decimal 4 expect result = decimal("100") - result == Ok 4 + result == Ok(4) # binary 1001 is decimal 9 expect result = decimal("1001") - result == Ok 9 + result == Ok(9) # binary 11010 is decimal 26 expect result = decimal("11010") - result == Ok 26 + result == Ok(26) # binary 10001101000 is decimal 1128 expect result = decimal("10001101000") - result == Ok 1128 + result == Ok(1128) # binary ignores leading zeros expect result = decimal("000011111") - result == Ok 31 + result == Ok(31) # 2 is not a valid binary digit expect diff --git a/exercises/practice/bowling/.meta/template.j2 b/exercises/practice/bowling/.meta/template.j2 index 48cd54d8..e462a07d 100644 --- a/exercises/practice/bowling/.meta/template.j2 +++ b/exercises/practice/bowling/.meta/template.j2 @@ -6,16 +6,19 @@ import {{ exercise | to_pascal }} exposing [Game, create, roll, score] replay_game : List U64 -> Result Game _ replay_game = |rolls| - new_game = create? {} + new_game = create({})? rolls - |> List.walk_until (Ok new_game) \state, pins -> - when state is - Ok game -> - when game |> roll pins is - Ok updated_game -> Continue (Ok updated_game) - Err err -> Break (Err err) + |> List.walk_until( + Ok(new_game), + |state, pins| + when state is + Ok(game) -> + when game |> roll(pins) is + Ok(updated_game) -> Continue(Ok(updated_game)) + Err(err) -> Break(Err(err)) - Err _ -> crash "Impossible, we don't start or Continue with an Err" + Err(_) -> crash "Impossible, we don't start or Continue with an Err" + ) {% for case in cases -%} @@ -23,10 +26,10 @@ replay_game = |rolls| expect maybe_game = create { previous_rolls : {{ case["input"]["previousRolls"] | to_roc }} } {%- if case["property"] == "score" %} - result = maybe_game |> Result.try |game| score(game) + result = maybe_game |> Result.try(|game| score(game)) {%- else %} - result = maybe_game |> Result.try |game| - game |> {{ case["property"] | to_snake }}({{ case["input"]["roll"] }}) + result = maybe_game |> Result.try(|game| + game |> {{ case["property"] | to_snake }}({{ case["input"]["roll"] }})) {%- endif %} {%- if case["expected"]["error"] %} result |> Result.is_err diff --git a/exercises/practice/bowling/bowling-test.roc b/exercises/practice/bowling/bowling-test.roc index 0ced72ec..26e7f410 100644 --- a/exercises/practice/bowling/bowling-test.roc +++ b/exercises/practice/bowling/bowling-test.roc @@ -14,21 +14,24 @@ import Bowling exposing [Game, create, roll, score] replay_game : List U64 -> Result Game _ replay_game = |rolls| - new_game = create? {} + new_game = create({})? rolls - |> List.walk_until (Ok new_game) |state, pins| - when state is - Ok game -> - when game |> roll pins is - Ok updated_game -> Continue (Ok updated_game) - Err err -> Break (Err err) - - Err _ -> crash "Impossible, we don't start or Continue with an Err" + |> List.walk_until( + Ok(new_game), + |state, pins| + when state is + Ok(game) -> + when game |> roll(pins) is + Ok(updated_game) -> Continue(Ok(updated_game)) + Err(err) -> Break(Err(err)) + + Err(_) -> crash "Impossible, we don't start or Continue with an Err", + ) # should be able to score a game with all zeros expect maybe_game = create { previous_rolls: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] } - result = maybe_game |> Result.try |game| score(game) + result = maybe_game |> Result.try(|game| score(game)) result == Ok(0) # should be able to replay this finished game from the start @@ -40,7 +43,7 @@ expect # should be able to score a game with no strikes or spares expect maybe_game = create { previous_rolls: [3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6] } - result = maybe_game |> Result.try |game| score(game) + result = maybe_game |> Result.try(|game| score(game)) result == Ok(90) # should be able to replay this finished game from the start @@ -52,7 +55,7 @@ expect # a spare followed by zeros is worth ten points expect maybe_game = create { previous_rolls: [6, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] } - result = maybe_game |> Result.try |game| score(game) + result = maybe_game |> Result.try(|game| score(game)) result == Ok(10) # should be able to replay this finished game from the start @@ -64,7 +67,7 @@ expect # points scored in the roll after a spare are counted twice expect maybe_game = create { previous_rolls: [6, 4, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] } - result = maybe_game |> Result.try |game| score(game) + result = maybe_game |> Result.try(|game| score(game)) result == Ok(16) # should be able to replay this finished game from the start @@ -76,7 +79,7 @@ expect # consecutive spares each get a one roll bonus expect maybe_game = create { previous_rolls: [5, 5, 3, 7, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] } - result = maybe_game |> Result.try |game| score(game) + result = maybe_game |> Result.try(|game| score(game)) result == Ok(31) # should be able to replay this finished game from the start @@ -88,7 +91,7 @@ expect # a spare in the last frame gets a one roll bonus that is counted once expect maybe_game = create { previous_rolls: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 3, 7] } - result = maybe_game |> Result.try |game| score(game) + result = maybe_game |> Result.try(|game| score(game)) result == Ok(17) # should be able to replay this finished game from the start @@ -100,7 +103,7 @@ expect # a strike earns ten points in a frame with a single roll expect maybe_game = create { previous_rolls: [10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] } - result = maybe_game |> Result.try |game| score(game) + result = maybe_game |> Result.try(|game| score(game)) result == Ok(10) # should be able to replay this finished game from the start @@ -112,7 +115,7 @@ expect # points scored in the two rolls after a strike are counted twice as a bonus expect maybe_game = create { previous_rolls: [10, 5, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] } - result = maybe_game |> Result.try |game| score(game) + result = maybe_game |> Result.try(|game| score(game)) result == Ok(26) # should be able to replay this finished game from the start @@ -124,7 +127,7 @@ expect # consecutive strikes each get the two roll bonus expect maybe_game = create { previous_rolls: [10, 10, 10, 5, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] } - result = maybe_game |> Result.try |game| score(game) + result = maybe_game |> Result.try(|game| score(game)) result == Ok(81) # should be able to replay this finished game from the start @@ -136,7 +139,7 @@ expect # a strike in the last frame gets a two roll bonus that is counted once expect maybe_game = create { previous_rolls: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 7, 1] } - result = maybe_game |> Result.try |game| score(game) + result = maybe_game |> Result.try(|game| score(game)) result == Ok(18) # should be able to replay this finished game from the start @@ -148,7 +151,7 @@ expect # rolling a spare with the two roll bonus does not get a bonus roll expect maybe_game = create { previous_rolls: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 7, 3] } - result = maybe_game |> Result.try |game| score(game) + result = maybe_game |> Result.try(|game| score(game)) result == Ok(20) # should be able to replay this finished game from the start @@ -160,7 +163,7 @@ expect # strikes with the two roll bonus do not get bonus rolls expect maybe_game = create { previous_rolls: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 10, 10] } - result = maybe_game |> Result.try |game| score(game) + result = maybe_game |> Result.try(|game| score(game)) result == Ok(30) # should be able to replay this finished game from the start @@ -172,7 +175,7 @@ expect # last two strikes followed by only last bonus with non strike points expect maybe_game = create { previous_rolls: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 10, 0, 1] } - result = maybe_game |> Result.try |game| score(game) + result = maybe_game |> Result.try(|game| score(game)) result == Ok(31) # should be able to replay this finished game from the start @@ -184,7 +187,7 @@ expect # a strike with the one roll bonus after a spare in the last frame does not get a bonus expect maybe_game = create { previous_rolls: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 3, 10] } - result = maybe_game |> Result.try |game| score(game) + result = maybe_game |> Result.try(|game| score(game)) result == Ok(20) # should be able to replay this finished game from the start @@ -196,7 +199,7 @@ expect # all strikes is a perfect game expect maybe_game = create { previous_rolls: [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10] } - result = maybe_game |> Result.try |game| score(game) + result = maybe_game |> Result.try(|game| score(game)) result == Ok(300) # should be able to replay this finished game from the start @@ -210,8 +213,10 @@ expect maybe_game = create { previous_rolls: [] } result = maybe_game - |> Result.try |game| - game |> roll(11) + |> Result.try( + |game| + game |> roll(11), + ) result |> Result.is_err # two rolls in a frame cannot score more than 10 points @@ -219,8 +224,10 @@ expect maybe_game = create { previous_rolls: [5] } result = maybe_game - |> Result.try |game| - game |> roll(6) + |> Result.try( + |game| + game |> roll(6), + ) result |> Result.is_err # bonus roll after a strike in the last frame cannot score more than 10 points @@ -228,8 +235,10 @@ expect maybe_game = create { previous_rolls: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10] } result = maybe_game - |> Result.try |game| - game |> roll(11) + |> Result.try( + |game| + game |> roll(11), + ) result |> Result.is_err # two bonus rolls after a strike in the last frame cannot score more than 10 points @@ -237,14 +246,16 @@ expect maybe_game = create { previous_rolls: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 5] } result = maybe_game - |> Result.try |game| - game |> roll(6) + |> Result.try( + |game| + game |> roll(6), + ) result |> Result.is_err # two bonus rolls after a strike in the last frame can score more than 10 points if one is a strike expect maybe_game = create { previous_rolls: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 10, 6] } - result = maybe_game |> Result.try |game| score(game) + result = maybe_game |> Result.try(|game| score(game)) result == Ok(26) # should be able to replay this finished game from the start @@ -258,8 +269,10 @@ expect maybe_game = create { previous_rolls: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 6] } result = maybe_game - |> Result.try |game| - game |> roll(10) + |> Result.try( + |game| + game |> roll(10), + ) result |> Result.is_err # second bonus roll after a strike in the last frame cannot score more than 10 points @@ -267,20 +280,22 @@ expect maybe_game = create { previous_rolls: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 10] } result = maybe_game - |> Result.try |game| - game |> roll(11) + |> Result.try( + |game| + game |> roll(11), + ) result |> Result.is_err # an unstarted game cannot be scored expect maybe_game = create { previous_rolls: [] } - result = maybe_game |> Result.try |game| score(game) + result = maybe_game |> Result.try(|game| score(game)) result |> Result.is_err # an incomplete game cannot be scored expect maybe_game = create { previous_rolls: [0, 0] } - result = maybe_game |> Result.try |game| score(game) + result = maybe_game |> Result.try(|game| score(game)) result |> Result.is_err # cannot roll if game already has ten frames @@ -288,26 +303,28 @@ expect maybe_game = create { previous_rolls: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] } result = maybe_game - |> Result.try |game| - game |> roll(0) + |> Result.try( + |game| + game |> roll(0), + ) result |> Result.is_err # bonus rolls for a strike in the last frame must be rolled before score can be calculated expect maybe_game = create { previous_rolls: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10] } - result = maybe_game |> Result.try |game| score(game) + result = maybe_game |> Result.try(|game| score(game)) result |> Result.is_err # both bonus rolls for a strike in the last frame must be rolled before score can be calculated expect maybe_game = create { previous_rolls: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 10] } - result = maybe_game |> Result.try |game| score(game) + result = maybe_game |> Result.try(|game| score(game)) result |> Result.is_err # bonus roll for a spare in the last frame must be rolled before score can be calculated expect maybe_game = create { previous_rolls: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 3] } - result = maybe_game |> Result.try |game| score(game) + result = maybe_game |> Result.try(|game| score(game)) result |> Result.is_err # cannot roll after bonus roll for spare @@ -315,8 +332,10 @@ expect maybe_game = create { previous_rolls: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 3, 2] } result = maybe_game - |> Result.try |game| - game |> roll(2) + |> Result.try( + |game| + game |> roll(2), + ) result |> Result.is_err # cannot roll after bonus rolls for strike @@ -324,7 +343,9 @@ expect maybe_game = create { previous_rolls: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 3, 2] } result = maybe_game - |> Result.try |game| - game |> roll(2) + |> Result.try( + |game| + game |> roll(2), + ) result |> Result.is_err diff --git a/exercises/practice/change/.meta/template.j2 b/exercises/practice/change/.meta/template.j2 index 372bf523..1aa34c3d 100644 --- a/exercises/practice/change/.meta/template.j2 +++ b/exercises/practice/change/.meta/template.j2 @@ -12,7 +12,7 @@ expect {%- if case["expected"]["error"] %} result |> Result.is_err {%- else %} - result == Ok {{ case["expected"] | to_roc }} + result == Ok({{ case["expected"] | to_roc }}) {%- endif %} {% endfor %} diff --git a/exercises/practice/change/change-test.roc b/exercises/practice/change/change-test.roc index 3f1bf081..f50911bf 100644 --- a/exercises/practice/change/change-test.roc +++ b/exercises/practice/change/change-test.roc @@ -16,61 +16,61 @@ import Change exposing [find_fewest_coins] expect coins = [1, 5, 10, 25] result = coins |> find_fewest_coins(1) - result == Ok [1] + result == Ok([1]) # single coin change expect coins = [1, 5, 10, 25, 100] result = coins |> find_fewest_coins(25) - result == Ok [25] + result == Ok([25]) # multiple coin change expect coins = [1, 5, 10, 25, 100] result = coins |> find_fewest_coins(15) - result == Ok [5, 10] + result == Ok([5, 10]) # change with Lilliputian Coins expect coins = [1, 4, 15, 20, 50] result = coins |> find_fewest_coins(23) - result == Ok [4, 4, 15] + result == Ok([4, 4, 15]) # change with Lower Elbonia Coins expect coins = [1, 5, 10, 21, 25] result = coins |> find_fewest_coins(63) - result == Ok [21, 21, 21] + result == Ok([21, 21, 21]) # large target values expect coins = [1, 2, 5, 10, 20, 50, 100] result = coins |> find_fewest_coins(999) - result == Ok [2, 2, 5, 20, 20, 50, 100, 100, 100, 100, 100, 100, 100, 100, 100] + result == Ok([2, 2, 5, 20, 20, 50, 100, 100, 100, 100, 100, 100, 100, 100, 100]) # possible change without unit coins available expect coins = [2, 5, 10, 20, 50] result = coins |> find_fewest_coins(21) - result == Ok [2, 2, 2, 5, 10] + result == Ok([2, 2, 2, 5, 10]) # another possible change without unit coins available expect coins = [4, 5] result = coins |> find_fewest_coins(27) - result == Ok [4, 4, 4, 5, 5, 5] + result == Ok([4, 4, 4, 5, 5, 5]) # a greedy approach is not optimal expect coins = [1, 10, 11] result = coins |> find_fewest_coins(20) - result == Ok [10, 10] + result == Ok([10, 10]) # no coins make 0 change expect coins = [1, 5, 10, 21, 25] result = coins |> find_fewest_coins(0) - result == Ok [] + result == Ok([]) # error testing for change smaller than the smallest of coins expect diff --git a/exercises/practice/circular-buffer/.meta/template.j2 b/exercises/practice/circular-buffer/.meta/template.j2 index 6a9ce081..38f60295 100644 --- a/exercises/practice/circular-buffer/.meta/template.j2 +++ b/exercises/practice/circular-buffer/.meta/template.j2 @@ -36,7 +36,7 @@ run_operations{{ loop.index }} = |_| {%- endif %} {%- endif %} {%- endfor %} - Ok result + Ok(result) expect diff --git a/exercises/practice/circular-buffer/circular-buffer-test.roc b/exercises/practice/circular-buffer/circular-buffer-test.roc index eedfe246..303fa32e 100644 --- a/exercises/practice/circular-buffer/circular-buffer-test.roc +++ b/exercises/practice/circular-buffer/circular-buffer-test.roc @@ -20,7 +20,7 @@ run_operations1 = |_| read_result = buffer_before_read |> read expect read_result == Err BufferEmpty buffer_before_read - Ok result + Ok(result) expect result = run_operations1 {} @@ -35,7 +35,7 @@ run_operations2 = |_| |> |read_result| expect read_result.value == 1 read_result.new_buffer - Ok result + Ok(result) expect result = run_operations2 {} @@ -54,7 +54,7 @@ run_operations3 = |_| read_result = buffer_before_read |> read expect read_result == Err BufferEmpty buffer_before_read - Ok result + Ok(result) expect result = run_operations3 {} @@ -74,7 +74,7 @@ run_operations4 = |_| |> |read_result| expect read_result.value == 2 read_result.new_buffer - Ok result + Ok(result) expect result = run_operations4 {} @@ -89,7 +89,7 @@ run_operations5 = |_| write_result = buffer_before_write |> write 2 expect write_result == Err BufferFull buffer_before_write - Ok result + Ok(result) expect result = run_operations5 {} @@ -109,7 +109,7 @@ run_operations6 = |_| |> |read_result| expect read_result.value == 2 read_result.new_buffer - Ok result + Ok(result) expect result = run_operations6 {} @@ -134,7 +134,7 @@ run_operations7 = |_| |> |read_result| expect read_result.value == 3 read_result.new_buffer - Ok result + Ok(result) expect result = run_operations7 {} @@ -150,7 +150,7 @@ run_operations8 = |_| read_result = buffer_before_read |> read expect read_result == Err BufferEmpty buffer_before_read - Ok result + Ok(result) expect result = run_operations8 {} @@ -167,7 +167,7 @@ run_operations9 = |_| |> |read_result| expect read_result.value == 2 read_result.new_buffer - Ok result + Ok(result) expect result = run_operations9 {} @@ -183,7 +183,7 @@ run_operations10 = |_| |> |read_result| expect read_result.value == 1 read_result.new_buffer - Ok result + Ok(result) expect result = run_operations10 {} @@ -203,7 +203,7 @@ run_operations11 = |_| |> |read_result| expect read_result.value == 2 read_result.new_buffer - Ok result + Ok(result) expect result = run_operations11 {} @@ -224,7 +224,7 @@ run_operations12 = |_| |> |read_result| expect read_result.value == 3 read_result.new_buffer - Ok result + Ok(result) expect result = run_operations12 {} @@ -255,7 +255,7 @@ run_operations13 = |_| |> |read_result| expect read_result.value == 5 read_result.new_buffer - Ok result + Ok(result) expect result = run_operations13 {} @@ -282,7 +282,7 @@ run_operations14 = |_| read_result = buffer_before_read |> read expect read_result == Err BufferEmpty buffer_before_read - Ok result + Ok(result) expect result = run_operations14 {} diff --git a/exercises/practice/collatz-conjecture/.meta/template.j2 b/exercises/practice/collatz-conjecture/.meta/template.j2 index 5859e457..2b3056fd 100644 --- a/exercises/practice/collatz-conjecture/.meta/template.j2 +++ b/exercises/practice/collatz-conjecture/.meta/template.j2 @@ -11,7 +11,7 @@ expect {%- if case["expected"]["error"] %} Result.is_err result {%- else %} - result == Ok {{ case["expected"] }} + result == Ok({{ case["expected"] }}) {%- endif %} {% endfor %} diff --git a/exercises/practice/collatz-conjecture/collatz-conjecture-test.roc b/exercises/practice/collatz-conjecture/collatz-conjecture-test.roc index 54bb20f8..053f7e10 100644 --- a/exercises/practice/collatz-conjecture/collatz-conjecture-test.roc +++ b/exercises/practice/collatz-conjecture/collatz-conjecture-test.roc @@ -15,22 +15,22 @@ import CollatzConjecture exposing [steps] # zero steps for one expect result = steps(1) - result == Ok 0 + result == Ok(0) # divide if even expect result = steps(16) - result == Ok 4 + result == Ok(4) # even and odd steps expect result = steps(12) - result == Ok 9 + result == Ok(9) # large number of even and odd steps expect result = steps(1000000) - result == Ok 152 + result == Ok(152) # zero is an error expect diff --git a/exercises/practice/connect/.meta/template.j2 b/exercises/practice/connect/.meta/template.j2 index 097deb01..34fb2ad5 100644 --- a/exercises/practice/connect/.meta/template.j2 +++ b/exercises/practice/connect/.meta/template.j2 @@ -9,6 +9,6 @@ import {{ exercise | to_pascal }} exposing [{{ cases[0]["property"] | to_snake } expect board = {{ case["input"]["board"] | to_roc_multiline_string | indent(8) }} result = board |> {{ case["property"] | to_snake }} - result == {% if case["expected"] == "" %}Err NotFinished{% else %}Ok Player{{ case["expected"] }}{% endif %} + result == {% if case["expected"] == "" %}Err NotFinished{% else %}Ok(Player{{ case["expected"] }}){% endif %} {% endfor %} diff --git a/exercises/practice/connect/connect-test.roc b/exercises/practice/connect/connect-test.roc index de464c8d..b558dc0d 100644 --- a/exercises/practice/connect/connect-test.roc +++ b/exercises/practice/connect/connect-test.roc @@ -29,13 +29,13 @@ expect expect board = "X" result = board |> winner - result == Ok PlayerX + result == Ok(PlayerX) # O can win on a 1x1 board expect board = "O" result = board |> winner - result == Ok PlayerO + result == Ok(PlayerO) # only edges does not make a winner expect @@ -86,7 +86,7 @@ expect . O X . """ result = board |> winner - result == Ok PlayerX + result == Ok(PlayerX) # O wins crossing from top to bottom expect @@ -99,7 +99,7 @@ expect . O X . """ result = board |> winner - result == Ok PlayerO + result == Ok(PlayerO) # X wins using a convoluted path expect @@ -112,7 +112,7 @@ expect O O O O O """ result = board |> winner - result == Ok PlayerX + result == Ok(PlayerX) # X wins using a spiral path expect @@ -129,5 +129,5 @@ expect X X X X X X X X O """ result = board |> winner - result == Ok PlayerX + result == Ok(PlayerX) diff --git a/exercises/practice/dominoes/.meta/template.j2 b/exercises/practice/dominoes/.meta/template.j2 index cf99838e..404a592f 100644 --- a/exercises/practice/dominoes/.meta/template.j2 +++ b/exercises/practice/dominoes/.meta/template.j2 @@ -26,21 +26,24 @@ canonicalize = |dominoes| is_valid_chain_for : Result (List Domino) _, List Domino -> Bool is_valid_chain_for = |maybeChain, dominoes| when maybeChain is - Err _ -> Bool.false - Ok chain -> - if Set.from_list (canonicalize chain) == Set.from_list (canonicalize dominoes) then + Err(_) -> Bool.false + Ok(chain) -> + if Set.from_list(canonicalize chain) == Set.from_list(canonicalize dominoes) then when chain is [] -> Bool.true [.., last] -> chain - |> List.walk_until (Ok last) \state, domino -> - when state is - Err InvalidChain -> crash "Unreachable" - Ok previous -> - if previous.1 == domino.0 then - Continue (Ok domino) - else - Break (Err InvalidChain) + |> List.walk_until( + Ok(last), + |state, domino| + when state is + Err(InvalidChain) -> crash "Unreachable" + Ok(previous) -> + if previous.1 == domino.0 then + Continue(Ok(domino)) + else + Break(Err(InvalidChain)) + ) |> Result.is_ok else Bool.false @@ -48,9 +51,9 @@ is_valid_chain_for = |maybeChain, dominoes| {% for case in cases -%} # {{ case["description"] }} expect - result = find_chain {{ to_list_of_pairs(case["input"]["dominoes"]) }} + result = find_chain({{ to_list_of_pairs(case["input"]["dominoes"]) }}) {%- if case["expected"] %} - result |> is_valid_chain_for {{ to_list_of_pairs(case["input"]["dominoes"]) }} + result |> is_valid_chain_for({{ to_list_of_pairs(case["input"]["dominoes"]) }}) {%- else %} result |> Result.is_err {%- endif %} diff --git a/exercises/practice/dominoes/dominoes-test.roc b/exercises/practice/dominoes/dominoes-test.roc index 4fdfae62..29045d22 100644 --- a/exercises/practice/dominoes/dominoes-test.roc +++ b/exercises/practice/dominoes/dominoes-test.roc @@ -26,87 +26,90 @@ canonicalize = |dominoes| is_valid_chain_for : Result (List Domino) _, List Domino -> Bool is_valid_chain_for = |maybeChain, dominoes| when maybeChain is - Err _ -> Bool.false - Ok chain -> - if Set.from_list (canonicalize chain) == Set.from_list (canonicalize dominoes) then + Err(_) -> Bool.false + Ok(chain) -> + if Set.from_list(canonicalize chain) == Set.from_list(canonicalize dominoes) then when chain is [] -> Bool.true [.., last] -> chain - |> List.walk_until (Ok last) |state, domino| - when state is - Err InvalidChain -> crash "Unreachable" - Ok previous -> - if previous.1 == domino.0 then - Continue (Ok domino) - else - Break (Err InvalidChain) + |> List.walk_until( + Ok(last), + |state, domino| + when state is + Err(InvalidChain) -> crash "Unreachable" + Ok(previous) -> + if previous.1 == domino.0 then + Continue(Ok(domino)) + else + Break(Err(InvalidChain)), + ) |> Result.is_ok else Bool.false # empty input = empty output expect - result = find_chain [] - result |> is_valid_chain_for [] + result = find_chain([]) + result |> is_valid_chain_for([]) # singleton input = singleton output expect - result = find_chain [(1, 1)] - result |> is_valid_chain_for [(1, 1)] + result = find_chain([(1, 1)]) + result |> is_valid_chain_for([(1, 1)]) # singleton that can't be chained expect - result = find_chain [(1, 2)] + result = find_chain([(1, 2)]) result |> Result.is_err # three elements expect - result = find_chain [(1, 2), (3, 1), (2, 3)] - result |> is_valid_chain_for [(1, 2), (3, 1), (2, 3)] + result = find_chain([(1, 2), (3, 1), (2, 3)]) + result |> is_valid_chain_for([(1, 2), (3, 1), (2, 3)]) # can reverse dominoes expect - result = find_chain [(1, 2), (1, 3), (2, 3)] - result |> is_valid_chain_for [(1, 2), (1, 3), (2, 3)] + result = find_chain([(1, 2), (1, 3), (2, 3)]) + result |> is_valid_chain_for([(1, 2), (1, 3), (2, 3)]) # can't be chained expect - result = find_chain [(1, 2), (4, 1), (2, 3)] + result = find_chain([(1, 2), (4, 1), (2, 3)]) result |> Result.is_err # disconnected - simple expect - result = find_chain [(1, 1), (2, 2)] + result = find_chain([(1, 1), (2, 2)]) result |> Result.is_err # disconnected - double loop expect - result = find_chain [(1, 2), (2, 1), (3, 4), (4, 3)] + result = find_chain([(1, 2), (2, 1), (3, 4), (4, 3)]) result |> Result.is_err # disconnected - single isolated expect - result = find_chain [(1, 2), (2, 3), (3, 1), (4, 4)] + result = find_chain([(1, 2), (2, 3), (3, 1), (4, 4)]) result |> Result.is_err # need backtrack expect - result = find_chain [(1, 2), (2, 3), (3, 1), (2, 4), (2, 4)] - result |> is_valid_chain_for [(1, 2), (2, 3), (3, 1), (2, 4), (2, 4)] + result = find_chain([(1, 2), (2, 3), (3, 1), (2, 4), (2, 4)]) + result |> is_valid_chain_for([(1, 2), (2, 3), (3, 1), (2, 4), (2, 4)]) # separate loops expect - result = find_chain [(1, 2), (2, 3), (3, 1), (1, 1), (2, 2), (3, 3)] - result |> is_valid_chain_for [(1, 2), (2, 3), (3, 1), (1, 1), (2, 2), (3, 3)] + result = find_chain([(1, 2), (2, 3), (3, 1), (1, 1), (2, 2), (3, 3)]) + result |> is_valid_chain_for([(1, 2), (2, 3), (3, 1), (1, 1), (2, 2), (3, 3)]) # nine elements expect - result = find_chain [(1, 2), (5, 3), (3, 1), (1, 2), (2, 4), (1, 6), (2, 3), (3, 4), (5, 6)] - result |> is_valid_chain_for [(1, 2), (5, 3), (3, 1), (1, 2), (2, 4), (1, 6), (2, 3), (3, 4), (5, 6)] + result = find_chain([(1, 2), (5, 3), (3, 1), (1, 2), (2, 4), (1, 6), (2, 3), (3, 4), (5, 6)]) + result |> is_valid_chain_for([(1, 2), (5, 3), (3, 1), (1, 2), (2, 4), (1, 6), (2, 3), (3, 4), (5, 6)]) # separate three-domino loops expect - result = find_chain [(1, 2), (2, 3), (3, 1), (4, 5), (5, 6), (6, 4)] + result = find_chain([(1, 2), (2, 3), (3, 1), (4, 5), (5, 6), (6, 4)]) result |> Result.is_err diff --git a/exercises/practice/forth/.meta/template.j2 b/exercises/practice/forth/.meta/template.j2 index 5cfd30e1..15bb2df2 100644 --- a/exercises/practice/forth/.meta/template.j2 +++ b/exercises/practice/forth/.meta/template.j2 @@ -12,7 +12,7 @@ expect {%- if innerCase["expected"]["error"] %} Result.is_err result {%- else %} - result == Ok {{ innerCase["expected"] }} + result == Ok({{ innerCase["expected"] }}) {%- endif %} {% endfor %} {% endfor %} diff --git a/exercises/practice/forth/forth-test.roc b/exercises/practice/forth/forth-test.roc index 76bb0b01..7052a04e 100644 --- a/exercises/practice/forth/forth-test.roc +++ b/exercises/practice/forth/forth-test.roc @@ -15,17 +15,17 @@ import Forth exposing [evaluate] # parsing and numbers: numbers just get pushed onto the stack expect result = evaluate "1 2 3 4 5" - result == Ok [1, 2, 3, 4, 5] + result == Ok([1, 2, 3, 4, 5]) # parsing and numbers: pushes negative numbers onto the stack expect result = evaluate "-1 -2 -3 -4 -5" - result == Ok [-1, -2, -3, -4, -5] + result == Ok([-1, -2, -3, -4, -5]) # addition: can add two numbers expect result = evaluate "1 2 +" - result == Ok [3] + result == Ok([3]) # addition: errors if there is nothing on the stack expect @@ -40,12 +40,12 @@ expect # addition: more than two values on the stack expect result = evaluate "1 2 3 +" - result == Ok [1, 5] + result == Ok([1, 5]) # subtraction: can subtract two numbers expect result = evaluate "3 4 -" - result == Ok [-1] + result == Ok([-1]) # subtraction: errors if there is nothing on the stack expect @@ -60,12 +60,12 @@ expect # subtraction: more than two values on the stack expect result = evaluate "1 12 3 -" - result == Ok [1, 9] + result == Ok([1, 9]) # multiplication: can multiply two numbers expect result = evaluate "2 4 *" - result == Ok [8] + result == Ok([8]) # multiplication: errors if there is nothing on the stack expect @@ -80,17 +80,17 @@ expect # multiplication: more than two values on the stack expect result = evaluate "1 2 3 *" - result == Ok [1, 6] + result == Ok([1, 6]) # division: can divide two numbers expect result = evaluate "12 3 /" - result == Ok [4] + result == Ok([4]) # division: performs integer division expect result = evaluate "8 3 /" - result == Ok [2] + result == Ok([2]) # division: errors if dividing by zero expect @@ -110,37 +110,37 @@ expect # division: more than two values on the stack expect result = evaluate "1 12 3 /" - result == Ok [1, 4] + result == Ok([1, 4]) # combined arithmetic: addition and subtraction expect result = evaluate "1 2 + 4 -" - result == Ok [-1] + result == Ok([-1]) # combined arithmetic: multiplication and division expect result = evaluate "2 4 * 3 /" - result == Ok [2] + result == Ok([2]) # combined arithmetic: multiplication and addition expect result = evaluate "1 3 4 * +" - result == Ok [13] + result == Ok([13]) # combined arithmetic: addition and multiplication expect result = evaluate "1 3 4 + *" - result == Ok [7] + result == Ok([7]) # dup: copies a value on the stack expect result = evaluate "1 dup" - result == Ok [1, 1] + result == Ok([1, 1]) # dup: copies the top value on the stack expect result = evaluate "1 2 dup" - result == Ok [1, 2, 2] + result == Ok([1, 2, 2]) # dup: errors if there is nothing on the stack expect @@ -150,12 +150,12 @@ expect # drop: removes the top value on the stack if it is the only one expect result = evaluate "1 drop" - result == Ok [] + result == Ok([]) # drop: removes the top value on the stack if it is not the only one expect result = evaluate "1 2 drop" - result == Ok [1] + result == Ok([1]) # drop: errors if there is nothing on the stack expect @@ -165,12 +165,12 @@ expect # swap: swaps the top two values on the stack if they are the only ones expect result = evaluate "1 2 swap" - result == Ok [2, 1] + result == Ok([2, 1]) # swap: swaps the top two values on the stack if they are not the only ones expect result = evaluate "1 2 3 swap" - result == Ok [1, 3, 2] + result == Ok([1, 3, 2]) # swap: errors if there is nothing on the stack expect @@ -185,12 +185,12 @@ expect # over: copies the second element if there are only two expect result = evaluate "1 2 over" - result == Ok [1, 2, 1] + result == Ok([1, 2, 1]) # over: copies the second element if there are more than two expect result = evaluate "1 2 3 over" - result == Ok [1, 2, 3, 2] + result == Ok([1, 2, 3, 2]) # over: errors if there is nothing on the stack expect @@ -209,7 +209,7 @@ expect : dup-twice dup dup ; 1 dup-twice """ - result == Ok [1, 1, 1] + result == Ok([1, 1, 1]) # user-defined words: execute in the right order expect @@ -218,7 +218,7 @@ expect : countup 1 2 3 ; countup """ - result == Ok [1, 2, 3] + result == Ok([1, 2, 3]) # user-defined words: can override other user-defined words expect @@ -228,7 +228,7 @@ expect : foo dup dup ; 1 foo """ - result == Ok [1, 1, 1] + result == Ok([1, 1, 1]) # user-defined words: can override built-in words expect @@ -237,7 +237,7 @@ expect : swap dup ; 1 swap """ - result == Ok [1, 1] + result == Ok([1, 1]) # user-defined words: can override built-in operators expect @@ -246,7 +246,7 @@ expect : + * ; 3 4 + """ - result == Ok [12] + result == Ok([12]) # user-defined words: can use different words with the same name expect @@ -257,7 +257,7 @@ expect : foo 6 ; bar foo """ - result == Ok [5, 6] + result == Ok([5, 6]) # user-defined words: can define word that uses word with the same name expect @@ -267,7 +267,7 @@ expect : foo foo 1 + ; foo """ - result == Ok [11] + result == Ok([11]) # user-defined words: errors if executing a non-existent word expect @@ -277,22 +277,22 @@ expect # case-insensitivity: DUP is case-insensitive expect result = evaluate "1 DUP Dup dup" - result == Ok [1, 1, 1, 1] + result == Ok([1, 1, 1, 1]) # case-insensitivity: DROP is case-insensitive expect result = evaluate "1 2 3 4 DROP Drop drop" - result == Ok [1] + result == Ok([1]) # case-insensitivity: SWAP is case-insensitive expect result = evaluate "1 2 SWAP 3 Swap 4 swap" - result == Ok [2, 3, 4, 1] + result == Ok([2, 3, 4, 1]) # case-insensitivity: OVER is case-insensitive expect result = evaluate "1 2 OVER Over over" - result == Ok [1, 2, 1, 2, 1] + result == Ok([1, 2, 1, 2, 1]) # case-insensitivity: user-defined words are case-insensitive expect @@ -301,7 +301,7 @@ expect : foo dup ; 1 FOO Foo foo """ - result == Ok [1, 1, 1, 1] + result == Ok([1, 1, 1, 1]) # case-insensitivity: definitions are case-insensitive expect @@ -310,5 +310,5 @@ expect : SWAP DUP Dup dup ; 1 swap """ - result == Ok [1, 1, 1, 1] + result == Ok([1, 1, 1, 1]) diff --git a/exercises/practice/go-counting/.meta/template.j2 b/exercises/practice/go-counting/.meta/template.j2 index 885807ff..98d62b02 100644 --- a/exercises/practice/go-counting/.meta/template.j2 +++ b/exercises/practice/go-counting/.meta/template.j2 @@ -22,12 +22,12 @@ import {{ exercise | to_pascal }} exposing [territory, territories] ## in order to compare them properly. compareTerritory = |maybe_result, maybe_expected| when (maybe_result, maybe_expected) is - (Ok result, Ok expected) -> result.owner == expected.owner && result.territory == expected.territory + (Ok(result), Ok(expected)) -> result.owner == expected.owner && result.territory == expected.territory _ -> Bool.false compareTerritories = |maybe_result, maybe_expected| when (maybe_result, maybe_expected) is - (Ok result, Ok expected) -> result.black == expected.black && result.white == expected.white && result.none == expected.none + (Ok(result), Ok(expected)) -> result.black == expected.black && result.white == expected.white && result.none == expected.none _ -> Bool.false {% for case in cases -%} @@ -39,17 +39,17 @@ expect {%- if case["expected"]["error"] %} result |> Result.is_err {%- elif case["expected"]["owner"] %} - expected = Ok { + expected = Ok({ owner: {{ case["expected"]["owner"] | to_pascal }}, territory: {{ to_territory(case["expected"]["territory"]) }}, - } + }) result |> compareTerritory expected {%- else %} - expected = Ok { + expected = Ok({ black: {{ to_territory(case["expected"]["territoryBlack"]) }}, white: {{ to_territory(case["expected"]["territoryWhite"]) }}, none: {{ to_territory(case["expected"]["territoryNone"]) }}, - } + }) result |> compareTerritories expected {%- endif %} diff --git a/exercises/practice/go-counting/go-counting-test.roc b/exercises/practice/go-counting/go-counting-test.roc index ec8c0498..e067f116 100644 --- a/exercises/practice/go-counting/go-counting-test.roc +++ b/exercises/practice/go-counting/go-counting-test.roc @@ -18,12 +18,12 @@ import GoCounting exposing [territory, territories] ## in order to compare them properly. compareTerritory = |maybe_result, maybe_expected| when (maybe_result, maybe_expected) is - (Ok result, Ok expected) -> result.owner == expected.owner and result.territory == expected.territory + (Ok(result), Ok(expected)) -> result.owner == expected.owner and result.territory == expected.territory _ -> Bool.false compareTerritories = |maybe_result, maybe_expected| when (maybe_result, maybe_expected) is - (Ok result, Ok expected) -> result.black == expected.black and result.white == expected.white and result.none == expected.none + (Ok(result), Ok(expected)) -> result.black == expected.black and result.white == expected.white and result.none == expected.none _ -> Bool.false # Black corner territory on 5x5 board @@ -38,14 +38,16 @@ expect """ |> Str.replace_each "·" " " result = board |> territory { x: 0, y: 1 } - expected = Ok { - owner: Black, - territory: Set.from_list [ - { x: 0, y: 0 }, - { x: 0, y: 1 }, - { x: 1, y: 0 }, - ], - } + expected = Ok( + { + owner: Black, + territory: Set.from_list [ + { x: 0, y: 0 }, + { x: 0, y: 1 }, + { x: 1, y: 0 }, + ], + }, + ) result |> compareTerritory expected # White center territory on 5x5 board @@ -60,12 +62,14 @@ expect """ |> Str.replace_each "·" " " result = board |> territory { x: 2, y: 3 } - expected = Ok { - owner: White, - territory: Set.from_list [ - { x: 2, y: 3 }, - ], - } + expected = Ok( + { + owner: White, + territory: Set.from_list [ + { x: 2, y: 3 }, + ], + }, + ) result |> compareTerritory expected # Open corner territory on 5x5 board @@ -80,14 +84,16 @@ expect """ |> Str.replace_each "·" " " result = board |> territory { x: 1, y: 4 } - expected = Ok { - owner: None, - territory: Set.from_list [ - { x: 0, y: 3 }, - { x: 0, y: 4 }, - { x: 1, y: 4 }, - ], - } + expected = Ok( + { + owner: None, + territory: Set.from_list [ + { x: 0, y: 3 }, + { x: 0, y: 4 }, + { x: 1, y: 4 }, + ], + }, + ) result |> compareTerritory expected # A stone and not a territory on 5x5 board @@ -102,10 +108,12 @@ expect """ |> Str.replace_each "·" " " result = board |> territory { x: 1, y: 1 } - expected = Ok { - owner: None, - territory: Set.empty {}, - } + expected = Ok( + { + owner: None, + territory: Set.empty {}, + }, + ) result |> compareTerritory expected # Invalid because X is too high for 5x5 board @@ -140,15 +148,17 @@ expect expect board = "·" |> Str.replace_each "·" " " result = board |> territories - expected = Ok { - black: Set.empty {}, + expected = Ok( + { + black: Set.empty {}, - white: Set.empty {}, + white: Set.empty {}, - none: Set.from_list [ - { x: 0, y: 0 }, - ], - } + none: Set.from_list [ + { x: 0, y: 0 }, + ], + }, + ) result |> compareTerritories expected # Two territory rectangular board @@ -160,34 +170,38 @@ expect """ |> Str.replace_each "·" " " result = board |> territories - expected = Ok { - black: Set.from_list [ - { x: 0, y: 0 }, - { x: 0, y: 1 }, - ], - - white: Set.from_list [ - { x: 3, y: 0 }, - { x: 3, y: 1 }, - ], - - none: Set.empty {}, - } + expected = Ok( + { + black: Set.from_list [ + { x: 0, y: 0 }, + { x: 0, y: 1 }, + ], + + white: Set.from_list [ + { x: 3, y: 0 }, + { x: 3, y: 1 }, + ], + + none: Set.empty {}, + }, + ) result |> compareTerritories expected # Two region rectangular board expect board = "·B·" |> Str.replace_each "·" " " result = board |> territories - expected = Ok { - black: Set.from_list [ - { x: 0, y: 0 }, - { x: 2, y: 0 }, - ], - - white: Set.empty {}, - - none: Set.empty {}, - } + expected = Ok( + { + black: Set.from_list [ + { x: 0, y: 0 }, + { x: 2, y: 0 }, + ], + + white: Set.empty {}, + + none: Set.empty {}, + }, + ) result |> compareTerritories expected diff --git a/exercises/practice/grains/.meta/template.j2 b/exercises/practice/grains/.meta/template.j2 index 72494f1d..78e88cc7 100644 --- a/exercises/practice/grains/.meta/template.j2 +++ b/exercises/practice/grains/.meta/template.j2 @@ -20,7 +20,7 @@ expect {%- if subcase["expected"]["error"] %} Result.is_err result {%- else %} - result == Ok {{ subcase["expected"] }} + result == Ok({{ subcase["expected"] }}) {%- endif %} {% endfor %} diff --git a/exercises/practice/grains/grains-test.roc b/exercises/practice/grains/grains-test.roc index 1af91798..9f259b38 100644 --- a/exercises/practice/grains/grains-test.roc +++ b/exercises/practice/grains/grains-test.roc @@ -19,37 +19,37 @@ import Grains exposing [grains_on_square, total_grains] # grains on square 1 expect result = grains_on_square 1 - result == Ok 1 + result == Ok(1) # grains on square 2 expect result = grains_on_square 2 - result == Ok 2 + result == Ok(2) # grains on square 3 expect result = grains_on_square 3 - result == Ok 4 + result == Ok(4) # grains on square 4 expect result = grains_on_square 4 - result == Ok 8 + result == Ok(8) # grains on square 16 expect result = grains_on_square 16 - result == Ok 32768 + result == Ok(32768) # grains on square 32 expect result = grains_on_square 32 - result == Ok 2147483648 + result == Ok(2147483648) # grains on square 64 expect result = grains_on_square 64 - result == Ok 9223372036854775808 + result == Ok(9223372036854775808) # square 0 is invalid expect diff --git a/exercises/practice/high-scores/.meta/template.j2 b/exercises/practice/high-scores/.meta/template.j2 index 68329390..8607c15a 100644 --- a/exercises/practice/high-scores/.meta/template.j2 +++ b/exercises/practice/high-scores/.meta/template.j2 @@ -17,7 +17,7 @@ import {{ exercise | to_pascal }} exposing [latest, personal_best, personal_top_ {%- endif %} expect result = {{ case["property"] | to_snake }}({{ case["input"]["scores"] }}) - result == {% if case["property"] != "personalTopThree" %}Ok {% endif %}{{ case["expected"] | to_roc }} + result == {% if case["property"] != "personalTopThree" %}Ok({{ case["expected"] | to_roc }}){% endif %}{{ case["expected"] | to_roc }} {% endfor -%} {%- endfor %} diff --git a/exercises/practice/high-scores/high-scores-test.roc b/exercises/practice/high-scores/high-scores-test.roc index 20e2d7b0..c0ab80a7 100644 --- a/exercises/practice/high-scores/high-scores-test.roc +++ b/exercises/practice/high-scores/high-scores-test.roc @@ -15,12 +15,12 @@ import HighScores exposing [latest, personal_best, personal_top_three] ## Latest score expect result = latest([100, 0, 90, 30]) - result == Ok 30 + result == Ok(30) 30 ## Personal best expect result = personal_best([40, 100, 70]) - result == Ok 100 + result == Ok(100) 100 ## Top 3 scores # Personal top three from a list of scores diff --git a/exercises/practice/kindergarten-garden/.meta/template.j2 b/exercises/practice/kindergarten-garden/.meta/template.j2 index 2e162d9a..2a2355d8 100644 --- a/exercises/practice/kindergarten-garden/.meta/template.j2 +++ b/exercises/practice/kindergarten-garden/.meta/template.j2 @@ -22,7 +22,7 @@ import {{ exercise | to_pascal }} exposing [plants] expect diagram = {{ subcase["input"]["diagram"] | to_roc_multiline_string | indent(8) }} result = diagram |> {{ subcase["property"] | to_snake }}({{ subcase["input"]["student"] | to_pascal }}) - result == Ok [{% for plant in subcase["expected"] %}{{ plant | to_pascal }}, {% endfor %}] + result == Ok([{% for plant in subcase["expected"] %}{{ plant | to_pascal }}, {% endfor %}]) {% endfor %} diff --git a/exercises/practice/kindergarten-garden/kindergarten-garden-test.roc b/exercises/practice/kindergarten-garden/kindergarten-garden-test.roc index b0e2b558..6d37f12a 100644 --- a/exercises/practice/kindergarten-garden/kindergarten-garden-test.roc +++ b/exercises/practice/kindergarten-garden/kindergarten-garden-test.roc @@ -24,7 +24,7 @@ expect GG """ result = diagram |> plants(Alice) - result == Ok [Radishes, Clover, Grass, Grass] + result == Ok([Radishes, Clover, Grass, Grass]) # different garden with single student expect @@ -34,7 +34,7 @@ expect RC """ result = diagram |> plants(Alice) - result == Ok [Violets, Clover, Radishes, Clover] + result == Ok([Violets, Clover, Radishes, Clover]) # garden with two students expect @@ -44,7 +44,7 @@ expect VVRC """ result = diagram |> plants(Bob) - result == Ok [Clover, Grass, Radishes, Clover] + result == Ok([Clover, Grass, Radishes, Clover]) ## multiple students for the same garden with three students @@ -56,7 +56,7 @@ expect VVCCGG """ result = diagram |> plants(Bob) - result == Ok [Clover, Clover, Clover, Clover] + result == Ok([Clover, Clover, Clover, Clover]) # third student's garden expect @@ -66,7 +66,7 @@ expect VVCCGG """ result = diagram |> plants(Charlie) - result == Ok [Grass, Grass, Grass, Grass] + result == Ok([Grass, Grass, Grass, Grass]) ### ### full garden @@ -80,7 +80,7 @@ expect VRCCCGCRRGVCGCRVVCVGCGCV """ result = diagram |> plants(Alice) - result == Ok [Violets, Radishes, Violets, Radishes] + result == Ok([Violets, Radishes, Violets, Radishes]) # for Bob, second student's garden expect @@ -90,7 +90,7 @@ expect VRCCCGCRRGVCGCRVVCVGCGCV """ result = diagram |> plants(Bob) - result == Ok [Clover, Grass, Clover, Clover] + result == Ok([Clover, Grass, Clover, Clover]) # for Charlie expect @@ -100,7 +100,7 @@ expect VRCCCGCRRGVCGCRVVCVGCGCV """ result = diagram |> plants(Charlie) - result == Ok [Violets, Violets, Clover, Grass] + result == Ok([Violets, Violets, Clover, Grass]) # for David expect @@ -110,7 +110,7 @@ expect VRCCCGCRRGVCGCRVVCVGCGCV """ result = diagram |> plants(David) - result == Ok [Radishes, Violets, Clover, Radishes] + result == Ok([Radishes, Violets, Clover, Radishes]) # for Eve expect @@ -120,7 +120,7 @@ expect VRCCCGCRRGVCGCRVVCVGCGCV """ result = diagram |> plants(Eve) - result == Ok [Clover, Grass, Radishes, Grass] + result == Ok([Clover, Grass, Radishes, Grass]) # for Fred expect @@ -130,7 +130,7 @@ expect VRCCCGCRRGVCGCRVVCVGCGCV """ result = diagram |> plants(Fred) - result == Ok [Grass, Clover, Violets, Clover] + result == Ok([Grass, Clover, Violets, Clover]) # for Ginny expect @@ -140,7 +140,7 @@ expect VRCCCGCRRGVCGCRVVCVGCGCV """ result = diagram |> plants(Ginny) - result == Ok [Clover, Grass, Grass, Clover] + result == Ok([Clover, Grass, Grass, Clover]) # for Harriet expect @@ -150,7 +150,7 @@ expect VRCCCGCRRGVCGCRVVCVGCGCV """ result = diagram |> plants(Harriet) - result == Ok [Violets, Radishes, Radishes, Violets] + result == Ok([Violets, Radishes, Radishes, Violets]) # for Ileana expect @@ -160,7 +160,7 @@ expect VRCCCGCRRGVCGCRVVCVGCGCV """ result = diagram |> plants(Ileana) - result == Ok [Grass, Clover, Violets, Clover] + result == Ok([Grass, Clover, Violets, Clover]) # for Joseph expect @@ -170,7 +170,7 @@ expect VRCCCGCRRGVCGCRVVCVGCGCV """ result = diagram |> plants(Joseph) - result == Ok [Violets, Clover, Violets, Grass] + result == Ok([Violets, Clover, Violets, Grass]) # for Kincaid, second to last student's garden expect @@ -180,7 +180,7 @@ expect VRCCCGCRRGVCGCRVVCVGCGCV """ result = diagram |> plants(Kincaid) - result == Ok [Grass, Clover, Clover, Grass] + result == Ok([Grass, Clover, Clover, Grass]) # for Larry, last student's garden expect @@ -190,5 +190,5 @@ expect VRCCCGCRRGVCGCRVVCVGCGCV """ result = diagram |> plants(Larry) - result == Ok [Grass, Violets, Clover, Violets] + result == Ok([Grass, Violets, Clover, Violets]) diff --git a/exercises/practice/largest-series-product/.meta/template.j2 b/exercises/practice/largest-series-product/.meta/template.j2 index 32e91028..c0cf1475 100644 --- a/exercises/practice/largest-series-product/.meta/template.j2 +++ b/exercises/practice/largest-series-product/.meta/template.j2 @@ -12,7 +12,7 @@ expect {%- if case["expected"]["error"] %} result |> Result.is_err {%- else %} - expected = Ok {{ case["expected"] | to_roc }} + expected = Ok({{ case["expected"] | to_roc }}) result == expected {%- endif %} diff --git a/exercises/practice/largest-series-product/largest-series-product-test.roc b/exercises/practice/largest-series-product/largest-series-product-test.roc index ddf4091f..85c69a15 100644 --- a/exercises/practice/largest-series-product/largest-series-product-test.roc +++ b/exercises/practice/largest-series-product/largest-series-product-test.roc @@ -16,63 +16,63 @@ import LargestSeriesProduct exposing [largest_product] expect digits = "29" result = digits |> largest_product(2) - expected = Ok 18 + expected = Ok(18) result == expected # can find the largest product of 2 with numbers in order expect digits = "0123456789" result = digits |> largest_product(2) - expected = Ok 72 + expected = Ok(72) result == expected # can find the largest product of 2 expect digits = "576802143" result = digits |> largest_product(2) - expected = Ok 48 + expected = Ok(48) result == expected # can find the largest product of 3 with numbers in order expect digits = "0123456789" result = digits |> largest_product(3) - expected = Ok 504 + expected = Ok(504) result == expected # can find the largest product of 3 expect digits = "1027839564" result = digits |> largest_product(3) - expected = Ok 270 + expected = Ok(270) result == expected # can find the largest product of 5 with numbers in order expect digits = "0123456789" result = digits |> largest_product(5) - expected = Ok 15120 + expected = Ok(15120) result == expected # can get the largest product of a big number expect digits = "73167176531330624919225119674426574742355349194934" result = digits |> largest_product(6) - expected = Ok 23520 + expected = Ok(23520) result == expected # reports zero if the only digits are zero expect digits = "0000" result = digits |> largest_product(2) - expected = Ok 0 + expected = Ok(0) result == expected # reports zero if all spans include zero expect digits = "99099" result = digits |> largest_product(3) - expected = Ok 0 + expected = Ok(0) result == expected # rejects span longer than string length @@ -85,14 +85,14 @@ expect expect digits = "" result = digits |> largest_product(0) - expected = Ok 1 + expected = Ok(1) result == expected # reports 1 for nonempty string and empty product (0 span) expect digits = "123" result = digits |> largest_product(0) - expected = Ok 1 + expected = Ok(1) result == expected # rejects empty string and nonzero span diff --git a/exercises/practice/matrix/.meta/template.j2 b/exercises/practice/matrix/.meta/template.j2 index e3f97d3f..465f298d 100644 --- a/exercises/practice/matrix/.meta/template.j2 +++ b/exercises/practice/matrix/.meta/template.j2 @@ -9,6 +9,6 @@ import {{ exercise | to_pascal }} exposing [row, column] expect matrix_str = {{ case["input"]["string"] | to_roc_multiline_string | indent(8) }} result = matrix_str |> {{ case["property"] | to_snake }}({{ case["input"]["index"] | to_roc }}) - result == Ok {{ case["expected"] | to_roc }} + result == Ok({{ case["expected"] | to_roc }}) {% endfor %} diff --git a/exercises/practice/matrix/matrix-test.roc b/exercises/practice/matrix/matrix-test.roc index 7517ceb5..1a7d1344 100644 --- a/exercises/practice/matrix/matrix-test.roc +++ b/exercises/practice/matrix/matrix-test.roc @@ -16,7 +16,7 @@ import Matrix exposing [row, column] expect matrix_str = "1" result = matrix_str |> row(1) - result == Ok [1] + result == Ok([1]) # can extract row expect @@ -26,7 +26,7 @@ expect 3 4 """ result = matrix_str |> row(2) - result == Ok [3, 4] + result == Ok([3, 4]) # extract row where numbers have different widths expect @@ -36,7 +36,7 @@ expect 10 20 """ result = matrix_str |> row(2) - result == Ok [10, 20] + result == Ok([10, 20]) # can extract row from non-square matrix with no corresponding column expect @@ -48,13 +48,13 @@ expect 8 7 6 """ result = matrix_str |> row(4) - result == Ok [8, 7, 6] + result == Ok([8, 7, 6]) # extract column from one number matrix expect matrix_str = "1" result = matrix_str |> column(1) - result == Ok [1] + result == Ok([1]) # can extract column expect @@ -65,7 +65,7 @@ expect 7 8 9 """ result = matrix_str |> column(3) - result == Ok [3, 6, 9] + result == Ok([3, 6, 9]) # can extract column from non-square matrix with no corresponding row expect @@ -76,7 +76,7 @@ expect 9 8 7 6 """ result = matrix_str |> column(4) - result == Ok [4, 8, 6] + result == Ok([4, 8, 6]) # extract column where numbers have different widths expect @@ -87,5 +87,5 @@ expect 9 4 800 """ result = matrix_str |> column(2) - result == Ok [1903, 3, 4] + result == Ok([1903, 3, 4]) diff --git a/exercises/practice/micro-blog/.meta/template.j2 b/exercises/practice/micro-blog/.meta/template.j2 index 0d29d5f2..32cb0476 100644 --- a/exercises/practice/micro-blog/.meta/template.j2 +++ b/exercises/practice/micro-blog/.meta/template.j2 @@ -8,6 +8,6 @@ import {{ exercise | to_pascal }} exposing [{{ cases[0]["property"] | to_snake } # {{ case["description"] }} expect result = {{ case["property"] | to_snake }}({{ case["input"]["phrase"] | to_roc }}) - result == Ok {{ case["expected"] | to_roc }} + result == Ok({{ case["expected"] | to_roc }}) {% endfor %} diff --git a/exercises/practice/micro-blog/micro-blog-test.roc b/exercises/practice/micro-blog/micro-blog-test.roc index 4d94396a..5123de31 100644 --- a/exercises/practice/micro-blog/micro-blog-test.roc +++ b/exercises/practice/micro-blog/micro-blog-test.roc @@ -16,60 +16,60 @@ import MicroBlog exposing [truncate] # English language short expect result = truncate("Hi") - result == Ok "Hi" + result == Ok("Hi") # English language long expect result = truncate("Hello there") - result == Ok "Hello" + result == Ok("Hello") # German language short (broth) expect result = truncate("brühe") - result == Ok "brühe" + result == Ok("brühe") # German language long (bear carpet → beards) expect result = truncate("Bärteppich") - result == Ok "Bärte" + result == Ok("Bärte") # Bulgarian language short (good) expect result = truncate("Добър") - result == Ok "Добър" + result == Ok("Добър") # Greek language short (health) expect result = truncate("υγειά") - result == Ok "υγειά" + result == Ok("υγειά") # Maths short expect result = truncate("a=πr²") - result == Ok "a=πr²" + result == Ok("a=πr²") # Maths long expect result = truncate("∅⊊ℕ⊊ℤ⊊ℚ⊊ℝ⊊ℂ") - result == Ok "∅⊊ℕ⊊ℤ" + result == Ok("∅⊊ℕ⊊ℤ") # English and emoji short expect result = truncate("Fly 🛫") - result == Ok "Fly 🛫" + result == Ok("Fly 🛫") # Emoji short expect result = truncate("💇") - result == Ok "💇" + result == Ok("💇") # Emoji long expect result = truncate("❄🌡🤧🤒🏥🕰😀") - result == Ok "❄🌡🤧🤒🏥" + result == Ok("❄🌡🤧🤒🏥") # Royal Flush? expect result = truncate("🃎🂸🃅🃋🃍🃁🃊") - result == Ok "🃎🂸🃅🃋🃍" + result == Ok("🃎🂸🃅🃋🃍") diff --git a/exercises/practice/nth-prime/.meta/template.j2 b/exercises/practice/nth-prime/.meta/template.j2 index 7c8f0f90..e815e36b 100644 --- a/exercises/practice/nth-prime/.meta/template.j2 +++ b/exercises/practice/nth-prime/.meta/template.j2 @@ -11,7 +11,7 @@ expect {%- if case["expected"]["error"] %} result |> Result.is_err {%- else %} - result == Ok {{ case["expected"] }} + result == Ok({{ case["expected"] }}) {%- endif %} {% endfor %} diff --git a/exercises/practice/nth-prime/nth-prime-test.roc b/exercises/practice/nth-prime/nth-prime-test.roc index 512ce43d..53268158 100644 --- a/exercises/practice/nth-prime/nth-prime-test.roc +++ b/exercises/practice/nth-prime/nth-prime-test.roc @@ -15,22 +15,22 @@ import NthPrime exposing [prime] # first prime expect result = prime(1) - result == Ok 2 + result == Ok(2) # second prime expect result = prime(2) - result == Ok 3 + result == Ok(3) # sixth prime expect result = prime(6) - result == Ok 13 + result == Ok(13) # big prime expect result = prime(10001) - result == Ok 104743 + result == Ok(104743) # there is no zeroth prime expect diff --git a/exercises/practice/nucleotide-count/.meta/template.j2 b/exercises/practice/nucleotide-count/.meta/template.j2 index 7daf42e3..c9e48644 100644 --- a/exercises/practice/nucleotide-count/.meta/template.j2 +++ b/exercises/practice/nucleotide-count/.meta/template.j2 @@ -11,7 +11,7 @@ expect {%- if case["expected"]["error"] %} Result.is_err result {%- else %} - result == Ok {{ case["expected"] | to_roc }} + result == Ok({{ case["expected"] | to_roc }}) {%- endif %} {% endfor %} diff --git a/exercises/practice/nucleotide-count/nucleotide-count-test.roc b/exercises/practice/nucleotide-count/nucleotide-count-test.roc index 6c7909b7..742bcdad 100644 --- a/exercises/practice/nucleotide-count/nucleotide-count-test.roc +++ b/exercises/practice/nucleotide-count/nucleotide-count-test.roc @@ -15,22 +15,22 @@ import NucleotideCount exposing [nucleotide_counts] # empty strand expect result = nucleotide_counts("") - result == Ok { a: 0, c: 0, g: 0, t: 0 } + result == Ok({ a: 0, c: 0, g: 0, t: 0 }) # can count one nucleotide in single-character input expect result = nucleotide_counts("G") - result == Ok { a: 0, c: 0, g: 1, t: 0 } + result == Ok({ a: 0, c: 0, g: 1, t: 0 }) # strand with repeated nucleotide expect result = nucleotide_counts("GGGGGGG") - result == Ok { a: 0, c: 0, g: 7, t: 0 } + result == Ok({ a: 0, c: 0, g: 7, t: 0 }) # strand with multiple nucleotides expect result = nucleotide_counts("AGCTTTTCATTCTGACTGCAACGGGCAATATGTCTCTGTGTGGATTAAAAAAAGAGTGTCTGATAGCAGC") - result == Ok { a: 20, c: 12, g: 17, t: 21 } + result == Ok({ a: 20, c: 12, g: 17, t: 21 }) # strand with invalid nucleotides expect diff --git a/exercises/practice/ocr-numbers/.meta/template.j2 b/exercises/practice/ocr-numbers/.meta/template.j2 index d284568d..468210a2 100644 --- a/exercises/practice/ocr-numbers/.meta/template.j2 +++ b/exercises/practice/ocr-numbers/.meta/template.j2 @@ -12,7 +12,7 @@ expect {%- if case["expected"]["error"] %} result |> Result.is_err {%- else %} - expected = Ok {{ case["expected"] | to_roc }} + expected = Ok({{ case["expected"] | to_roc }}) result == expected {%- endif %} diff --git a/exercises/practice/ocr-numbers/ocr-numbers-test.roc b/exercises/practice/ocr-numbers/ocr-numbers-test.roc index 8e2ecd54..c86700ae 100644 --- a/exercises/practice/ocr-numbers/ocr-numbers-test.roc +++ b/exercises/practice/ocr-numbers/ocr-numbers-test.roc @@ -22,7 +22,7 @@ expect """ result = convert grid - expected = Ok "0" + expected = Ok("0") result == expected # Recognizes 1 @@ -35,7 +35,7 @@ expect """ result = convert grid - expected = Ok "1" + expected = Ok("1") result == expected # Unreadable but correctly sized inputs return ? @@ -48,7 +48,7 @@ expect """ result = convert grid - expected = Ok "?" + expected = Ok("?") result == expected # Input with a number of lines that is not a multiple of four raises an error @@ -84,7 +84,7 @@ expect """ result = convert grid - expected = Ok "110101100" + expected = Ok("110101100") result == expected # Garbled numbers in a string are replaced with ? @@ -97,7 +97,7 @@ expect """ result = convert grid - expected = Ok "11?10?1?0" + expected = Ok("11?10?1?0") result == expected # Recognizes 2 @@ -110,7 +110,7 @@ expect """ result = convert grid - expected = Ok "2" + expected = Ok("2") result == expected # Recognizes 3 @@ -123,7 +123,7 @@ expect """ result = convert grid - expected = Ok "3" + expected = Ok("3") result == expected # Recognizes 4 @@ -136,7 +136,7 @@ expect """ result = convert grid - expected = Ok "4" + expected = Ok("4") result == expected # Recognizes 5 @@ -149,7 +149,7 @@ expect """ result = convert grid - expected = Ok "5" + expected = Ok("5") result == expected # Recognizes 6 @@ -162,7 +162,7 @@ expect """ result = convert grid - expected = Ok "6" + expected = Ok("6") result == expected # Recognizes 7 @@ -175,7 +175,7 @@ expect """ result = convert grid - expected = Ok "7" + expected = Ok("7") result == expected # Recognizes 8 @@ -188,7 +188,7 @@ expect """ result = convert grid - expected = Ok "8" + expected = Ok("8") result == expected # Recognizes 9 @@ -201,7 +201,7 @@ expect """ result = convert grid - expected = Ok "9" + expected = Ok("9") result == expected # Recognizes string of decimal numbers @@ -214,7 +214,7 @@ expect """ result = convert grid - expected = Ok "1234567890" + expected = Ok("1234567890") result == expected # Numbers separated by empty lines are recognized. Lines are joined by commas. @@ -235,6 +235,6 @@ expect """ result = convert grid - expected = Ok "123,456,789" + expected = Ok("123,456,789") result == expected diff --git a/exercises/practice/perfect-numbers/.meta/template.j2 b/exercises/practice/perfect-numbers/.meta/template.j2 index 85ac393c..4e655f9b 100644 --- a/exercises/practice/perfect-numbers/.meta/template.j2 +++ b/exercises/practice/perfect-numbers/.meta/template.j2 @@ -16,7 +16,7 @@ expect {%- if case["expected"]["error"] %} Result.is_err result {%- else %} - result == Ok {{ case["expected"] | to_pascal }} + result == Ok({{ case["expected"] | to_pascal }}) {%- endif %} {% endfor %} diff --git a/exercises/practice/perfect-numbers/perfect-numbers-test.roc b/exercises/practice/perfect-numbers/perfect-numbers-test.roc index fcba677b..a66851a9 100644 --- a/exercises/practice/perfect-numbers/perfect-numbers-test.roc +++ b/exercises/practice/perfect-numbers/perfect-numbers-test.roc @@ -19,17 +19,17 @@ import PerfectNumbers exposing [classify] # Smallest perfect number is classified correctly expect result = classify(6) - result == Ok Perfect + result == Ok(Perfect) # Medium perfect number is classified correctly expect result = classify(28) - result == Ok Perfect + result == Ok(Perfect) # Large perfect number is classified correctly expect result = classify(33550336) - result == Ok Perfect + result == Ok(Perfect) ## ## Abundant numbers @@ -38,17 +38,17 @@ expect # Smallest abundant number is classified correctly expect result = classify(12) - result == Ok Abundant + result == Ok(Abundant) # Medium abundant number is classified correctly expect result = classify(30) - result == Ok Abundant + result == Ok(Abundant) # Large abundant number is classified correctly expect result = classify(33550335) - result == Ok Abundant + result == Ok(Abundant) ## ## Deficient numbers @@ -57,27 +57,27 @@ expect # Smallest prime deficient number is classified correctly expect result = classify(2) - result == Ok Deficient + result == Ok(Deficient) # Smallest non-prime deficient number is classified correctly expect result = classify(4) - result == Ok Deficient + result == Ok(Deficient) # Medium deficient number is classified correctly expect result = classify(32) - result == Ok Deficient + result == Ok(Deficient) # Large deficient number is classified correctly expect result = classify(33550337) - result == Ok Deficient + result == Ok(Deficient) # Edge case (no factors other than itself) is classified correctly expect result = classify(1) - result == Ok Deficient + result == Ok(Deficient) ## ## Invalid inputs diff --git a/exercises/practice/phone-number/.meta/template.j2 b/exercises/practice/phone-number/.meta/template.j2 index c6e5ddd9..45f4dec9 100644 --- a/exercises/practice/phone-number/.meta/template.j2 +++ b/exercises/practice/phone-number/.meta/template.j2 @@ -11,7 +11,7 @@ expect {%- if case["expected"]["error"] %} result |> Result.is_err {%- else %} - expected = Ok {{ case["expected"] | to_roc }} + expected = Ok({{ case["expected"] | to_roc }}) result == expected {%- endif %} diff --git a/exercises/practice/phone-number/phone-number-test.roc b/exercises/practice/phone-number/phone-number-test.roc index f2a2abb2..4175682f 100644 --- a/exercises/practice/phone-number/phone-number-test.roc +++ b/exercises/practice/phone-number/phone-number-test.roc @@ -15,19 +15,19 @@ import PhoneNumber exposing [clean] # cleans the number expect result = clean("(223) 456-7890") - expected = Ok "2234567890" + expected = Ok("2234567890") result == expected # cleans numbers with dots expect result = clean("223.456.7890") - expected = Ok "2234567890" + expected = Ok("2234567890") result == expected # cleans numbers with multiple spaces expect result = clean("223 456 7890 ") - expected = Ok "2234567890" + expected = Ok("2234567890") result == expected # invalid when 9 digits @@ -43,13 +43,13 @@ expect # valid when 11 digits and starting with 1 expect result = clean("12234567890") - expected = Ok "2234567890" + expected = Ok("2234567890") result == expected # valid when 11 digits and starting with 1 even with punctuation expect result = clean("+1 (223) 456-7890") - expected = Ok "2234567890" + expected = Ok("2234567890") result == expected # invalid when more than 11 digits diff --git a/exercises/practice/rail-fence-cipher/.meta/template.j2 b/exercises/practice/rail-fence-cipher/.meta/template.j2 index ca87fee9..c05a1a87 100644 --- a/exercises/practice/rail-fence-cipher/.meta/template.j2 +++ b/exercises/practice/rail-fence-cipher/.meta/template.j2 @@ -14,7 +14,7 @@ import {{ exercise | to_pascal }} exposing [encode, decode] expect message = {{ case["input"]["msg"] | to_roc }} result = message |> {{ case["property"] | to_snake }}({{ case["input"]["rails"] | to_roc }}) - expected = Ok {{ case["expected"] | to_roc }} + expected = Ok({{ case["expected"] | to_roc }}) result == expected {% endfor %} diff --git a/exercises/practice/rail-fence-cipher/rail-fence-cipher-test.roc b/exercises/practice/rail-fence-cipher/rail-fence-cipher-test.roc index fa424793..5d9446db 100644 --- a/exercises/practice/rail-fence-cipher/rail-fence-cipher-test.roc +++ b/exercises/practice/rail-fence-cipher/rail-fence-cipher-test.roc @@ -20,21 +20,21 @@ import RailFenceCipher exposing [encode, decode] expect message = "XOXOXOXOXOXOXOXOXO" result = message |> encode(2) - expected = Ok "XXXXXXXXXOOOOOOOOO" + expected = Ok("XXXXXXXXXOOOOOOOOO") result == expected # encode with three rails expect message = "WEAREDISCOVEREDFLEEATONCE" result = message |> encode(3) - expected = Ok "WECRLTEERDSOEEFEAOCAIVDEN" + expected = Ok("WECRLTEERDSOEEFEAOCAIVDEN") result == expected # encode with ending in the middle expect message = "EXERCISES" result = message |> encode(4) - expected = Ok "ESXIEECSR" + expected = Ok("ESXIEECSR") result == expected ## @@ -45,20 +45,20 @@ expect expect message = "TEITELHDVLSNHDTISEIIEA" result = message |> decode(3) - expected = Ok "THEDEVILISINTHEDETAILS" + expected = Ok("THEDEVILISINTHEDETAILS") result == expected # decode with five rails expect message = "EIEXMSMESAORIWSCE" result = message |> decode(5) - expected = Ok "EXERCISMISAWESOME" + expected = Ok("EXERCISMISAWESOME") result == expected # decode with six rails expect message = "133714114238148966225439541018335470986172518171757571896261" result = message |> decode(6) - expected = Ok "112358132134558914423337761098715972584418167651094617711286" + expected = Ok("112358132134558914423337761098715972584418167651094617711286") result == expected diff --git a/exercises/practice/resistor-color/.meta/template.j2 b/exercises/practice/resistor-color/.meta/template.j2 index 2717e885..c8e32f9f 100644 --- a/exercises/practice/resistor-color/.meta/template.j2 +++ b/exercises/practice/resistor-color/.meta/template.j2 @@ -21,7 +21,7 @@ expect # {{ subcase["description"] }} expect result = {{ subcase["property"] | to_snake }}({{ subcase["input"]["color"] | to_roc }}) - result == Ok {{ subcase["expected"] }} + result == Ok({{ subcase["expected"] }}) {% endfor %} {%- endif -%} diff --git a/exercises/practice/resistor-color/resistor-color-test.roc b/exercises/practice/resistor-color/resistor-color-test.roc index cbe606a8..0802bb88 100644 --- a/exercises/practice/resistor-color/resistor-color-test.roc +++ b/exercises/practice/resistor-color/resistor-color-test.roc @@ -19,17 +19,17 @@ import ResistorColor exposing [color_code, colors] # Black expect result = color_code("black") - result == Ok 0 + result == Ok(0) # White expect result = color_code("white") - result == Ok 9 + result == Ok(9) # Orange expect result = color_code("orange") - result == Ok 3 + result == Ok(3) ## ## Colors diff --git a/exercises/practice/roman-numerals/.meta/template.j2 b/exercises/practice/roman-numerals/.meta/template.j2 index 1c850941..d2fb0f03 100644 --- a/exercises/practice/roman-numerals/.meta/template.j2 +++ b/exercises/practice/roman-numerals/.meta/template.j2 @@ -8,6 +8,6 @@ import {{ exercise | to_pascal }} exposing [{{ cases[0]["property"] | to_snake } # {{ case["description"] }} expect result = {{ case["property"] | to_snake }}({{ case["input"]["number"] | to_roc }}) - result == Ok {{ case["expected"] | to_roc }} + result == Ok({{ case["expected"] | to_roc }}) {% endfor %} diff --git a/exercises/practice/roman-numerals/roman-numerals-test.roc b/exercises/practice/roman-numerals/roman-numerals-test.roc index 8b5ebf73..93602658 100644 --- a/exercises/practice/roman-numerals/roman-numerals-test.roc +++ b/exercises/practice/roman-numerals/roman-numerals-test.roc @@ -15,135 +15,135 @@ import RomanNumerals exposing [roman] # 1 is I expect result = roman(1) - result == Ok "I" + result == Ok("I") # 2 is II expect result = roman(2) - result == Ok "II" + result == Ok("II") # 3 is III expect result = roman(3) - result == Ok "III" + result == Ok("III") # 4 is IV expect result = roman(4) - result == Ok "IV" + result == Ok("IV") # 5 is V expect result = roman(5) - result == Ok "V" + result == Ok("V") # 6 is VI expect result = roman(6) - result == Ok "VI" + result == Ok("VI") # 9 is IX expect result = roman(9) - result == Ok "IX" + result == Ok("IX") # 16 is XVI expect result = roman(16) - result == Ok "XVI" + result == Ok("XVI") # 27 is XXVII expect result = roman(27) - result == Ok "XXVII" + result == Ok("XXVII") # 48 is XLVIII expect result = roman(48) - result == Ok "XLVIII" + result == Ok("XLVIII") # 49 is XLIX expect result = roman(49) - result == Ok "XLIX" + result == Ok("XLIX") # 59 is LIX expect result = roman(59) - result == Ok "LIX" + result == Ok("LIX") # 66 is LXVI expect result = roman(66) - result == Ok "LXVI" + result == Ok("LXVI") # 93 is XCIII expect result = roman(93) - result == Ok "XCIII" + result == Ok("XCIII") # 141 is CXLI expect result = roman(141) - result == Ok "CXLI" + result == Ok("CXLI") # 163 is CLXIII expect result = roman(163) - result == Ok "CLXIII" + result == Ok("CLXIII") # 166 is CLXVI expect result = roman(166) - result == Ok "CLXVI" + result == Ok("CLXVI") # 402 is CDII expect result = roman(402) - result == Ok "CDII" + result == Ok("CDII") # 575 is DLXXV expect result = roman(575) - result == Ok "DLXXV" + result == Ok("DLXXV") # 666 is DCLXVI expect result = roman(666) - result == Ok "DCLXVI" + result == Ok("DCLXVI") # 911 is CMXI expect result = roman(911) - result == Ok "CMXI" + result == Ok("CMXI") # 1024 is MXXIV expect result = roman(1024) - result == Ok "MXXIV" + result == Ok("MXXIV") # 1666 is MDCLXVI expect result = roman(1666) - result == Ok "MDCLXVI" + result == Ok("MDCLXVI") # 3000 is MMM expect result = roman(3000) - result == Ok "MMM" + result == Ok("MMM") # 3001 is MMMI expect result = roman(3001) - result == Ok "MMMI" + result == Ok("MMMI") # 3888 is MMMDCCCLXXXVIII expect result = roman(3888) - result == Ok "MMMDCCCLXXXVIII" + result == Ok("MMMDCCCLXXXVIII") # 3999 is MMMCMXCIX expect result = roman(3999) - result == Ok "MMMCMXCIX" + result == Ok("MMMCMXCIX") diff --git a/exercises/practice/say/.meta/template.j2 b/exercises/practice/say/.meta/template.j2 index 7f6649e8..2e8c177e 100644 --- a/exercises/practice/say/.meta/template.j2 +++ b/exercises/practice/say/.meta/template.j2 @@ -11,7 +11,7 @@ expect {%- if case["expected"]["error"] %} result |> Result.is_err {%- else %} - result == Ok {{ case["expected"] | to_roc }} + result == Ok({{ case["expected"] | to_roc }}) {% endif %} {% endfor %} diff --git a/exercises/practice/say/say-test.roc b/exercises/practice/say/say-test.roc index 0e3ff4ed..4ee13693 100644 --- a/exercises/practice/say/say-test.roc +++ b/exercises/practice/say/say-test.roc @@ -15,87 +15,87 @@ import Say exposing [say] # zero expect result = say(0) - result == Ok "zero" + result == Ok("zero") # one expect result = say(1) - result == Ok "one" + result == Ok("one") # fourteen expect result = say(14) - result == Ok "fourteen" + result == Ok("fourteen") # twenty expect result = say(20) - result == Ok "twenty" + result == Ok("twenty") # twenty-two expect result = say(22) - result == Ok "twenty-two" + result == Ok("twenty-two") # thirty expect result = say(30) - result == Ok "thirty" + result == Ok("thirty") # ninety-nine expect result = say(99) - result == Ok "ninety-nine" + result == Ok("ninety-nine") # one hundred expect result = say(100) - result == Ok "one hundred" + result == Ok("one hundred") # one hundred twenty-three expect result = say(123) - result == Ok "one hundred twenty-three" + result == Ok("one hundred twenty-three") # two hundred expect result = say(200) - result == Ok "two hundred" + result == Ok("two hundred") # nine hundred ninety-nine expect result = say(999) - result == Ok "nine hundred ninety-nine" + result == Ok("nine hundred ninety-nine") # one thousand expect result = say(1000) - result == Ok "one thousand" + result == Ok("one thousand") # one thousand two hundred thirty-four expect result = say(1234) - result == Ok "one thousand two hundred thirty-four" + result == Ok("one thousand two hundred thirty-four") # one million expect result = say(1000000) - result == Ok "one million" + result == Ok("one million") # one million two thousand three hundred forty-five expect result = say(1002345) - result == Ok "one million two thousand three hundred forty-five" + result == Ok("one million two thousand three hundred forty-five") # one billion expect result = say(1000000000) - result == Ok "one billion" + result == Ok("one billion") # a big number expect result = say(987654321123) - result == Ok "nine hundred eighty-seven billion six hundred fifty-four million three hundred twenty-one thousand one hundred twenty-three" + result == Ok("nine hundred eighty-seven billion six hundred fifty-four million three hundred twenty-one thousand one hundred twenty-three") # numbers above 999,999,999,999 are out of range expect diff --git a/exercises/practice/sgf-parsing/.meta/template.j2 b/exercises/practice/sgf-parsing/.meta/template.j2 index 452107a0..4b2c088f 100644 --- a/exercises/practice/sgf-parsing/.meta/template.j2 +++ b/exercises/practice/sgf-parsing/.meta/template.j2 @@ -27,7 +27,7 @@ expect result |> Result.is_err {%- else %} expected = {{ to_node(case["expected"]) | indent(4) }} - result == Ok expected + result == Ok(expected) {%- endif %} diff --git a/exercises/practice/sgf-parsing/sgf-parsing-test.roc b/exercises/practice/sgf-parsing/sgf-parsing-test.roc index 93ae8277..a1d2de51 100644 --- a/exercises/practice/sgf-parsing/sgf-parsing-test.roc +++ b/exercises/practice/sgf-parsing/sgf-parsing-test.roc @@ -40,7 +40,7 @@ expect properties: Dict.from_list [], children: [], } - result == Ok expected + result == Ok(expected) # single node tree expect @@ -53,7 +53,7 @@ expect ], children: [], } - result == Ok expected + result == Ok(expected) # multiple properties expect @@ -67,7 +67,7 @@ expect ], children: [], } - result == Ok expected + result == Ok(expected) # properties without delimiter expect @@ -105,7 +105,7 @@ expect }, ], } - result == Ok expected + result == Ok(expected) # two child trees expect @@ -131,7 +131,7 @@ expect }, ], } - result == Ok expected + result == Ok(expected) # multiple property values expect @@ -144,7 +144,7 @@ expect ], children: [], } - result == Ok expected + result == Ok(expected) # within property values, whitespace characters such as tab are converted to spaces expect @@ -157,7 +157,7 @@ expect ], children: [], } - result == Ok expected + result == Ok(expected) # within property values, newlines remain as newlines expect @@ -170,7 +170,7 @@ expect ], children: [], } - result == Ok expected + result == Ok(expected) # escaped closing bracket within property value becomes just a closing bracket expect @@ -183,7 +183,7 @@ expect ], children: [], } - result == Ok expected + result == Ok(expected) # escaped backslash in property value becomes just a backslash expect @@ -196,7 +196,7 @@ expect ], children: [], } - result == Ok expected + result == Ok(expected) # opening bracket within property value doesn't need to be escaped expect @@ -217,7 +217,7 @@ expect }, ], } - result == Ok expected + result == Ok(expected) # semicolon in property value doesn't need to be escaped expect @@ -238,7 +238,7 @@ expect }, ], } - result == Ok expected + result == Ok(expected) # parentheses in property value don't need to be escaped expect @@ -259,7 +259,7 @@ expect }, ], } - result == Ok expected + result == Ok(expected) # escaped tab in property value is converted to space expect @@ -272,7 +272,7 @@ expect ], children: [], } - result == Ok expected + result == Ok(expected) # escaped newline in property value is converted to nothing at all expect @@ -285,7 +285,7 @@ expect ], children: [], } - result == Ok expected + result == Ok(expected) # escaped t and n in property value are just letters, not whitespace expect @@ -298,7 +298,7 @@ expect ], children: [], } - result == Ok expected + result == Ok(expected) # mixing various kinds of whitespace and escaped characters in property value expect @@ -311,5 +311,5 @@ expect ], children: [], } - result == Ok expected + result == Ok(expected) diff --git a/exercises/practice/variable-length-quantity/.meta/template.j2 b/exercises/practice/variable-length-quantity/.meta/template.j2 index 6b1121e2..e0965421 100644 --- a/exercises/practice/variable-length-quantity/.meta/template.j2 +++ b/exercises/practice/variable-length-quantity/.meta/template.j2 @@ -24,7 +24,7 @@ expect {%- if case["expected"]["error"] %} result |> Result.is_err {%- else %} - expected = Ok {{ case["expected"] | to_roc }} + expected = Ok({{ case["expected"] | to_roc }}) result == expected {%- endif %} {%- endif %} diff --git a/exercises/practice/variable-length-quantity/variable-length-quantity-test.roc b/exercises/practice/variable-length-quantity/variable-length-quantity-test.roc index de37bb05..c6af1750 100644 --- a/exercises/practice/variable-length-quantity/variable-length-quantity-test.roc +++ b/exercises/practice/variable-length-quantity/variable-length-quantity-test.roc @@ -185,35 +185,35 @@ expect expect bytes = [127] result = decode bytes - expected = Ok [127] + expected = Ok([127]) result == expected # two bytes expect bytes = [192, 0] result = decode bytes - expected = Ok [8192] + expected = Ok([8192]) result == expected # three bytes expect bytes = [255, 255, 127] result = decode bytes - expected = Ok [2097151] + expected = Ok([2097151]) result == expected # four bytes expect bytes = [129, 128, 128, 0] result = decode bytes - expected = Ok [2097152] + expected = Ok([2097152]) result == expected # maximum 32-bit integer expect bytes = [143, 255, 255, 255, 127] result = decode bytes - expected = Ok [4294967295] + expected = Ok([4294967295]) result == expected # incomplete sequence causes error @@ -232,6 +232,6 @@ expect expect bytes = [192, 0, 200, 232, 86, 255, 255, 255, 127, 0, 255, 127, 129, 128, 0] result = decode bytes - expected = Ok [8192, 1193046, 268435455, 0, 16383, 16384] + expected = Ok([8192, 1193046, 268435455, 0, 16383, 16384]) result == expected diff --git a/exercises/practice/wordy/.meta/template.j2 b/exercises/practice/wordy/.meta/template.j2 index a6fbe2fe..d814b72c 100644 --- a/exercises/practice/wordy/.meta/template.j2 +++ b/exercises/practice/wordy/.meta/template.j2 @@ -9,9 +9,9 @@ import {{ exercise | to_pascal }} exposing [answer] expect result = {{ case["property"] | to_snake }}({{ case["input"]["question"] | to_roc }}) {%- if case["expected"]["error"] %} - Result.is_err result + Result.is_err(result) {%- else %} - result == Ok {{ case["expected"] }} + result == Ok({{ case["expected"] }}) {%- endif %} {% endfor %} diff --git a/exercises/practice/wordy/wordy-test.roc b/exercises/practice/wordy/wordy-test.roc index 7a09a8dd..d4b30112 100644 --- a/exercises/practice/wordy/wordy-test.roc +++ b/exercises/practice/wordy/wordy-test.roc @@ -15,135 +15,135 @@ import Wordy exposing [answer] # just a number expect result = answer("What is 5?") - result == Ok 5 + result == Ok(5) # just a zero expect result = answer("What is 0?") - result == Ok 0 + result == Ok(0) # just a negative number expect result = answer("What is -123?") - result == Ok -123 + result == Ok(-123) # addition expect result = answer("What is 1 plus 1?") - result == Ok 2 + result == Ok(2) # addition with a left hand zero expect result = answer("What is 0 plus 2?") - result == Ok 2 + result == Ok(2) # addition with a right hand zero expect result = answer("What is 3 plus 0?") - result == Ok 3 + result == Ok(3) # more addition expect result = answer("What is 53 plus 2?") - result == Ok 55 + result == Ok(55) # addition with negative numbers expect result = answer("What is -1 plus -10?") - result == Ok -11 + result == Ok(-11) # large addition expect result = answer("What is 123 plus 45678?") - result == Ok 45801 + result == Ok(45801) # subtraction expect result = answer("What is 4 minus -12?") - result == Ok 16 + result == Ok(16) # multiplication expect result = answer("What is -3 multiplied by 25?") - result == Ok -75 + result == Ok(-75) # division expect result = answer("What is 33 divided by -3?") - result == Ok -11 + result == Ok(-11) # multiple additions expect result = answer("What is 1 plus 1 plus 1?") - result == Ok 3 + result == Ok(3) # addition and subtraction expect result = answer("What is 1 plus 5 minus -2?") - result == Ok 8 + result == Ok(8) # multiple subtraction expect result = answer("What is 20 minus 4 minus 13?") - result == Ok 3 + result == Ok(3) # subtraction then addition expect result = answer("What is 17 minus 6 plus 3?") - result == Ok 14 + result == Ok(14) # multiple multiplication expect result = answer("What is 2 multiplied by -2 multiplied by 3?") - result == Ok -12 + result == Ok(-12) # addition and multiplication expect result = answer("What is -3 plus 7 multiplied by -2?") - result == Ok -8 + result == Ok(-8) # multiple division expect result = answer("What is -12 divided by 2 divided by -3?") - result == Ok 2 + result == Ok(2) # unknown operation expect result = answer("What is 52 cubed?") - Result.is_err result + Result.is_err(result) # Non math question expect result = answer("Who is the President of the United States?") - Result.is_err result + Result.is_err(result) # reject problem missing an operand expect result = answer("What is 1 plus?") - Result.is_err result + Result.is_err(result) # reject problem with no operands or operators expect result = answer("What is?") - Result.is_err result + Result.is_err(result) # reject two operations in a row expect result = answer("What is 1 plus plus 2?") - Result.is_err result + Result.is_err(result) # reject two numbers in a row expect result = answer("What is 1 plus 2 1?") - Result.is_err result + Result.is_err(result) # reject postfix notation expect result = answer("What is 1 2 plus?") - Result.is_err result + Result.is_err(result) # reject prefix notation expect result = answer("What is plus 1 2?") - Result.is_err result + Result.is_err(result) diff --git a/exercises/practice/zebra-puzzle/.meta/template.j2 b/exercises/practice/zebra-puzzle/.meta/template.j2 index 80259686..70da5c15 100644 --- a/exercises/practice/zebra-puzzle/.meta/template.j2 +++ b/exercises/practice/zebra-puzzle/.meta/template.j2 @@ -8,6 +8,6 @@ import {{ exercise | to_pascal }} exposing [owns_zebra, drinks_water] # {{ case["description"] }} expect result = {{ case["property"] | to_snake }} - result == Ok {{ case["expected"] }} + result == Ok({{ case["expected"] }}) {% endfor %} diff --git a/exercises/practice/zebra-puzzle/zebra-puzzle-test.roc b/exercises/practice/zebra-puzzle/zebra-puzzle-test.roc index 796fe340..09f924cc 100644 --- a/exercises/practice/zebra-puzzle/zebra-puzzle-test.roc +++ b/exercises/practice/zebra-puzzle/zebra-puzzle-test.roc @@ -15,10 +15,10 @@ import ZebraPuzzle exposing [owns_zebra, drinks_water] # resident who drinks water expect result = drinks_water - result == Ok Norwegian + result == Ok(Norwegian) # resident who owns zebra expect result = owns_zebra - result == Ok Japanese + result == Ok(Japanese) From 132421d17e8e2af23146da5f309f67d755fe64ba Mon Sep 17 00:00:00 2001 From: Anton-4 <17049058+Anton-4@users.noreply.github.com> Date: Sat, 26 Jul 2025 19:01:59 +0200 Subject: [PATCH 5/8] more syntax updates --- .../practice/accumulate/.meta/template.j2 | 4 +- .../practice/accumulate/accumulate-test.roc | 4 +- .../practice/allergies/.meta/template.j2 | 2 +- .../practice/allergies/allergies-test.roc | 20 +- exercises/practice/bowling/.meta/template.j2 | 4 +- exercises/practice/bowling/bowling-test.roc | 92 +++--- .../circular-buffer/.meta/template.j2 | 10 +- .../circular-buffer/circular-buffer-test.roc | 84 +++--- .../collatz-conjecture/.meta/template.j2 | 2 +- .../collatz-conjecture-test.roc | 2 +- exercises/practice/connect/.meta/template.j2 | 2 +- exercises/practice/connect/connect-test.roc | 8 +- .../practice/custom-set/.meta/template.j2 | 10 +- .../practice/custom-set/custom-set-test.roc | 214 +++++++------- exercises/practice/dominoes/.meta/template.j2 | 3 +- exercises/practice/dominoes/dominoes-test.roc | 6 +- exercises/practice/etl/.meta/template.j2 | 8 +- exercises/practice/etl/etl-test.roc | 142 +++++---- exercises/practice/forth/.meta/template.j2 | 2 +- exercises/practice/forth/forth-test.roc | 32 +-- .../practice/go-counting/.meta/template.j2 | 4 +- .../practice/go-counting/go-counting-test.roc | 72 +++-- exercises/practice/grains/.meta/template.j2 | 2 +- exercises/practice/grains/grains-test.roc | 4 +- .../nucleotide-count/.meta/template.j2 | 2 +- .../nucleotide-count-test.roc | 2 +- .../palindrome-products/.meta/template.j2 | 4 +- .../palindrome-products-test.roc | 86 +++--- .../perfect-numbers/.meta/template.j2 | 2 +- .../perfect-numbers/perfect-numbers-test.roc | 2 +- .../pythagorean-triplet/.meta/template.j2 | 4 +- .../pythagorean-triplet-test.roc | 74 +++-- exercises/practice/rest-api/.meta/template.j2 | 8 +- exercises/practice/rest-api/rest-api-test.roc | 124 ++++---- .../practice/saddle-points/.meta/template.j2 | 4 +- .../saddle-points/saddle-points-test.roc | 82 +++--- .../practice/sgf-parsing/.meta/template.j2 | 4 +- .../practice/sgf-parsing/sgf-parsing-test.roc | 186 +++++++----- .../practice/word-count/.meta/template.j2 | 4 +- .../practice/word-count/word-count-test.roc | 192 +++++++------ .../practice/word-search/.meta/template.j2 | 4 +- .../practice/word-search/word-search-test.roc | 272 ++++++++++-------- 42 files changed, 1007 insertions(+), 782 deletions(-) diff --git a/exercises/practice/accumulate/.meta/template.j2 b/exercises/practice/accumulate/.meta/template.j2 index 450806a5..1ca22045 100644 --- a/exercises/practice/accumulate/.meta/template.j2 +++ b/exercises/practice/accumulate/.meta/template.j2 @@ -8,7 +8,7 @@ import {{ exercise | to_pascal }} exposing [{{ cases[0]["property"] | to_snake } "(x) => x * x": "|x|\n x * x", "(x) => upcase(x)": "to_upper", "(x) => reverse(x)": "reverse", - "(x) => accumulate([\"1\", \"2\", \"3\"], (y) => x + y)": "|x|\n accumulate [\"1\", \"2\", \"3\"] (\\y -> Str.concat x y)" + "(x) => accumulate([\"1\", \"2\", \"3\"], (y) => x + y)": "|x|\n accumulate [\"1\", \"2\", \"3\"] (\\y -> Str.concat(x, y))" } -%} {% for case in cases -%} @@ -28,7 +28,7 @@ reverse = |str| to_upper : Str -> Str to_upper = |str| - Str.to_utf8 str + Str.to_utf8(str) |> List.map( |byte| if 'a' <= byte && byte <= 'z' then diff --git a/exercises/practice/accumulate/accumulate-test.roc b/exercises/practice/accumulate/accumulate-test.roc index 0605d796..fd2acf16 100644 --- a/exercises/practice/accumulate/accumulate-test.roc +++ b/exercises/practice/accumulate/accumulate-test.roc @@ -45,7 +45,7 @@ expect result = accumulate( ["a", "b", "c"], |x| - accumulate ["1", "2", "3"] (|y| Str.concat x y), + accumulate ["1", "2", "3"] (|y| Str.concat(x, y)), ) result == [["a1", "a2", "a3"], ["b1", "b2", "b3"], ["c1", "c2", "c3"]] @@ -58,7 +58,7 @@ reverse = |str| to_upper : Str -> Str to_upper = |str| - Str.to_utf8 str + Str.to_utf8(str) |> List.map( |byte| if 'a' <= byte and byte <= 'z' then diff --git a/exercises/practice/allergies/.meta/template.j2 b/exercises/practice/allergies/.meta/template.j2 index 504099c2..33f1aa05 100644 --- a/exercises/practice/allergies/.meta/template.j2 +++ b/exercises/practice/allergies/.meta/template.j2 @@ -12,7 +12,7 @@ expect result = allergic_to({{ case["input"]["item"] | to_pascal }}, {{ case["input"]["score"] | to_roc }}) result == {{ case["expected"] | to_roc }} {%- else %} - result = set {{ case["input"]["score"] }} + result = set({{ case["input"]["score"] }}) result == Set.from_list([{{ case["expected"] | map('to_pascal') | join(", ") }}]) {%- endif %} diff --git a/exercises/practice/allergies/allergies-test.roc b/exercises/practice/allergies/allergies-test.roc index 8bcd2743..e2f4f52d 100644 --- a/exercises/practice/allergies/allergies-test.roc +++ b/exercises/practice/allergies/allergies-test.roc @@ -214,51 +214,51 @@ expect # list when: no allergies expect - result = set 0 + result = set(0) result == Set.from_list([]) # list when: just eggs expect - result = set 1 + result = set(1) result == Set.from_list([Eggs]) # list when: just peanuts expect - result = set 2 + result = set(2) result == Set.from_list([Peanuts]) # list when: just strawberries expect - result = set 8 + result = set(8) result == Set.from_list([Strawberries]) # list when: eggs and peanuts expect - result = set 3 + result = set(3) result == Set.from_list([Eggs, Peanuts]) # list when: more than eggs but not peanuts expect - result = set 5 + result = set(5) result == Set.from_list([Eggs, Shellfish]) # list when: lots of stuff expect - result = set 248 + result = set(248) result == Set.from_list([Strawberries, Tomatoes, Chocolate, Pollen, Cats]) # list when: everything expect - result = set 255 + result = set(255) result == Set.from_list([Eggs, Peanuts, Shellfish, Strawberries, Tomatoes, Chocolate, Pollen, Cats]) # list when: no allergen score parts expect - result = set 509 + result = set(509) result == Set.from_list([Eggs, Shellfish, Strawberries, Tomatoes, Chocolate, Pollen, Cats]) # list when: no allergen score parts without highest valid score expect - result = set 257 + result = set(257) result == Set.from_list([Eggs]) diff --git a/exercises/practice/bowling/.meta/template.j2 b/exercises/practice/bowling/.meta/template.j2 index e462a07d..17e2f490 100644 --- a/exercises/practice/bowling/.meta/template.j2 +++ b/exercises/practice/bowling/.meta/template.j2 @@ -24,7 +24,7 @@ replay_game = |rolls| {% for case in cases -%} # {{ case["description"] }} expect - maybe_game = create { previous_rolls : {{ case["input"]["previousRolls"] | to_roc }} } + maybe_game = create({ previous_rolls : {{ case["input"]["previousRolls"] | to_roc }} }) {%- if case["property"] == "score" %} result = maybe_game |> Result.try(|game| score(game)) {%- else %} @@ -41,7 +41,7 @@ expect # should be able to replay this finished game from the start expect rolls = {{ case["input"]["previousRolls"] | to_roc }} - result = replay_game rolls + result = replay_game(rolls) result |> Result.is_ok {%- endif %} diff --git a/exercises/practice/bowling/bowling-test.roc b/exercises/practice/bowling/bowling-test.roc index 26e7f410..4bacc4ff 100644 --- a/exercises/practice/bowling/bowling-test.roc +++ b/exercises/practice/bowling/bowling-test.roc @@ -30,187 +30,187 @@ replay_game = |rolls| # should be able to score a game with all zeros expect - maybe_game = create { previous_rolls: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] } + maybe_game = create({ previous_rolls: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] }) result = maybe_game |> Result.try(|game| score(game)) result == Ok(0) # should be able to replay this finished game from the start expect rolls = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] - result = replay_game rolls + result = replay_game(rolls) result |> Result.is_ok # should be able to score a game with no strikes or spares expect - maybe_game = create { previous_rolls: [3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6] } + maybe_game = create({ previous_rolls: [3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6] }) result = maybe_game |> Result.try(|game| score(game)) result == Ok(90) # should be able to replay this finished game from the start expect rolls = [3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6] - result = replay_game rolls + result = replay_game(rolls) result |> Result.is_ok # a spare followed by zeros is worth ten points expect - maybe_game = create { previous_rolls: [6, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] } + maybe_game = create({ previous_rolls: [6, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] }) result = maybe_game |> Result.try(|game| score(game)) result == Ok(10) # should be able to replay this finished game from the start expect rolls = [6, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] - result = replay_game rolls + result = replay_game(rolls) result |> Result.is_ok # points scored in the roll after a spare are counted twice expect - maybe_game = create { previous_rolls: [6, 4, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] } + maybe_game = create({ previous_rolls: [6, 4, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] }) result = maybe_game |> Result.try(|game| score(game)) result == Ok(16) # should be able to replay this finished game from the start expect rolls = [6, 4, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] - result = replay_game rolls + result = replay_game(rolls) result |> Result.is_ok # consecutive spares each get a one roll bonus expect - maybe_game = create { previous_rolls: [5, 5, 3, 7, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] } + maybe_game = create({ previous_rolls: [5, 5, 3, 7, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] }) result = maybe_game |> Result.try(|game| score(game)) result == Ok(31) # should be able to replay this finished game from the start expect rolls = [5, 5, 3, 7, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] - result = replay_game rolls + result = replay_game(rolls) result |> Result.is_ok # a spare in the last frame gets a one roll bonus that is counted once expect - maybe_game = create { previous_rolls: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 3, 7] } + maybe_game = create({ previous_rolls: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 3, 7] }) result = maybe_game |> Result.try(|game| score(game)) result == Ok(17) # should be able to replay this finished game from the start expect rolls = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 3, 7] - result = replay_game rolls + result = replay_game(rolls) result |> Result.is_ok # a strike earns ten points in a frame with a single roll expect - maybe_game = create { previous_rolls: [10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] } + maybe_game = create({ previous_rolls: [10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] }) result = maybe_game |> Result.try(|game| score(game)) result == Ok(10) # should be able to replay this finished game from the start expect rolls = [10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] - result = replay_game rolls + result = replay_game(rolls) result |> Result.is_ok # points scored in the two rolls after a strike are counted twice as a bonus expect - maybe_game = create { previous_rolls: [10, 5, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] } + maybe_game = create({ previous_rolls: [10, 5, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] }) result = maybe_game |> Result.try(|game| score(game)) result == Ok(26) # should be able to replay this finished game from the start expect rolls = [10, 5, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] - result = replay_game rolls + result = replay_game(rolls) result |> Result.is_ok # consecutive strikes each get the two roll bonus expect - maybe_game = create { previous_rolls: [10, 10, 10, 5, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] } + maybe_game = create({ previous_rolls: [10, 10, 10, 5, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] }) result = maybe_game |> Result.try(|game| score(game)) result == Ok(81) # should be able to replay this finished game from the start expect rolls = [10, 10, 10, 5, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] - result = replay_game rolls + result = replay_game(rolls) result |> Result.is_ok # a strike in the last frame gets a two roll bonus that is counted once expect - maybe_game = create { previous_rolls: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 7, 1] } + maybe_game = create({ previous_rolls: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 7, 1] }) result = maybe_game |> Result.try(|game| score(game)) result == Ok(18) # should be able to replay this finished game from the start expect rolls = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 7, 1] - result = replay_game rolls + result = replay_game(rolls) result |> Result.is_ok # rolling a spare with the two roll bonus does not get a bonus roll expect - maybe_game = create { previous_rolls: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 7, 3] } + maybe_game = create({ previous_rolls: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 7, 3] }) result = maybe_game |> Result.try(|game| score(game)) result == Ok(20) # should be able to replay this finished game from the start expect rolls = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 7, 3] - result = replay_game rolls + result = replay_game(rolls) result |> Result.is_ok # strikes with the two roll bonus do not get bonus rolls expect - maybe_game = create { previous_rolls: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 10, 10] } + maybe_game = create({ previous_rolls: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 10, 10] }) result = maybe_game |> Result.try(|game| score(game)) result == Ok(30) # should be able to replay this finished game from the start expect rolls = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 10, 10] - result = replay_game rolls + result = replay_game(rolls) result |> Result.is_ok # last two strikes followed by only last bonus with non strike points expect - maybe_game = create { previous_rolls: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 10, 0, 1] } + maybe_game = create({ previous_rolls: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 10, 0, 1] }) result = maybe_game |> Result.try(|game| score(game)) result == Ok(31) # should be able to replay this finished game from the start expect rolls = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 10, 0, 1] - result = replay_game rolls + result = replay_game(rolls) result |> Result.is_ok # a strike with the one roll bonus after a spare in the last frame does not get a bonus expect - maybe_game = create { previous_rolls: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 3, 10] } + maybe_game = create({ previous_rolls: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 3, 10] }) result = maybe_game |> Result.try(|game| score(game)) result == Ok(20) # should be able to replay this finished game from the start expect rolls = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 3, 10] - result = replay_game rolls + result = replay_game(rolls) result |> Result.is_ok # all strikes is a perfect game expect - maybe_game = create { previous_rolls: [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10] } + maybe_game = create({ previous_rolls: [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10] }) result = maybe_game |> Result.try(|game| score(game)) result == Ok(300) # should be able to replay this finished game from the start expect rolls = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10] - result = replay_game rolls + result = replay_game(rolls) result |> Result.is_ok # a roll cannot score more than 10 points expect - maybe_game = create { previous_rolls: [] } + maybe_game = create({ previous_rolls: [] }) result = maybe_game |> Result.try( @@ -221,7 +221,7 @@ expect # two rolls in a frame cannot score more than 10 points expect - maybe_game = create { previous_rolls: [5] } + maybe_game = create({ previous_rolls: [5] }) result = maybe_game |> Result.try( @@ -232,7 +232,7 @@ expect # bonus roll after a strike in the last frame cannot score more than 10 points expect - maybe_game = create { previous_rolls: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10] } + maybe_game = create({ previous_rolls: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10] }) result = maybe_game |> Result.try( @@ -243,7 +243,7 @@ expect # two bonus rolls after a strike in the last frame cannot score more than 10 points expect - maybe_game = create { previous_rolls: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 5] } + maybe_game = create({ previous_rolls: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 5] }) result = maybe_game |> Result.try( @@ -254,19 +254,19 @@ expect # two bonus rolls after a strike in the last frame can score more than 10 points if one is a strike expect - maybe_game = create { previous_rolls: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 10, 6] } + maybe_game = create({ previous_rolls: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 10, 6] }) result = maybe_game |> Result.try(|game| score(game)) result == Ok(26) # should be able to replay this finished game from the start expect rolls = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 10, 6] - result = replay_game rolls + result = replay_game(rolls) result |> Result.is_ok # the second bonus rolls after a strike in the last frame cannot be a strike if the first one is not a strike expect - maybe_game = create { previous_rolls: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 6] } + maybe_game = create({ previous_rolls: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 6] }) result = maybe_game |> Result.try( @@ -277,7 +277,7 @@ expect # second bonus roll after a strike in the last frame cannot score more than 10 points expect - maybe_game = create { previous_rolls: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 10] } + maybe_game = create({ previous_rolls: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 10] }) result = maybe_game |> Result.try( @@ -288,19 +288,19 @@ expect # an unstarted game cannot be scored expect - maybe_game = create { previous_rolls: [] } + maybe_game = create({ previous_rolls: [] }) result = maybe_game |> Result.try(|game| score(game)) result |> Result.is_err # an incomplete game cannot be scored expect - maybe_game = create { previous_rolls: [0, 0] } + maybe_game = create({ previous_rolls: [0, 0] }) result = maybe_game |> Result.try(|game| score(game)) result |> Result.is_err # cannot roll if game already has ten frames expect - maybe_game = create { previous_rolls: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] } + maybe_game = create({ previous_rolls: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] }) result = maybe_game |> Result.try( @@ -311,25 +311,25 @@ expect # bonus rolls for a strike in the last frame must be rolled before score can be calculated expect - maybe_game = create { previous_rolls: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10] } + maybe_game = create({ previous_rolls: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10] }) result = maybe_game |> Result.try(|game| score(game)) result |> Result.is_err # both bonus rolls for a strike in the last frame must be rolled before score can be calculated expect - maybe_game = create { previous_rolls: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 10] } + maybe_game = create({ previous_rolls: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 10] }) result = maybe_game |> Result.try(|game| score(game)) result |> Result.is_err # bonus roll for a spare in the last frame must be rolled before score can be calculated expect - maybe_game = create { previous_rolls: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 3] } + maybe_game = create({ previous_rolls: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 3] }) result = maybe_game |> Result.try(|game| score(game)) result |> Result.is_err # cannot roll after bonus roll for spare expect - maybe_game = create { previous_rolls: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 3, 2] } + maybe_game = create({ previous_rolls: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 3, 2] }) result = maybe_game |> Result.try( @@ -340,7 +340,7 @@ expect # cannot roll after bonus rolls for strike expect - maybe_game = create { previous_rolls: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 3, 2] } + maybe_game = create({ previous_rolls: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 3, 2] }) result = maybe_game |> Result.try( diff --git a/exercises/practice/circular-buffer/.meta/template.j2 b/exercises/practice/circular-buffer/.meta/template.j2 index 38f60295..f3565715 100644 --- a/exercises/practice/circular-buffer/.meta/template.j2 +++ b/exercises/practice/circular-buffer/.meta/template.j2 @@ -16,11 +16,11 @@ run_operations{{ loop.index }} = |_| |> overwrite {{ op["item"] }} {%- elif op["operation"] == "write" %} {%- if op["should_succeed"] %} - |> write? {{ op["item"] }} + |> write({{ op["item"] }})? {%- else %} - |> \buffer_before_write -> + |> |buffer_before_write| write_result = buffer_before_write |> write {{ op["item"] }} - expect write_result == Err BufferFull + expect write_result == Err(BufferFull) buffer_before_write {%- endif %} {%- elif op["operation"] == "read" %} @@ -31,7 +31,7 @@ run_operations{{ loop.index }} = |_| {%- else %} |> |buffer_before_read| read_result = buffer_before_read |> read - expect read_result == Err BufferEmpty + expect read_result == Err(BufferEmpty) buffer_before_read {%- endif %} {%- endif %} @@ -40,7 +40,7 @@ run_operations{{ loop.index }} = |_| expect - result = run_operations{{ loop.index }} {} + result = run_operations{{ loop.index }}({}) result |> Result.is_ok {% endfor %} diff --git a/exercises/practice/circular-buffer/circular-buffer-test.roc b/exercises/practice/circular-buffer/circular-buffer-test.roc index 303fa32e..2b186309 100644 --- a/exercises/practice/circular-buffer/circular-buffer-test.roc +++ b/exercises/practice/circular-buffer/circular-buffer-test.roc @@ -18,19 +18,19 @@ run_operations1 = |_| create { capacity: 1 } |> |buffer_before_read| read_result = buffer_before_read |> read - expect read_result == Err BufferEmpty + expect read_result == Err(BufferEmpty) buffer_before_read Ok(result) expect - result = run_operations1 {} + result = run_operations1({}) result |> Result.is_ok # can read an item just written run_operations2 = |_| result = create { capacity: 1 } - |> write? 1 + |> write(1)? |> read? |> |read_result| expect read_result.value == 1 @@ -38,34 +38,34 @@ run_operations2 = |_| Ok(result) expect - result = run_operations2 {} + result = run_operations2({}) result |> Result.is_ok # each item may only be read once run_operations3 = |_| result = create { capacity: 1 } - |> write? 1 + |> write(1)? |> read? |> |read_result| expect read_result.value == 1 read_result.new_buffer |> |buffer_before_read| read_result = buffer_before_read |> read - expect read_result == Err BufferEmpty + expect read_result == Err(BufferEmpty) buffer_before_read Ok(result) expect - result = run_operations3 {} + result = run_operations3({}) result |> Result.is_ok # items are read in the order they are written run_operations4 = |_| result = create { capacity: 2 } - |> write? 1 - |> write? 2 + |> write(1)? + |> write(2)? |> read? |> |read_result| expect read_result.value == 1 @@ -77,34 +77,34 @@ run_operations4 = |_| Ok(result) expect - result = run_operations4 {} + result = run_operations4({}) result |> Result.is_ok # full buffer can't be written to run_operations5 = |_| result = create { capacity: 1 } - |> write? 1 + |> write(1)? |> |buffer_before_write| write_result = buffer_before_write |> write 2 - expect write_result == Err BufferFull + expect write_result == Err(BufferFull) buffer_before_write Ok(result) expect - result = run_operations5 {} + result = run_operations5({}) result |> Result.is_ok # a read frees up capacity for another write run_operations6 = |_| result = create { capacity: 1 } - |> write? 1 + |> write(1)? |> read? |> |read_result| expect read_result.value == 1 read_result.new_buffer - |> write? 2 + |> write(2)? |> read? |> |read_result| expect read_result.value == 2 @@ -112,20 +112,20 @@ run_operations6 = |_| Ok(result) expect - result = run_operations6 {} + result = run_operations6({}) result |> Result.is_ok # read position is maintained even across multiple writes run_operations7 = |_| result = create { capacity: 3 } - |> write? 1 - |> write? 2 + |> write(1)? + |> write(2)? |> read? |> |read_result| expect read_result.value == 1 read_result.new_buffer - |> write? 3 + |> write(3)? |> read? |> |read_result| expect read_result.value == 2 @@ -137,32 +137,32 @@ run_operations7 = |_| Ok(result) expect - result = run_operations7 {} + result = run_operations7({}) result |> Result.is_ok # items cleared out of buffer can't be read run_operations8 = |_| result = create { capacity: 1 } - |> write? 1 + |> write(1)? |> clear |> |buffer_before_read| read_result = buffer_before_read |> read - expect read_result == Err BufferEmpty + expect read_result == Err(BufferEmpty) buffer_before_read Ok(result) expect - result = run_operations8 {} + result = run_operations8({}) result |> Result.is_ok # clear frees up capacity for another write run_operations9 = |_| result = create { capacity: 1 } - |> write? 1 + |> write(1)? |> clear - |> write? 2 + |> write(2)? |> read? |> |read_result| expect read_result.value == 2 @@ -170,7 +170,7 @@ run_operations9 = |_| Ok(result) expect - result = run_operations9 {} + result = run_operations9({}) result |> Result.is_ok # clear does nothing on empty buffer @@ -178,7 +178,7 @@ run_operations10 = |_| result = create { capacity: 1 } |> clear - |> write? 1 + |> write(1)? |> read? |> |read_result| expect read_result.value == 1 @@ -186,14 +186,14 @@ run_operations10 = |_| Ok(result) expect - result = run_operations10 {} + result = run_operations10({}) result |> Result.is_ok # overwrite acts like write on non-full buffer run_operations11 = |_| result = create { capacity: 2 } - |> write? 1 + |> write(1)? |> overwrite 2 |> read? |> |read_result| @@ -206,15 +206,15 @@ run_operations11 = |_| Ok(result) expect - result = run_operations11 {} + result = run_operations11({}) result |> Result.is_ok # overwrite replaces the oldest item on full buffer run_operations12 = |_| result = create { capacity: 2 } - |> write? 1 - |> write? 2 + |> write(1)? + |> write(2)? |> overwrite 3 |> read? |> |read_result| @@ -227,21 +227,21 @@ run_operations12 = |_| Ok(result) expect - result = run_operations12 {} + result = run_operations12({}) result |> Result.is_ok # overwrite replaces the oldest item remaining in buffer following a read run_operations13 = |_| result = create { capacity: 3 } - |> write? 1 - |> write? 2 - |> write? 3 + |> write(1)? + |> write(2)? + |> write(3)? |> read? |> |read_result| expect read_result.value == 1 read_result.new_buffer - |> write? 4 + |> write(4)? |> overwrite 5 |> read? |> |read_result| @@ -258,7 +258,7 @@ run_operations13 = |_| Ok(result) expect - result = run_operations13 {} + result = run_operations13({}) result |> Result.is_ok # initial clear does not affect wrapping around @@ -266,8 +266,8 @@ run_operations14 = |_| result = create { capacity: 2 } |> clear - |> write? 1 - |> write? 2 + |> write(1)? + |> write(2)? |> overwrite 3 |> overwrite 4 |> read? @@ -280,11 +280,11 @@ run_operations14 = |_| read_result.new_buffer |> |buffer_before_read| read_result = buffer_before_read |> read - expect read_result == Err BufferEmpty + expect read_result == Err(BufferEmpty) buffer_before_read Ok(result) expect - result = run_operations14 {} + result = run_operations14({}) result |> Result.is_ok diff --git a/exercises/practice/collatz-conjecture/.meta/template.j2 b/exercises/practice/collatz-conjecture/.meta/template.j2 index 2b3056fd..ce67bec3 100644 --- a/exercises/practice/collatz-conjecture/.meta/template.j2 +++ b/exercises/practice/collatz-conjecture/.meta/template.j2 @@ -9,7 +9,7 @@ import {{ exercise | to_pascal }} exposing [steps] expect result = {{ case["property"] | to_snake }}({{ case["input"]["number"] }}) {%- if case["expected"]["error"] %} - Result.is_err result + Result.is_err(result) {%- else %} result == Ok({{ case["expected"] }}) {%- endif %} diff --git a/exercises/practice/collatz-conjecture/collatz-conjecture-test.roc b/exercises/practice/collatz-conjecture/collatz-conjecture-test.roc index 053f7e10..64773c4a 100644 --- a/exercises/practice/collatz-conjecture/collatz-conjecture-test.roc +++ b/exercises/practice/collatz-conjecture/collatz-conjecture-test.roc @@ -35,5 +35,5 @@ expect # zero is an error expect result = steps(0) - Result.is_err result + Result.is_err(result) diff --git a/exercises/practice/connect/.meta/template.j2 b/exercises/practice/connect/.meta/template.j2 index 34fb2ad5..25aa62ac 100644 --- a/exercises/practice/connect/.meta/template.j2 +++ b/exercises/practice/connect/.meta/template.j2 @@ -9,6 +9,6 @@ import {{ exercise | to_pascal }} exposing [{{ cases[0]["property"] | to_snake } expect board = {{ case["input"]["board"] | to_roc_multiline_string | indent(8) }} result = board |> {{ case["property"] | to_snake }} - result == {% if case["expected"] == "" %}Err NotFinished{% else %}Ok(Player{{ case["expected"] }}){% endif %} + result == {% if case["expected"] == "" %}Err(NotFinished){% else %}Ok(Player{{ case["expected"] }}){% endif %} {% endfor %} diff --git a/exercises/practice/connect/connect-test.roc b/exercises/practice/connect/connect-test.roc index b558dc0d..9e49daab 100644 --- a/exercises/practice/connect/connect-test.roc +++ b/exercises/practice/connect/connect-test.roc @@ -23,7 +23,7 @@ expect . . . . . """ result = board |> winner - result == Err NotFinished + result == Err(NotFinished) # X can win on a 1x1 board expect @@ -47,7 +47,7 @@ expect X O O O """ result = board |> winner - result == Err NotFinished + result == Err(NotFinished) # illegal diagonal does not make a winner expect @@ -60,7 +60,7 @@ expect X X O O """ result = board |> winner - result == Err NotFinished + result == Err(NotFinished) # nobody wins crossing adjacent angles expect @@ -73,7 +73,7 @@ expect . . O . """ result = board |> winner - result == Err NotFinished + result == Err(NotFinished) # X wins crossing from left to right expect diff --git a/exercises/practice/custom-set/.meta/template.j2 b/exercises/practice/custom-set/.meta/template.j2 index 6ab44eea..188d3a2a 100644 --- a/exercises/practice/custom-set/.meta/template.j2 +++ b/exercises/practice/custom-set/.meta/template.j2 @@ -36,13 +36,13 @@ set property_map = { {% set property = property_map.get(case["property"], case["property"]) %} expect {%- if "set" in case["input"] %} - set = from_list {{ case["input"]["set"] | to_roc }} + set = from_list({{ case["input"]["set"] | to_roc }}) result = set |> {{ property | to_snake }} {%- if "element" in case["input"] %} {{ case["input"]["element"] }}{%- endif %} {%- else %} - set1 = from_list {{ case["input"]["set1"] | to_roc }} - set2 = from_list {{ case["input"]["set2"] | to_roc }} - result = set1 |> {{ property | to_snake }} set2 + set1 = from_list({{ case["input"]["set1"] | to_roc }}) + set2 = from_list({{ case["input"]["set2"] | to_roc }}) + result = set1 |> {{ property | to_snake }}(set2) {%- endif %} {%- if case["expected"] is iterable %} expected = {{ case["expected"] | to_roc }} |> from_list @@ -62,7 +62,7 @@ expect {% for case in additional_cases -%} # {{ case["description"] }} expect - set = from_list {{ case["input"]["set"] | to_roc }} + set = from_list({{ case["input"]["set"] | to_roc }}) result = set |> to_list |> List.sort_asc expected = {{ case["expected"] | to_roc }} result == expected diff --git a/exercises/practice/custom-set/custom-set-test.roc b/exercises/practice/custom-set/custom-set-test.roc index bfab4da7..c51c9d97 100644 --- a/exercises/practice/custom-set/custom-set-test.roc +++ b/exercises/practice/custom-set/custom-set-test.roc @@ -31,7 +31,7 @@ import CustomSet exposing [ # sets with no elements are empty expect - set = from_list [] + set = from_list([]) result = set |> is_empty expected = Bool.true result == expected @@ -39,7 +39,7 @@ expect # sets with elements are not empty expect - set = from_list [1] + set = from_list([1]) result = set |> is_empty expected = Bool.false result == expected @@ -51,7 +51,7 @@ expect # nothing is contained in an empty set expect - set = from_list [] + set = from_list([]) result = set |> contains 1 expected = Bool.false result == expected @@ -59,7 +59,7 @@ expect # when the element is in the set expect - set = from_list [1, 2, 3] + set = from_list([1, 2, 3]) result = set |> contains 1 expected = Bool.true result == expected @@ -67,7 +67,7 @@ expect # when the element is not in the set expect - set = from_list [1, 2, 3] + set = from_list([1, 2, 3]) result = set |> contains 4 expected = Bool.false result == expected @@ -79,54 +79,54 @@ expect # empty set is a subset of another empty set expect - set1 = from_list [] - set2 = from_list [] - result = set1 |> is_subset_of set2 + set1 = from_list([]) + set2 = from_list([]) + result = set1 |> is_subset_of(set2) expected = Bool.true result == expected # empty set is a subset of non-empty set expect - set1 = from_list [] - set2 = from_list [1] - result = set1 |> is_subset_of set2 + set1 = from_list([]) + set2 = from_list([1]) + result = set1 |> is_subset_of(set2) expected = Bool.true result == expected # non-empty set is not a subset of empty set expect - set1 = from_list [1] - set2 = from_list [] - result = set1 |> is_subset_of set2 + set1 = from_list([1]) + set2 = from_list([]) + result = set1 |> is_subset_of(set2) expected = Bool.false result == expected # set is a subset of set with exact same elements expect - set1 = from_list [1, 2, 3] - set2 = from_list [1, 2, 3] - result = set1 |> is_subset_of set2 + set1 = from_list([1, 2, 3]) + set2 = from_list([1, 2, 3]) + result = set1 |> is_subset_of(set2) expected = Bool.true result == expected # set is a subset of larger set with same elements expect - set1 = from_list [1, 2, 3] - set2 = from_list [4, 1, 2, 3] - result = set1 |> is_subset_of set2 + set1 = from_list([1, 2, 3]) + set2 = from_list([4, 1, 2, 3]) + result = set1 |> is_subset_of(set2) expected = Bool.true result == expected # set is not a subset of set that does not contain its elements expect - set1 = from_list [1, 2, 3] - set2 = from_list [4, 1, 3] - result = set1 |> is_subset_of set2 + set1 = from_list([1, 2, 3]) + set2 = from_list([4, 1, 3]) + result = set1 |> is_subset_of(set2) expected = Bool.false result == expected @@ -137,45 +137,45 @@ expect # the empty set is disjoint with itself expect - set1 = from_list [] - set2 = from_list [] - result = set1 |> is_disjoint_with set2 + set1 = from_list([]) + set2 = from_list([]) + result = set1 |> is_disjoint_with(set2) expected = Bool.true result == expected # empty set is disjoint with non-empty set expect - set1 = from_list [] - set2 = from_list [1] - result = set1 |> is_disjoint_with set2 + set1 = from_list([]) + set2 = from_list([1]) + result = set1 |> is_disjoint_with(set2) expected = Bool.true result == expected # non-empty set is disjoint with empty set expect - set1 = from_list [1] - set2 = from_list [] - result = set1 |> is_disjoint_with set2 + set1 = from_list([1]) + set2 = from_list([]) + result = set1 |> is_disjoint_with(set2) expected = Bool.true result == expected # sets are not disjoint if they share an element expect - set1 = from_list [1, 2] - set2 = from_list [2, 3] - result = set1 |> is_disjoint_with set2 + set1 = from_list([1, 2]) + set2 = from_list([2, 3]) + result = set1 |> is_disjoint_with(set2) expected = Bool.false result == expected # sets are disjoint if they share no elements expect - set1 = from_list [1, 2] - set2 = from_list [3, 4] - result = set1 |> is_disjoint_with set2 + set1 = from_list([1, 2]) + set2 = from_list([3, 4]) + result = set1 |> is_disjoint_with(set2) expected = Bool.true result == expected @@ -186,63 +186,63 @@ expect # empty sets are equal expect - set1 = from_list [] - set2 = from_list [] - result = set1 |> is_eq set2 + set1 = from_list([]) + set2 = from_list([]) + result = set1 |> is_eq(set2) expected = Bool.true result == expected # empty set is not equal to non-empty set expect - set1 = from_list [] - set2 = from_list [1, 2, 3] - result = set1 |> is_eq set2 + set1 = from_list([]) + set2 = from_list([1, 2, 3]) + result = set1 |> is_eq(set2) expected = Bool.false result == expected # non-empty set is not equal to empty set expect - set1 = from_list [1, 2, 3] - set2 = from_list [] - result = set1 |> is_eq set2 + set1 = from_list([1, 2, 3]) + set2 = from_list([]) + result = set1 |> is_eq(set2) expected = Bool.false result == expected # sets with the same elements are equal expect - set1 = from_list [1, 2] - set2 = from_list [2, 1] - result = set1 |> is_eq set2 + set1 = from_list([1, 2]) + set2 = from_list([2, 1]) + result = set1 |> is_eq(set2) expected = Bool.true result == expected # sets with different elements are not equal expect - set1 = from_list [1, 2, 3] - set2 = from_list [1, 2, 4] - result = set1 |> is_eq set2 + set1 = from_list([1, 2, 3]) + set2 = from_list([1, 2, 4]) + result = set1 |> is_eq(set2) expected = Bool.false result == expected # set is not equal to larger set with same elements expect - set1 = from_list [1, 2, 3] - set2 = from_list [1, 2, 3, 4] - result = set1 |> is_eq set2 + set1 = from_list([1, 2, 3]) + set2 = from_list([1, 2, 3, 4]) + result = set1 |> is_eq(set2) expected = Bool.false result == expected # set is equal to a set constructed from an array with duplicates expect - set1 = from_list [1] - set2 = from_list [1, 1] - result = set1 |> is_eq set2 + set1 = from_list([1]) + set2 = from_list([1, 1]) + result = set1 |> is_eq(set2) expected = Bool.true result == expected @@ -253,7 +253,7 @@ expect # add to empty set expect - set = from_list [] + set = from_list([]) result = set |> insert 3 expected = [3] |> from_list result |> is_eq expected @@ -261,7 +261,7 @@ expect # add to non-empty set expect - set = from_list [1, 2, 4] + set = from_list([1, 2, 4]) result = set |> insert 3 expected = [1, 2, 3, 4] |> from_list result |> is_eq expected @@ -269,7 +269,7 @@ expect # adding an existing element does not change the set expect - set = from_list [1, 2, 3] + set = from_list([1, 2, 3]) result = set |> insert 3 expected = [1, 2, 3] |> from_list result |> is_eq expected @@ -281,45 +281,45 @@ expect # intersection of two empty sets is an empty set expect - set1 = from_list [] - set2 = from_list [] - result = set1 |> intersection set2 + set1 = from_list([]) + set2 = from_list([]) + result = set1 |> intersection(set2) expected = [] |> from_list result |> is_eq expected # intersection of an empty set and non-empty set is an empty set expect - set1 = from_list [] - set2 = from_list [3, 2, 5] - result = set1 |> intersection set2 + set1 = from_list([]) + set2 = from_list([3, 2, 5]) + result = set1 |> intersection(set2) expected = [] |> from_list result |> is_eq expected # intersection of a non-empty set and an empty set is an empty set expect - set1 = from_list [1, 2, 3, 4] - set2 = from_list [] - result = set1 |> intersection set2 + set1 = from_list([1, 2, 3, 4]) + set2 = from_list([]) + result = set1 |> intersection(set2) expected = [] |> from_list result |> is_eq expected # intersection of two sets with no shared elements is an empty set expect - set1 = from_list [1, 2, 3] - set2 = from_list [4, 5, 6] - result = set1 |> intersection set2 + set1 = from_list([1, 2, 3]) + set2 = from_list([4, 5, 6]) + result = set1 |> intersection(set2) expected = [] |> from_list result |> is_eq expected # intersection of two sets with shared elements is a set of the shared elements expect - set1 = from_list [1, 2, 3, 4] - set2 = from_list [3, 2, 5] - result = set1 |> intersection set2 + set1 = from_list([1, 2, 3, 4]) + set2 = from_list([3, 2, 5]) + result = set1 |> intersection(set2) expected = [2, 3] |> from_list result |> is_eq expected @@ -330,45 +330,45 @@ expect # difference of two empty sets is an empty set expect - set1 = from_list [] - set2 = from_list [] - result = set1 |> difference set2 + set1 = from_list([]) + set2 = from_list([]) + result = set1 |> difference(set2) expected = [] |> from_list result |> is_eq expected # difference of empty set and non-empty set is an empty set expect - set1 = from_list [] - set2 = from_list [3, 2, 5] - result = set1 |> difference set2 + set1 = from_list([]) + set2 = from_list([3, 2, 5]) + result = set1 |> difference(set2) expected = [] |> from_list result |> is_eq expected # difference of a non-empty set and an empty set is the non-empty set expect - set1 = from_list [1, 2, 3, 4] - set2 = from_list [] - result = set1 |> difference set2 + set1 = from_list([1, 2, 3, 4]) + set2 = from_list([]) + result = set1 |> difference(set2) expected = [1, 2, 3, 4] |> from_list result |> is_eq expected # difference of two non-empty sets is a set of elements that are only in the first set expect - set1 = from_list [3, 2, 1] - set2 = from_list [2, 4] - result = set1 |> difference set2 + set1 = from_list([3, 2, 1]) + set2 = from_list([2, 4]) + result = set1 |> difference(set2) expected = [1, 3] |> from_list result |> is_eq expected # difference removes all duplicates in the first set expect - set1 = from_list [1, 1] - set2 = from_list [1] - result = set1 |> difference set2 + set1 = from_list([1, 1]) + set2 = from_list([1]) + result = set1 |> difference(set2) expected = [] |> from_list result |> is_eq expected @@ -379,36 +379,36 @@ expect # union of empty sets is an empty set expect - set1 = from_list [] - set2 = from_list [] - result = set1 |> union set2 + set1 = from_list([]) + set2 = from_list([]) + result = set1 |> union(set2) expected = [] |> from_list result |> is_eq expected # union of an empty set and non-empty set is the non-empty set expect - set1 = from_list [] - set2 = from_list [2] - result = set1 |> union set2 + set1 = from_list([]) + set2 = from_list([2]) + result = set1 |> union(set2) expected = [2] |> from_list result |> is_eq expected # union of a non-empty set and empty set is the non-empty set expect - set1 = from_list [1, 3] - set2 = from_list [] - result = set1 |> union set2 + set1 = from_list([1, 3]) + set2 = from_list([]) + result = set1 |> union(set2) expected = [1, 3] |> from_list result |> is_eq expected # union of non-empty sets contains all unique elements expect - set1 = from_list [1, 3] - set2 = from_list [2, 3] - result = set1 |> union set2 + set1 = from_list([1, 3]) + set2 = from_list([2, 3]) + result = set1 |> union(set2) expected = [3, 2, 1] |> from_list result |> is_eq expected @@ -418,21 +418,21 @@ expect # an empty set has an empty list of items expect - set = from_list [] + set = from_list([]) result = set |> to_list |> List.sort_asc expected = [] result == expected # a set can provide the list of its items expect - set = from_list [1, 2, 3, 4] + set = from_list([1, 2, 3, 4]) result = set |> to_list |> List.sort_asc expected = [1, 2, 3, 4] result == expected # duplicate items must be removed expect - set = from_list [1, 2, 2, 3, 3, 3, 4, 4, 4, 4] + set = from_list([1, 2, 2, 3, 3, 3, 4, 4, 4, 4]) result = set |> to_list |> List.sort_asc expected = [1, 2, 3, 4] result == expected diff --git a/exercises/practice/dominoes/.meta/template.j2 b/exercises/practice/dominoes/.meta/template.j2 index 404a592f..036913ee 100644 --- a/exercises/practice/dominoes/.meta/template.j2 +++ b/exercises/practice/dominoes/.meta/template.j2 @@ -18,8 +18,9 @@ Domino : (U8, U8) canonicalize : List Domino -> List Domino canonicalize = |dominoes| dominoes - |> List.map |domino| + |> List.map(|domino| if domino.0 > domino.1 then (domino.1, domino.0) else domino + ) ## Ensure that the given result is Ok and is a valid chain for the ## given list of dominoes diff --git a/exercises/practice/dominoes/dominoes-test.roc b/exercises/practice/dominoes/dominoes-test.roc index 29045d22..049d7ae9 100644 --- a/exercises/practice/dominoes/dominoes-test.roc +++ b/exercises/practice/dominoes/dominoes-test.roc @@ -18,8 +18,10 @@ Domino : (U8, U8) canonicalize : List Domino -> List Domino canonicalize = |dominoes| dominoes - |> List.map |domino| - if domino.0 > domino.1 then (domino.1, domino.0) else domino + |> List.map( + |domino| + if domino.0 > domino.1 then (domino.1, domino.0) else domino, + ) ## Ensure that the given result is Ok and is a valid chain for the ## given list of dominoes diff --git a/exercises/practice/etl/.meta/template.j2 b/exercises/practice/etl/.meta/template.j2 index 0b2244d9..5058d36f 100644 --- a/exercises/practice/etl/.meta/template.j2 +++ b/exercises/practice/etl/.meta/template.j2 @@ -8,17 +8,17 @@ import {{ exercise | to_pascal }} exposing [transform] # {{ case["description"] }} expect legacy = - Dict.from_list [ + Dict.from_list([ {%- for score, letters in case["input"]["legacy"].items() %} ({{score}}, {{ letters | to_roc | replace("\"", "'") }}), {%- endfor %} - ] + ]) expected = - Dict.from_list [ + Dict.from_list([ {%- for letter, score in case["expected"].items() %} ('{{letter}}', {{ score }}), {%- endfor %} - ] + ]) transform legacy == expected {% endfor %} diff --git a/exercises/practice/etl/etl-test.roc b/exercises/practice/etl/etl-test.roc index 7ea1bfbd..99490d46 100644 --- a/exercises/practice/etl/etl-test.roc +++ b/exercises/practice/etl/etl-test.roc @@ -15,87 +15,103 @@ import Etl exposing [transform] # single letter expect legacy = - Dict.from_list [ - (1, ['A']), - ] + Dict.from_list( + [ + (1, ['A']), + ], + ) expected = - Dict.from_list [ - ('a', 1), - ] + Dict.from_list( + [ + ('a', 1), + ], + ) transform legacy == expected # single score with multiple letters expect legacy = - Dict.from_list [ - (1, ['A', 'E', 'I', 'O', 'U']), - ] + Dict.from_list( + [ + (1, ['A', 'E', 'I', 'O', 'U']), + ], + ) expected = - Dict.from_list [ - ('a', 1), - ('e', 1), - ('i', 1), - ('o', 1), - ('u', 1), - ] + Dict.from_list( + [ + ('a', 1), + ('e', 1), + ('i', 1), + ('o', 1), + ('u', 1), + ], + ) transform legacy == expected # multiple scores with multiple letters expect legacy = - Dict.from_list [ - (1, ['A', 'E']), - (2, ['D', 'G']), - ] + Dict.from_list( + [ + (1, ['A', 'E']), + (2, ['D', 'G']), + ], + ) expected = - Dict.from_list [ - ('a', 1), - ('d', 2), - ('e', 1), - ('g', 2), - ] + Dict.from_list( + [ + ('a', 1), + ('d', 2), + ('e', 1), + ('g', 2), + ], + ) transform legacy == expected # multiple scores with differing numbers of letters expect legacy = - Dict.from_list [ - (1, ['A', 'E', 'I', 'O', 'U', 'L', 'N', 'R', 'S', 'T']), - (2, ['D', 'G']), - (3, ['B', 'C', 'M', 'P']), - (4, ['F', 'H', 'V', 'W', 'Y']), - (5, ['K']), - (8, ['J', 'X']), - (10, ['Q', 'Z']), - ] + Dict.from_list( + [ + (1, ['A', 'E', 'I', 'O', 'U', 'L', 'N', 'R', 'S', 'T']), + (2, ['D', 'G']), + (3, ['B', 'C', 'M', 'P']), + (4, ['F', 'H', 'V', 'W', 'Y']), + (5, ['K']), + (8, ['J', 'X']), + (10, ['Q', 'Z']), + ], + ) expected = - Dict.from_list [ - ('a', 1), - ('b', 3), - ('c', 3), - ('d', 2), - ('e', 1), - ('f', 4), - ('g', 2), - ('h', 4), - ('i', 1), - ('j', 8), - ('k', 5), - ('l', 1), - ('m', 3), - ('n', 1), - ('o', 1), - ('p', 3), - ('q', 10), - ('r', 1), - ('s', 1), - ('t', 1), - ('u', 1), - ('v', 4), - ('w', 4), - ('x', 8), - ('y', 4), - ('z', 10), - ] + Dict.from_list( + [ + ('a', 1), + ('b', 3), + ('c', 3), + ('d', 2), + ('e', 1), + ('f', 4), + ('g', 2), + ('h', 4), + ('i', 1), + ('j', 8), + ('k', 5), + ('l', 1), + ('m', 3), + ('n', 1), + ('o', 1), + ('p', 3), + ('q', 10), + ('r', 1), + ('s', 1), + ('t', 1), + ('u', 1), + ('v', 4), + ('w', 4), + ('x', 8), + ('y', 4), + ('z', 10), + ], + ) transform legacy == expected diff --git a/exercises/practice/forth/.meta/template.j2 b/exercises/practice/forth/.meta/template.j2 index 15bb2df2..e964f09a 100644 --- a/exercises/practice/forth/.meta/template.j2 +++ b/exercises/practice/forth/.meta/template.j2 @@ -10,7 +10,7 @@ import Forth exposing [evaluate] expect result = evaluate {{ innerCase["input"]["instructions"] | join('\n') | to_roc_multiline_string | indent(8) }} {%- if innerCase["expected"]["error"] %} - Result.is_err result + Result.is_err(result) {%- else %} result == Ok({{ innerCase["expected"] }}) {%- endif %} diff --git a/exercises/practice/forth/forth-test.roc b/exercises/practice/forth/forth-test.roc index 7052a04e..be1a4084 100644 --- a/exercises/practice/forth/forth-test.roc +++ b/exercises/practice/forth/forth-test.roc @@ -30,12 +30,12 @@ expect # addition: errors if there is nothing on the stack expect result = evaluate "+" - Result.is_err result + Result.is_err(result) # addition: errors if there is only one value on the stack expect result = evaluate "1 +" - Result.is_err result + Result.is_err(result) # addition: more than two values on the stack expect @@ -50,12 +50,12 @@ expect # subtraction: errors if there is nothing on the stack expect result = evaluate "-" - Result.is_err result + Result.is_err(result) # subtraction: errors if there is only one value on the stack expect result = evaluate "1 -" - Result.is_err result + Result.is_err(result) # subtraction: more than two values on the stack expect @@ -70,12 +70,12 @@ expect # multiplication: errors if there is nothing on the stack expect result = evaluate "*" - Result.is_err result + Result.is_err(result) # multiplication: errors if there is only one value on the stack expect result = evaluate "1 *" - Result.is_err result + Result.is_err(result) # multiplication: more than two values on the stack expect @@ -95,17 +95,17 @@ expect # division: errors if dividing by zero expect result = evaluate "4 0 /" - Result.is_err result + Result.is_err(result) # division: errors if there is nothing on the stack expect result = evaluate "/" - Result.is_err result + Result.is_err(result) # division: errors if there is only one value on the stack expect result = evaluate "1 /" - Result.is_err result + Result.is_err(result) # division: more than two values on the stack expect @@ -145,7 +145,7 @@ expect # dup: errors if there is nothing on the stack expect result = evaluate "dup" - Result.is_err result + Result.is_err(result) # drop: removes the top value on the stack if it is the only one expect @@ -160,7 +160,7 @@ expect # drop: errors if there is nothing on the stack expect result = evaluate "drop" - Result.is_err result + Result.is_err(result) # swap: swaps the top two values on the stack if they are the only ones expect @@ -175,12 +175,12 @@ expect # swap: errors if there is nothing on the stack expect result = evaluate "swap" - Result.is_err result + Result.is_err(result) # swap: errors if there is only one value on the stack expect result = evaluate "1 swap" - Result.is_err result + Result.is_err(result) # over: copies the second element if there are only two expect @@ -195,12 +195,12 @@ expect # over: errors if there is nothing on the stack expect result = evaluate "over" - Result.is_err result + Result.is_err(result) # over: errors if there is only one value on the stack expect result = evaluate "1 over" - Result.is_err result + Result.is_err(result) # user-defined words: can consist of built-in words expect @@ -272,7 +272,7 @@ expect # user-defined words: errors if executing a non-existent word expect result = evaluate "foo" - Result.is_err result + Result.is_err(result) # case-insensitivity: DUP is case-insensitive expect diff --git a/exercises/practice/go-counting/.meta/template.j2 b/exercises/practice/go-counting/.meta/template.j2 index 98d62b02..44f896cd 100644 --- a/exercises/practice/go-counting/.meta/template.j2 +++ b/exercises/practice/go-counting/.meta/template.j2 @@ -6,11 +6,11 @@ {%- if territory == [] %} Set.empty {} {%- else %} -Set.from_list [ +Set.from_list([ {%- for intersection in territory %} { x : {{ intersection[0] }}, y : {{ intersection[1] }} }, {%- endfor %} -] +]) {%- endif %} {% endmacro %} diff --git a/exercises/practice/go-counting/go-counting-test.roc b/exercises/practice/go-counting/go-counting-test.roc index e067f116..2fc2b28b 100644 --- a/exercises/practice/go-counting/go-counting-test.roc +++ b/exercises/practice/go-counting/go-counting-test.roc @@ -41,11 +41,13 @@ expect expected = Ok( { owner: Black, - territory: Set.from_list [ - { x: 0, y: 0 }, - { x: 0, y: 1 }, - { x: 1, y: 0 }, - ], + territory: Set.from_list( + [ + { x: 0, y: 0 }, + { x: 0, y: 1 }, + { x: 1, y: 0 }, + ], + ), }, ) result |> compareTerritory expected @@ -65,9 +67,11 @@ expect expected = Ok( { owner: White, - territory: Set.from_list [ - { x: 2, y: 3 }, - ], + territory: Set.from_list( + [ + { x: 2, y: 3 }, + ], + ), }, ) result |> compareTerritory expected @@ -87,11 +91,13 @@ expect expected = Ok( { owner: None, - territory: Set.from_list [ - { x: 0, y: 3 }, - { x: 0, y: 4 }, - { x: 1, y: 4 }, - ], + territory: Set.from_list( + [ + { x: 0, y: 3 }, + { x: 0, y: 4 }, + { x: 1, y: 4 }, + ], + ), }, ) result |> compareTerritory expected @@ -154,9 +160,11 @@ expect white: Set.empty {}, - none: Set.from_list [ - { x: 0, y: 0 }, - ], + none: Set.from_list( + [ + { x: 0, y: 0 }, + ], + ), }, ) result |> compareTerritories expected @@ -172,15 +180,19 @@ expect result = board |> territories expected = Ok( { - black: Set.from_list [ - { x: 0, y: 0 }, - { x: 0, y: 1 }, - ], - - white: Set.from_list [ - { x: 3, y: 0 }, - { x: 3, y: 1 }, - ], + black: Set.from_list( + [ + { x: 0, y: 0 }, + { x: 0, y: 1 }, + ], + ), + + white: Set.from_list( + [ + { x: 3, y: 0 }, + { x: 3, y: 1 }, + ], + ), none: Set.empty {}, }, @@ -193,10 +205,12 @@ expect result = board |> territories expected = Ok( { - black: Set.from_list [ - { x: 0, y: 0 }, - { x: 2, y: 0 }, - ], + black: Set.from_list( + [ + { x: 0, y: 0 }, + { x: 2, y: 0 }, + ], + ), white: Set.empty {}, diff --git a/exercises/practice/grains/.meta/template.j2 b/exercises/practice/grains/.meta/template.j2 index 78e88cc7..1d014c69 100644 --- a/exercises/practice/grains/.meta/template.j2 +++ b/exercises/practice/grains/.meta/template.j2 @@ -18,7 +18,7 @@ expect expect result = grains_on_square {{ subcase["input"]["square"] }} {%- if subcase["expected"]["error"] %} - Result.is_err result + Result.is_err(result) {%- else %} result == Ok({{ subcase["expected"] }}) {%- endif %} diff --git a/exercises/practice/grains/grains-test.roc b/exercises/practice/grains/grains-test.roc index 9f259b38..07b9f5bb 100644 --- a/exercises/practice/grains/grains-test.roc +++ b/exercises/practice/grains/grains-test.roc @@ -54,12 +54,12 @@ expect # square 0 is invalid expect result = grains_on_square 0 - Result.is_err result + Result.is_err(result) # square greater than 64 is invalid expect result = grains_on_square 65 - Result.is_err result + Result.is_err(result) ## ## returns the total number of grains on the board diff --git a/exercises/practice/nucleotide-count/.meta/template.j2 b/exercises/practice/nucleotide-count/.meta/template.j2 index c9e48644..0594f9d9 100644 --- a/exercises/practice/nucleotide-count/.meta/template.j2 +++ b/exercises/practice/nucleotide-count/.meta/template.j2 @@ -9,7 +9,7 @@ import {{ exercise | to_pascal }} exposing [{{ cases[0]["property"] | to_snake } expect result = {{ case["property"] | to_snake }}({{ case["input"]["strand"] | to_roc }}) {%- if case["expected"]["error"] %} - Result.is_err result + Result.is_err(result) {%- else %} result == Ok({{ case["expected"] | to_roc }}) {%- endif %} diff --git a/exercises/practice/nucleotide-count/nucleotide-count-test.roc b/exercises/practice/nucleotide-count/nucleotide-count-test.roc index 742bcdad..d38579c5 100644 --- a/exercises/practice/nucleotide-count/nucleotide-count-test.roc +++ b/exercises/practice/nucleotide-count/nucleotide-count-test.roc @@ -35,5 +35,5 @@ expect # strand with invalid nucleotides expect result = nucleotide_counts("AGXXACT") - Result.is_err result + Result.is_err(result) diff --git a/exercises/practice/palindrome-products/.meta/template.j2 b/exercises/practice/palindrome-products/.meta/template.j2 index c09d6f3d..5cb06a1f 100644 --- a/exercises/practice/palindrome-products/.meta/template.j2 +++ b/exercises/practice/palindrome-products/.meta/template.j2 @@ -19,10 +19,10 @@ expect {%- else %} expected = Ok({ value: {% if case["expected"]["value"] is none %}0{% else %}{{ case["expected"]["value"] }}{% endif %}, - factors: Set.from_list [ + factors: Set.from_list([ {%- for pair in case["expected"]["factors"] %} ({{ pair[0] }}, {{ pair[1] }}),{% endfor %} - ] + ]) }) result |> isEq expected {%- endif %} diff --git a/exercises/practice/palindrome-products/palindrome-products-test.roc b/exercises/practice/palindrome-products/palindrome-products-test.roc index dba7f585..26f14da2 100644 --- a/exercises/practice/palindrome-products/palindrome-products-test.roc +++ b/exercises/practice/palindrome-products/palindrome-products-test.roc @@ -25,9 +25,11 @@ expect expected = Ok( { value: 1, - factors: Set.from_list [ - (1, 1), - ], + factors: Set.from_list( + [ + (1, 1), + ], + ), }, ) result |> isEq expected @@ -38,10 +40,12 @@ expect expected = Ok( { value: 9, - factors: Set.from_list [ - (1, 9), - (3, 3), - ], + factors: Set.from_list( + [ + (1, 9), + (3, 3), + ], + ), }, ) result |> isEq expected @@ -52,9 +56,11 @@ expect expected = Ok( { value: 121, - factors: Set.from_list [ - (11, 11), - ], + factors: Set.from_list( + [ + (11, 11), + ], + ), }, ) result |> isEq expected @@ -65,9 +71,11 @@ expect expected = Ok( { value: 9009, - factors: Set.from_list [ - (91, 99), - ], + factors: Set.from_list( + [ + (91, 99), + ], + ), }, ) result |> isEq expected @@ -78,9 +86,11 @@ expect expected = Ok( { value: 10201, - factors: Set.from_list [ - (101, 101), - ], + factors: Set.from_list( + [ + (101, 101), + ], + ), }, ) result |> isEq expected @@ -91,9 +101,11 @@ expect expected = Ok( { value: 906609, - factors: Set.from_list [ - (913, 993), - ], + factors: Set.from_list( + [ + (913, 993), + ], + ), }, ) result |> isEq expected @@ -104,9 +116,11 @@ expect expected = Ok( { value: 1002001, - factors: Set.from_list [ - (1001, 1001), - ], + factors: Set.from_list( + [ + (1001, 1001), + ], + ), }, ) result |> isEq expected @@ -117,9 +131,11 @@ expect expected = Ok( { value: 99000099, - factors: Set.from_list [ - (9901, 9999), - ], + factors: Set.from_list( + [ + (9901, 9999), + ], + ), }, ) result |> isEq expected @@ -130,8 +146,10 @@ expect expected = Ok( { value: 0, - factors: Set.from_list [ - ], + factors: Set.from_list( + [ + ], + ), }, ) result |> isEq expected @@ -142,8 +160,10 @@ expect expected = Ok( { value: 0, - factors: Set.from_list [ - ], + factors: Set.from_list( + [ + ], + ), }, ) result |> isEq expected @@ -164,9 +184,11 @@ expect expected = Ok( { value: 10988901, - factors: Set.from_list [ - (3297, 3333), - ], + factors: Set.from_list( + [ + (3297, 3333), + ], + ), }, ) result |> isEq expected diff --git a/exercises/practice/perfect-numbers/.meta/template.j2 b/exercises/practice/perfect-numbers/.meta/template.j2 index 4e655f9b..ec51e9f2 100644 --- a/exercises/practice/perfect-numbers/.meta/template.j2 +++ b/exercises/practice/perfect-numbers/.meta/template.j2 @@ -14,7 +14,7 @@ import {{ exercise | to_pascal }} exposing [classify] expect result = {{ case["property"] | to_snake }}({{ case["input"]["number"] }}) {%- if case["expected"]["error"] %} - Result.is_err result + Result.is_err(result) {%- else %} result == Ok({{ case["expected"] | to_pascal }}) {%- endif %} diff --git a/exercises/practice/perfect-numbers/perfect-numbers-test.roc b/exercises/practice/perfect-numbers/perfect-numbers-test.roc index a66851a9..2d183d1c 100644 --- a/exercises/practice/perfect-numbers/perfect-numbers-test.roc +++ b/exercises/practice/perfect-numbers/perfect-numbers-test.roc @@ -86,5 +86,5 @@ expect # Zero is rejected (as it is not a positive integer) expect result = classify(0) - Result.is_err result + Result.is_err(result) diff --git a/exercises/practice/pythagorean-triplet/.meta/template.j2 b/exercises/practice/pythagorean-triplet/.meta/template.j2 index 8f4bf448..e7b51fc9 100644 --- a/exercises/practice/pythagorean-triplet/.meta/template.j2 +++ b/exercises/practice/pythagorean-triplet/.meta/template.j2 @@ -8,9 +8,9 @@ import {{ exercise | to_pascal }} exposing [{{ cases[0]["property"] | to_snake } # {{ case["description"] }} expect result = {{ case["property"] | to_snake }}({{ case["input"]["n"] }}) - expected = Set.from_list [{%- for triplet in case["expected"] %} + expected = Set.from_list([{%- for triplet in case["expected"] %} ({{ triplet[0] }}, {{ triplet[1] }}, {{ triplet[2] }}), - {%- endfor %}] + {%- endfor %}]) result == expected {% endfor %} diff --git a/exercises/practice/pythagorean-triplet/pythagorean-triplet-test.roc b/exercises/practice/pythagorean-triplet/pythagorean-triplet-test.roc index c730453f..80db9e6d 100644 --- a/exercises/practice/pythagorean-triplet/pythagorean-triplet-test.roc +++ b/exercises/practice/pythagorean-triplet/pythagorean-triplet-test.roc @@ -15,66 +15,78 @@ import PythagoreanTriplet exposing [triplets_with_sum] # triplets whose sum is 12 expect result = triplets_with_sum(12) - expected = Set.from_list [ - (3, 4, 5), - ] + expected = Set.from_list( + [ + (3, 4, 5), + ], + ) result == expected # triplets whose sum is 108 expect result = triplets_with_sum(108) - expected = Set.from_list [ - (27, 36, 45), - ] + expected = Set.from_list( + [ + (27, 36, 45), + ], + ) result == expected # triplets whose sum is 1000 expect result = triplets_with_sum(1000) - expected = Set.from_list [ - (200, 375, 425), - ] + expected = Set.from_list( + [ + (200, 375, 425), + ], + ) result == expected # no matching triplets for 1001 expect result = triplets_with_sum(1001) - expected = Set.from_list [] + expected = Set.from_list([]) result == expected # returns all matching triplets expect result = triplets_with_sum(90) - expected = Set.from_list [ - (9, 40, 41), - (15, 36, 39), - ] + expected = Set.from_list( + [ + (9, 40, 41), + (15, 36, 39), + ], + ) result == expected # several matching triplets expect result = triplets_with_sum(840) - expected = Set.from_list [ - (40, 399, 401), - (56, 390, 394), - (105, 360, 375), - (120, 350, 370), - (140, 336, 364), - (168, 315, 357), - (210, 280, 350), - (240, 252, 348), - ] + expected = Set.from_list( + [ + (40, 399, 401), + (56, 390, 394), + (105, 360, 375), + (120, 350, 370), + (140, 336, 364), + (168, 315, 357), + (210, 280, 350), + (240, 252, 348), + ], + ) result == expected # triplets for large number expect result = triplets_with_sum(30000) - expected = Set.from_list [ - (1200, 14375, 14425), - (1875, 14000, 14125), - (5000, 12000, 13000), - (6000, 11250, 12750), - (7500, 10000, 12500), - ] + expected = Set.from_list( + [ + (1200, 14375, 14425), + (1875, 14000, 14125), + (5000, 12000, 13000), + (6000, 11250, 12750), + (7500, 10000, 12500), + ], + ) result == expected diff --git a/exercises/practice/rest-api/.meta/template.j2 b/exercises/practice/rest-api/.meta/template.j2 index 6bc17fc3..0c5bc9ea 100644 --- a/exercises/practice/rest-api/.meta/template.j2 +++ b/exercises/practice/rest-api/.meta/template.j2 @@ -26,16 +26,16 @@ expect {%- for user in case["input"]["database"]["users"] %} { name: {{ user["name"] | to_roc }}, - owes: Dict.from_list [ + owes: Dict.from_list([ {%- for (name, amount) in user["owes"].items() %} ({{ name | to_roc }}, {{ amount }}), {%- endfor -%} - ], - owed_by: Dict.from_list [ + ]), + owed_by: Dict.from_list([ {%- for (name, amount) in user["owed_by"].items() %} ({{ name | to_roc }}, {{ amount }}), {%- endfor -%} - ], + ]), balance: {{ user["balance"] }}, }, {%- endfor %} diff --git a/exercises/practice/rest-api/rest-api-test.roc b/exercises/practice/rest-api/rest-api-test.roc index ac38a88d..359b80c2 100644 --- a/exercises/practice/rest-api/rest-api-test.roc +++ b/exercises/practice/rest-api/rest-api-test.roc @@ -68,14 +68,14 @@ expect users: [ { name: "Adam", - owes: Dict.from_list [], - owed_by: Dict.from_list [], + owes: Dict.from_list([]), + owed_by: Dict.from_list([]), balance: 0.0, }, { name: "Bob", - owes: Dict.from_list [], - owed_by: Dict.from_list [], + owes: Dict.from_list([]), + owed_by: Dict.from_list([]), balance: 0.0, }, ], @@ -102,14 +102,14 @@ expect users: [ { name: "Adam", - owes: Dict.from_list [], - owed_by: Dict.from_list [], + owes: Dict.from_list([]), + owed_by: Dict.from_list([]), balance: 0.0, }, { name: "Bob", - owes: Dict.from_list [], - owed_by: Dict.from_list [], + owes: Dict.from_list([]), + owed_by: Dict.from_list([]), balance: 0.0, }, ], @@ -132,24 +132,28 @@ expect users: [ { name: "Adam", - owes: Dict.from_list [], - owed_by: Dict.from_list [], + owes: Dict.from_list([]), + owed_by: Dict.from_list([]), balance: 0.0, }, { name: "Bob", - owes: Dict.from_list [ - ("Chuck", 3.0), - ], - owed_by: Dict.from_list [], + owes: Dict.from_list( + [ + ("Chuck", 3.0), + ], + ), + owed_by: Dict.from_list([]), balance: -3.0, }, { name: "Chuck", - owes: Dict.from_list [], - owed_by: Dict.from_list [ - ("Bob", 3.0), - ], + owes: Dict.from_list([]), + owed_by: Dict.from_list( + [ + ("Bob", 3.0), + ], + ), balance: 3.0, }, ], @@ -172,24 +176,28 @@ expect users: [ { name: "Adam", - owes: Dict.from_list [], - owed_by: Dict.from_list [], + owes: Dict.from_list([]), + owed_by: Dict.from_list([]), balance: 0.0, }, { name: "Bob", - owes: Dict.from_list [ - ("Chuck", 3.0), - ], - owed_by: Dict.from_list [], + owes: Dict.from_list( + [ + ("Chuck", 3.0), + ], + ), + owed_by: Dict.from_list([]), balance: -3.0, }, { name: "Chuck", - owes: Dict.from_list [], - owed_by: Dict.from_list [ - ("Bob", 3.0), - ], + owes: Dict.from_list([]), + owed_by: Dict.from_list( + [ + ("Bob", 3.0), + ], + ), balance: 3.0, }, ], @@ -212,18 +220,22 @@ expect users: [ { name: "Adam", - owes: Dict.from_list [ - ("Bob", 3.0), - ], - owed_by: Dict.from_list [], + owes: Dict.from_list( + [ + ("Bob", 3.0), + ], + ), + owed_by: Dict.from_list([]), balance: -3.0, }, { name: "Bob", - owes: Dict.from_list [], - owed_by: Dict.from_list [ - ("Adam", 3.0), - ], + owes: Dict.from_list([]), + owed_by: Dict.from_list( + [ + ("Adam", 3.0), + ], + ), balance: 3.0, }, ], @@ -246,18 +258,22 @@ expect users: [ { name: "Adam", - owes: Dict.from_list [ - ("Bob", 3.0), - ], - owed_by: Dict.from_list [], + owes: Dict.from_list( + [ + ("Bob", 3.0), + ], + ), + owed_by: Dict.from_list([]), balance: -3.0, }, { name: "Bob", - owes: Dict.from_list [], - owed_by: Dict.from_list [ - ("Adam", 3.0), - ], + owes: Dict.from_list([]), + owed_by: Dict.from_list( + [ + ("Adam", 3.0), + ], + ), balance: 3.0, }, ], @@ -280,18 +296,22 @@ expect users: [ { name: "Adam", - owes: Dict.from_list [ - ("Bob", 3.0), - ], - owed_by: Dict.from_list [], + owes: Dict.from_list( + [ + ("Bob", 3.0), + ], + ), + owed_by: Dict.from_list([]), balance: -3.0, }, { name: "Bob", - owes: Dict.from_list [], - owed_by: Dict.from_list [ - ("Adam", 3.0), - ], + owes: Dict.from_list([]), + owed_by: Dict.from_list( + [ + ("Adam", 3.0), + ], + ), balance: 3.0, }, ], diff --git a/exercises/practice/saddle-points/.meta/template.j2 b/exercises/practice/saddle-points/.meta/template.j2 index 4d0d3995..05478de4 100644 --- a/exercises/practice/saddle-points/.meta/template.j2 +++ b/exercises/practice/saddle-points/.meta/template.j2 @@ -13,11 +13,11 @@ expect {%- endfor %} ] result = treeHeights |> {{ case["property"] | to_snake }} - expected = Set.from_list [ + expected = Set.from_list([ {%- for tree in case["expected"] %} {{ tree | to_roc }}, {%- endfor %} - ] + ]) result == expected {% endfor %} diff --git a/exercises/practice/saddle-points/saddle-points-test.roc b/exercises/practice/saddle-points/saddle-points-test.roc index 20f182e8..488d4cf6 100644 --- a/exercises/practice/saddle-points/saddle-points-test.roc +++ b/exercises/practice/saddle-points/saddle-points-test.roc @@ -20,9 +20,11 @@ expect [6, 6, 7], ] result = treeHeights |> saddle_points - expected = Set.from_list [ - { row: 2, column: 1 }, - ] + expected = Set.from_list( + [ + { row: 2, column: 1 }, + ], + ) result == expected # Can identify that empty matrix has no saddle points @@ -31,8 +33,10 @@ expect [], ] result = treeHeights |> saddle_points - expected = Set.from_list [ - ] + expected = Set.from_list( + [ + ], + ) result == expected # Can identify lack of saddle points when there are none @@ -43,8 +47,10 @@ expect [2, 3, 1], ] result = treeHeights |> saddle_points - expected = Set.from_list [ - ] + expected = Set.from_list( + [ + ], + ) result == expected # Can identify multiple saddle points in a column @@ -55,11 +61,13 @@ expect [1, 5, 4], ] result = treeHeights |> saddle_points - expected = Set.from_list [ - { row: 1, column: 2 }, - { row: 2, column: 2 }, - { row: 3, column: 2 }, - ] + expected = Set.from_list( + [ + { row: 1, column: 2 }, + { row: 2, column: 2 }, + { row: 3, column: 2 }, + ], + ) result == expected # Can identify multiple saddle points in a row @@ -70,11 +78,13 @@ expect [7, 5, 6], ] result = treeHeights |> saddle_points - expected = Set.from_list [ - { row: 2, column: 1 }, - { row: 2, column: 2 }, - { row: 2, column: 3 }, - ] + expected = Set.from_list( + [ + { row: 2, column: 1 }, + { row: 2, column: 2 }, + { row: 2, column: 3 }, + ], + ) result == expected # Can identify saddle point in bottom right corner @@ -85,9 +95,11 @@ expect [3, 2, 5], ] result = treeHeights |> saddle_points - expected = Set.from_list [ - { row: 3, column: 3 }, - ] + expected = Set.from_list( + [ + { row: 3, column: 3 }, + ], + ) result == expected # Can identify saddle points in a non square matrix @@ -97,10 +109,12 @@ expect [3, 2, 4], ] result = treeHeights |> saddle_points - expected = Set.from_list [ - { row: 1, column: 3 }, - { row: 1, column: 1 }, - ] + expected = Set.from_list( + [ + { row: 1, column: 3 }, + { row: 1, column: 1 }, + ], + ) result == expected # Can identify that saddle points in a single column matrix are those with the minimum value @@ -112,10 +126,12 @@ expect [1], ] result = treeHeights |> saddle_points - expected = Set.from_list [ - { row: 2, column: 1 }, - { row: 4, column: 1 }, - ] + expected = Set.from_list( + [ + { row: 2, column: 1 }, + { row: 4, column: 1 }, + ], + ) result == expected # Can identify that saddle points in a single row matrix are those with the maximum value @@ -124,9 +140,11 @@ expect [2, 5, 3, 5], ] result = treeHeights |> saddle_points - expected = Set.from_list [ - { row: 1, column: 2 }, - { row: 1, column: 4 }, - ] + expected = Set.from_list( + [ + { row: 1, column: 2 }, + { row: 1, column: 4 }, + ], + ) result == expected diff --git a/exercises/practice/sgf-parsing/.meta/template.j2 b/exercises/practice/sgf-parsing/.meta/template.j2 index 4b2c088f..ffc16594 100644 --- a/exercises/practice/sgf-parsing/.meta/template.j2 +++ b/exercises/practice/sgf-parsing/.meta/template.j2 @@ -6,10 +6,10 @@ import {{ exercise | to_pascal }} exposing [{{ cases[0]["property"] | to_snake } {%- macro to_node(node) %} GameNode { - properties: Dict.from_list [ + properties: Dict.from_list([ {%- for name, values in node["properties"].items() %} ({{ name | to_roc }}, {{ values | to_roc }}), - {%- endfor %}], + {%- endfor %}]), children: [ {%- for child_node in node["children"] %} {{ to_node(child_node) }}, diff --git a/exercises/practice/sgf-parsing/sgf-parsing-test.roc b/exercises/practice/sgf-parsing/sgf-parsing-test.roc index a1d2de51..d156ca52 100644 --- a/exercises/practice/sgf-parsing/sgf-parsing-test.roc +++ b/exercises/practice/sgf-parsing/sgf-parsing-test.roc @@ -37,7 +37,7 @@ expect result = parse sgf expected = GameNode { - properties: Dict.from_list [], + properties: Dict.from_list([]), children: [], } result == Ok(expected) @@ -48,9 +48,11 @@ expect result = parse sgf expected = GameNode { - properties: Dict.from_list [ - ("A", ["B"]), - ], + properties: Dict.from_list( + [ + ("A", ["B"]), + ], + ), children: [], } result == Ok(expected) @@ -61,10 +63,12 @@ expect result = parse sgf expected = GameNode { - properties: Dict.from_list [ - ("A", ["b"]), - ("C", ["d"]), - ], + properties: Dict.from_list( + [ + ("A", ["b"]), + ("C", ["d"]), + ], + ), children: [], } result == Ok(expected) @@ -93,14 +97,18 @@ expect result = parse sgf expected = GameNode { - properties: Dict.from_list [ - ("A", ["B"]), - ], + properties: Dict.from_list( + [ + ("A", ["B"]), + ], + ), children: [ GameNode { - properties: Dict.from_list [ - ("B", ["C"]), - ], + properties: Dict.from_list( + [ + ("B", ["C"]), + ], + ), children: [], }, ], @@ -113,20 +121,26 @@ expect result = parse sgf expected = GameNode { - properties: Dict.from_list [ - ("A", ["B"]), - ], + properties: Dict.from_list( + [ + ("A", ["B"]), + ], + ), children: [ GameNode { - properties: Dict.from_list [ - ("B", ["C"]), - ], + properties: Dict.from_list( + [ + ("B", ["C"]), + ], + ), children: [], }, GameNode { - properties: Dict.from_list [ - ("C", ["D"]), - ], + properties: Dict.from_list( + [ + ("C", ["D"]), + ], + ), children: [], }, ], @@ -139,9 +153,11 @@ expect result = parse sgf expected = GameNode { - properties: Dict.from_list [ - ("A", ["b", "c", "d"]), - ], + properties: Dict.from_list( + [ + ("A", ["b", "c", "d"]), + ], + ), children: [], } result == Ok(expected) @@ -152,9 +168,11 @@ expect result = parse sgf expected = GameNode { - properties: Dict.from_list [ - ("A", ["hello world"]), - ], + properties: Dict.from_list( + [ + ("A", ["hello world"]), + ], + ), children: [], } result == Ok(expected) @@ -165,9 +183,11 @@ expect result = parse sgf expected = GameNode { - properties: Dict.from_list [ - ("A", ["hello\n\nworld"]), - ], + properties: Dict.from_list( + [ + ("A", ["hello\n\nworld"]), + ], + ), children: [], } result == Ok(expected) @@ -178,9 +198,11 @@ expect result = parse sgf expected = GameNode { - properties: Dict.from_list [ - ("A", ["]"]), - ], + properties: Dict.from_list( + [ + ("A", ["]"]), + ], + ), children: [], } result == Ok(expected) @@ -191,9 +213,11 @@ expect result = parse sgf expected = GameNode { - properties: Dict.from_list [ - ("A", ["\\"]), - ], + properties: Dict.from_list( + [ + ("A", ["\\"]), + ], + ), children: [], } result == Ok(expected) @@ -204,15 +228,19 @@ expect result = parse sgf expected = GameNode { - properties: Dict.from_list [ - ("A", ["x[y]z", "foo"]), - ("B", ["bar"]), - ], + properties: Dict.from_list( + [ + ("A", ["x[y]z", "foo"]), + ("B", ["bar"]), + ], + ), children: [ GameNode { - properties: Dict.from_list [ - ("C", ["baz"]), - ], + properties: Dict.from_list( + [ + ("C", ["baz"]), + ], + ), children: [], }, ], @@ -225,15 +253,19 @@ expect result = parse sgf expected = GameNode { - properties: Dict.from_list [ - ("A", ["a;b", "foo"]), - ("B", ["bar"]), - ], + properties: Dict.from_list( + [ + ("A", ["a;b", "foo"]), + ("B", ["bar"]), + ], + ), children: [ GameNode { - properties: Dict.from_list [ - ("C", ["baz"]), - ], + properties: Dict.from_list( + [ + ("C", ["baz"]), + ], + ), children: [], }, ], @@ -246,15 +278,19 @@ expect result = parse sgf expected = GameNode { - properties: Dict.from_list [ - ("A", ["x(y)z", "foo"]), - ("B", ["bar"]), - ], + properties: Dict.from_list( + [ + ("A", ["x(y)z", "foo"]), + ("B", ["bar"]), + ], + ), children: [ GameNode { - properties: Dict.from_list [ - ("C", ["baz"]), - ], + properties: Dict.from_list( + [ + ("C", ["baz"]), + ], + ), children: [], }, ], @@ -267,9 +303,11 @@ expect result = parse sgf expected = GameNode { - properties: Dict.from_list [ - ("A", ["hello world"]), - ], + properties: Dict.from_list( + [ + ("A", ["hello world"]), + ], + ), children: [], } result == Ok(expected) @@ -280,9 +318,11 @@ expect result = parse sgf expected = GameNode { - properties: Dict.from_list [ - ("A", ["helloworld"]), - ], + properties: Dict.from_list( + [ + ("A", ["helloworld"]), + ], + ), children: [], } result == Ok(expected) @@ -293,9 +333,11 @@ expect result = parse sgf expected = GameNode { - properties: Dict.from_list [ - ("A", ["t = t and n = n"]), - ], + properties: Dict.from_list( + [ + ("A", ["t = t and n = n"]), + ], + ), children: [], } result == Ok(expected) @@ -306,9 +348,11 @@ expect result = parse sgf expected = GameNode { - properties: Dict.from_list [ - ("A", ["]b\ncd e\\ ]"]), - ], + properties: Dict.from_list( + [ + ("A", ["]b\ncd e\\ ]"]), + ], + ), children: [], } result == Ok(expected) diff --git a/exercises/practice/word-count/.meta/template.j2 b/exercises/practice/word-count/.meta/template.j2 index a1812179..1a6dccc4 100644 --- a/exercises/practice/word-count/.meta/template.j2 +++ b/exercises/practice/word-count/.meta/template.j2 @@ -8,11 +8,11 @@ import {{ exercise | to_pascal }} exposing [{{ cases[0]["property"] | to_snake } # {{ case["description"] }} expect result = {{ case["property"] | to_snake }}({{ case["input"]["sentence"] | to_roc }}) - expected = Dict.from_list [ + expected = Dict.from_list([ {%- for word, count in case["expected"].items() %} ({{ word | to_roc }}, {{ count }}), {%- endfor %} - ] + ]) result == expected {% endfor %} diff --git a/exercises/practice/word-count/word-count-test.roc b/exercises/practice/word-count/word-count-test.roc index 092bf181..f516712a 100644 --- a/exercises/practice/word-count/word-count-test.roc +++ b/exercises/practice/word-count/word-count-test.roc @@ -15,152 +15,180 @@ import WordCount exposing [count_words] # count one word expect result = count_words("word") - expected = Dict.from_list [ - ("word", 1), - ] + expected = Dict.from_list( + [ + ("word", 1), + ], + ) result == expected # count one of each word expect result = count_words("one of each") - expected = Dict.from_list [ - ("one", 1), - ("of", 1), - ("each", 1), - ] + expected = Dict.from_list( + [ + ("one", 1), + ("of", 1), + ("each", 1), + ], + ) result == expected # multiple occurrences of a word expect result = count_words("one fish two fish red fish blue fish") - expected = Dict.from_list [ - ("one", 1), - ("fish", 4), - ("two", 1), - ("red", 1), - ("blue", 1), - ] + expected = Dict.from_list( + [ + ("one", 1), + ("fish", 4), + ("two", 1), + ("red", 1), + ("blue", 1), + ], + ) result == expected # handles cramped lists expect result = count_words("one,two,three") - expected = Dict.from_list [ - ("one", 1), - ("two", 1), - ("three", 1), - ] + expected = Dict.from_list( + [ + ("one", 1), + ("two", 1), + ("three", 1), + ], + ) result == expected # handles expanded lists expect result = count_words("one,\ntwo,\nthree") - expected = Dict.from_list [ - ("one", 1), - ("two", 1), - ("three", 1), - ] + expected = Dict.from_list( + [ + ("one", 1), + ("two", 1), + ("three", 1), + ], + ) result == expected # ignore punctuation expect result = count_words("car: carpet as java: javascript!!&@$%^&") - expected = Dict.from_list [ - ("car", 1), - ("carpet", 1), - ("as", 1), - ("java", 1), - ("javascript", 1), - ] + expected = Dict.from_list( + [ + ("car", 1), + ("carpet", 1), + ("as", 1), + ("java", 1), + ("javascript", 1), + ], + ) result == expected # include numbers expect result = count_words("testing, 1, 2 testing") - expected = Dict.from_list [ - ("testing", 2), - ("1", 1), - ("2", 1), - ] + expected = Dict.from_list( + [ + ("testing", 2), + ("1", 1), + ("2", 1), + ], + ) result == expected # normalize case expect result = count_words("go Go GO Stop stop") - expected = Dict.from_list [ - ("go", 3), - ("stop", 2), - ] + expected = Dict.from_list( + [ + ("go", 3), + ("stop", 2), + ], + ) result == expected # with apostrophes expect result = count_words("'First: don't laugh. Then: don't cry. You're getting it.'") - expected = Dict.from_list [ - ("first", 1), - ("don't", 2), - ("laugh", 1), - ("then", 1), - ("cry", 1), - ("you're", 1), - ("getting", 1), - ("it", 1), - ] + expected = Dict.from_list( + [ + ("first", 1), + ("don't", 2), + ("laugh", 1), + ("then", 1), + ("cry", 1), + ("you're", 1), + ("getting", 1), + ("it", 1), + ], + ) result == expected # with quotations expect result = count_words("Joe can't tell between 'large' and large.") - expected = Dict.from_list [ - ("joe", 1), - ("can't", 1), - ("tell", 1), - ("between", 1), - ("large", 2), - ("and", 1), - ] + expected = Dict.from_list( + [ + ("joe", 1), + ("can't", 1), + ("tell", 1), + ("between", 1), + ("large", 2), + ("and", 1), + ], + ) result == expected # substrings from the beginning expect result = count_words("Joe can't tell between app, apple and a.") - expected = Dict.from_list [ - ("joe", 1), - ("can't", 1), - ("tell", 1), - ("between", 1), - ("app", 1), - ("apple", 1), - ("and", 1), - ("a", 1), - ] + expected = Dict.from_list( + [ + ("joe", 1), + ("can't", 1), + ("tell", 1), + ("between", 1), + ("app", 1), + ("apple", 1), + ("and", 1), + ("a", 1), + ], + ) result == expected # multiple spaces not detected as a word expect result = count_words(" multiple whitespaces") - expected = Dict.from_list [ - ("multiple", 1), - ("whitespaces", 1), - ] + expected = Dict.from_list( + [ + ("multiple", 1), + ("whitespaces", 1), + ], + ) result == expected # alternating word separators not detected as a word expect result = count_words(",\n,one,\n ,two \n 'three'") - expected = Dict.from_list [ - ("one", 1), - ("two", 1), - ("three", 1), - ] + expected = Dict.from_list( + [ + ("one", 1), + ("two", 1), + ("three", 1), + ], + ) result == expected # quotation for word with apostrophe expect result = count_words("can, can't, 'can't'") - expected = Dict.from_list [ - ("can", 1), - ("can't", 2), - ] + expected = Dict.from_list( + [ + ("can", 1), + ("can't", 2), + ], + ) result == expected diff --git a/exercises/practice/word-search/.meta/template.j2 b/exercises/practice/word-search/.meta/template.j2 index 946f8a58..7701506c 100644 --- a/exercises/practice/word-search/.meta/template.j2 +++ b/exercises/practice/word-search/.meta/template.j2 @@ -10,7 +10,7 @@ expect grid = {{ case["input"]["grid"] | to_roc_multiline_string | indent(8) }} words_to_search_for = {{ case["input"]["wordsToSearchFor"] | to_roc }} result = grid |> {{ case["property"] | to_snake }} words_to_search_for - expected = Dict.from_list [ + expected = Dict.from_list([ {%- for word, result in case["expected"].items() %} {%- if result is none %} # {{ word | to_roc }} is not in the grid @@ -18,7 +18,7 @@ expect ({{ word | to_roc }}, {{ result | to_roc }}), {%- endif %} {%- endfor %} - ] + ]) result == expected {% endfor %} diff --git a/exercises/practice/word-search/word-search-test.roc b/exercises/practice/word-search/word-search-test.roc index 0b4c44a3..d5790acc 100644 --- a/exercises/practice/word-search/word-search-test.roc +++ b/exercises/practice/word-search/word-search-test.roc @@ -17,9 +17,11 @@ expect grid = "jefblpepre" words_to_search_for = ["clojure"] result = grid |> search words_to_search_for - expected = Dict.from_list [ - # "clojure" is not in the grid - ] + expected = Dict.from_list( + [ + # "clojure" is not in the grid + ], + ) result == expected # Should locate one word written left to right @@ -27,9 +29,11 @@ expect grid = "clojurermt" words_to_search_for = ["clojure"] result = grid |> search words_to_search_for - expected = Dict.from_list [ - ("clojure", { start: { column: 1, row: 1 }, end: { column: 7, row: 1 } }), - ] + expected = Dict.from_list( + [ + ("clojure", { start: { column: 1, row: 1 }, end: { column: 7, row: 1 } }), + ], + ) result == expected # Should locate the same word written left to right in a different position @@ -37,9 +41,11 @@ expect grid = "mtclojurer" words_to_search_for = ["clojure"] result = grid |> search words_to_search_for - expected = Dict.from_list [ - ("clojure", { start: { column: 3, row: 1 }, end: { column: 9, row: 1 } }), - ] + expected = Dict.from_list( + [ + ("clojure", { start: { column: 3, row: 1 }, end: { column: 9, row: 1 } }), + ], + ) result == expected # Should locate a different left to right word @@ -47,9 +53,11 @@ expect grid = "coffeelplx" words_to_search_for = ["coffee"] result = grid |> search words_to_search_for - expected = Dict.from_list [ - ("coffee", { start: { column: 1, row: 1 }, end: { column: 6, row: 1 } }), - ] + expected = Dict.from_list( + [ + ("coffee", { start: { column: 1, row: 1 }, end: { column: 6, row: 1 } }), + ], + ) result == expected # Should locate that different left to right word in a different position @@ -57,9 +65,11 @@ expect grid = "xcoffeezlp" words_to_search_for = ["coffee"] result = grid |> search words_to_search_for - expected = Dict.from_list [ - ("coffee", { start: { column: 2, row: 1 }, end: { column: 7, row: 1 } }), - ] + expected = Dict.from_list( + [ + ("coffee", { start: { column: 2, row: 1 }, end: { column: 7, row: 1 } }), + ], + ) result == expected # Should locate a left to right word in two line grid @@ -71,9 +81,11 @@ expect """ words_to_search_for = ["clojure"] result = grid |> search words_to_search_for - expected = Dict.from_list [ - ("clojure", { start: { column: 2, row: 2 }, end: { column: 8, row: 2 } }), - ] + expected = Dict.from_list( + [ + ("clojure", { start: { column: 2, row: 2 }, end: { column: 8, row: 2 } }), + ], + ) result == expected # Should locate a left to right word in three line grid @@ -86,9 +98,11 @@ expect """ words_to_search_for = ["clojure"] result = grid |> search words_to_search_for - expected = Dict.from_list [ - ("clojure", { start: { column: 1, row: 3 }, end: { column: 7, row: 3 } }), - ] + expected = Dict.from_list( + [ + ("clojure", { start: { column: 1, row: 3 }, end: { column: 7, row: 3 } }), + ], + ) result == expected # Should locate a left to right word in ten line grid @@ -108,9 +122,11 @@ expect """ words_to_search_for = ["clojure"] result = grid |> search words_to_search_for - expected = Dict.from_list [ - ("clojure", { start: { column: 1, row: 10 }, end: { column: 7, row: 10 } }), - ] + expected = Dict.from_list( + [ + ("clojure", { start: { column: 1, row: 10 }, end: { column: 7, row: 10 } }), + ], + ) result == expected # Should locate that left to right word in a different position in a ten line grid @@ -130,9 +146,11 @@ expect """ words_to_search_for = ["clojure"] result = grid |> search words_to_search_for - expected = Dict.from_list [ - ("clojure", { start: { column: 1, row: 9 }, end: { column: 7, row: 9 } }), - ] + expected = Dict.from_list( + [ + ("clojure", { start: { column: 1, row: 9 }, end: { column: 7, row: 9 } }), + ], + ) result == expected # Should locate a different left to right word in a ten line grid @@ -152,9 +170,11 @@ expect """ words_to_search_for = ["fortran"] result = grid |> search words_to_search_for - expected = Dict.from_list [ - ("fortran", { start: { column: 1, row: 7 }, end: { column: 7, row: 7 } }), - ] + expected = Dict.from_list( + [ + ("fortran", { start: { column: 1, row: 7 }, end: { column: 7, row: 7 } }), + ], + ) result == expected # Should locate multiple words @@ -174,10 +194,12 @@ expect """ words_to_search_for = ["fortran", "clojure"] result = grid |> search words_to_search_for - expected = Dict.from_list [ - ("clojure", { start: { column: 1, row: 10 }, end: { column: 7, row: 10 } }), - ("fortran", { start: { column: 1, row: 7 }, end: { column: 7, row: 7 } }), - ] + expected = Dict.from_list( + [ + ("clojure", { start: { column: 1, row: 10 }, end: { column: 7, row: 10 } }), + ("fortran", { start: { column: 1, row: 7 }, end: { column: 7, row: 7 } }), + ], + ) result == expected # Should locate a single word written right to left @@ -185,9 +207,11 @@ expect grid = "rixilelhrs" words_to_search_for = ["elixir"] result = grid |> search words_to_search_for - expected = Dict.from_list [ - ("elixir", { start: { column: 6, row: 1 }, end: { column: 1, row: 1 } }), - ] + expected = Dict.from_list( + [ + ("elixir", { start: { column: 6, row: 1 }, end: { column: 1, row: 1 } }), + ], + ) result == expected # Should locate multiple words written in different horizontal directions @@ -207,10 +231,12 @@ expect """ words_to_search_for = ["elixir", "clojure"] result = grid |> search words_to_search_for - expected = Dict.from_list [ - ("clojure", { start: { column: 1, row: 10 }, end: { column: 7, row: 10 } }), - ("elixir", { start: { column: 6, row: 5 }, end: { column: 1, row: 5 } }), - ] + expected = Dict.from_list( + [ + ("clojure", { start: { column: 1, row: 10 }, end: { column: 7, row: 10 } }), + ("elixir", { start: { column: 6, row: 5 }, end: { column: 1, row: 5 } }), + ], + ) result == expected # Should locate words written top to bottom @@ -230,11 +256,13 @@ expect """ words_to_search_for = ["clojure", "elixir", "ecmascript"] result = grid |> search words_to_search_for - expected = Dict.from_list [ - ("clojure", { start: { column: 1, row: 10 }, end: { column: 7, row: 10 } }), - ("elixir", { start: { column: 6, row: 5 }, end: { column: 1, row: 5 } }), - ("ecmascript", { start: { column: 10, row: 1 }, end: { column: 10, row: 10 } }), - ] + expected = Dict.from_list( + [ + ("clojure", { start: { column: 1, row: 10 }, end: { column: 7, row: 10 } }), + ("elixir", { start: { column: 6, row: 5 }, end: { column: 1, row: 5 } }), + ("ecmascript", { start: { column: 10, row: 1 }, end: { column: 10, row: 10 } }), + ], + ) result == expected # Should locate words written bottom to top @@ -254,12 +282,14 @@ expect """ words_to_search_for = ["clojure", "elixir", "ecmascript", "rust"] result = grid |> search words_to_search_for - expected = Dict.from_list [ - ("clojure", { start: { column: 1, row: 10 }, end: { column: 7, row: 10 } }), - ("elixir", { start: { column: 6, row: 5 }, end: { column: 1, row: 5 } }), - ("ecmascript", { start: { column: 10, row: 1 }, end: { column: 10, row: 10 } }), - ("rust", { start: { column: 9, row: 5 }, end: { column: 9, row: 2 } }), - ] + expected = Dict.from_list( + [ + ("clojure", { start: { column: 1, row: 10 }, end: { column: 7, row: 10 } }), + ("elixir", { start: { column: 6, row: 5 }, end: { column: 1, row: 5 } }), + ("ecmascript", { start: { column: 10, row: 1 }, end: { column: 10, row: 10 } }), + ("rust", { start: { column: 9, row: 5 }, end: { column: 9, row: 2 } }), + ], + ) result == expected # Should locate words written top left to bottom right @@ -279,13 +309,15 @@ expect """ words_to_search_for = ["clojure", "elixir", "ecmascript", "rust", "java"] result = grid |> search words_to_search_for - expected = Dict.from_list [ - ("clojure", { start: { column: 1, row: 10 }, end: { column: 7, row: 10 } }), - ("elixir", { start: { column: 6, row: 5 }, end: { column: 1, row: 5 } }), - ("ecmascript", { start: { column: 10, row: 1 }, end: { column: 10, row: 10 } }), - ("rust", { start: { column: 9, row: 5 }, end: { column: 9, row: 2 } }), - ("java", { start: { column: 1, row: 1 }, end: { column: 4, row: 4 } }), - ] + expected = Dict.from_list( + [ + ("clojure", { start: { column: 1, row: 10 }, end: { column: 7, row: 10 } }), + ("elixir", { start: { column: 6, row: 5 }, end: { column: 1, row: 5 } }), + ("ecmascript", { start: { column: 10, row: 1 }, end: { column: 10, row: 10 } }), + ("rust", { start: { column: 9, row: 5 }, end: { column: 9, row: 2 } }), + ("java", { start: { column: 1, row: 1 }, end: { column: 4, row: 4 } }), + ], + ) result == expected # Should locate words written bottom right to top left @@ -305,14 +337,16 @@ expect """ words_to_search_for = ["clojure", "elixir", "ecmascript", "rust", "java", "lua"] result = grid |> search words_to_search_for - expected = Dict.from_list [ - ("clojure", { start: { column: 1, row: 10 }, end: { column: 7, row: 10 } }), - ("elixir", { start: { column: 6, row: 5 }, end: { column: 1, row: 5 } }), - ("ecmascript", { start: { column: 10, row: 1 }, end: { column: 10, row: 10 } }), - ("rust", { start: { column: 9, row: 5 }, end: { column: 9, row: 2 } }), - ("java", { start: { column: 1, row: 1 }, end: { column: 4, row: 4 } }), - ("lua", { start: { column: 8, row: 9 }, end: { column: 6, row: 7 } }), - ] + expected = Dict.from_list( + [ + ("clojure", { start: { column: 1, row: 10 }, end: { column: 7, row: 10 } }), + ("elixir", { start: { column: 6, row: 5 }, end: { column: 1, row: 5 } }), + ("ecmascript", { start: { column: 10, row: 1 }, end: { column: 10, row: 10 } }), + ("rust", { start: { column: 9, row: 5 }, end: { column: 9, row: 2 } }), + ("java", { start: { column: 1, row: 1 }, end: { column: 4, row: 4 } }), + ("lua", { start: { column: 8, row: 9 }, end: { column: 6, row: 7 } }), + ], + ) result == expected # Should locate words written bottom left to top right @@ -332,15 +366,17 @@ expect """ words_to_search_for = ["clojure", "elixir", "ecmascript", "rust", "java", "lua", "lisp"] result = grid |> search words_to_search_for - expected = Dict.from_list [ - ("clojure", { start: { column: 1, row: 10 }, end: { column: 7, row: 10 } }), - ("elixir", { start: { column: 6, row: 5 }, end: { column: 1, row: 5 } }), - ("ecmascript", { start: { column: 10, row: 1 }, end: { column: 10, row: 10 } }), - ("rust", { start: { column: 9, row: 5 }, end: { column: 9, row: 2 } }), - ("java", { start: { column: 1, row: 1 }, end: { column: 4, row: 4 } }), - ("lua", { start: { column: 8, row: 9 }, end: { column: 6, row: 7 } }), - ("lisp", { start: { column: 3, row: 6 }, end: { column: 6, row: 3 } }), - ] + expected = Dict.from_list( + [ + ("clojure", { start: { column: 1, row: 10 }, end: { column: 7, row: 10 } }), + ("elixir", { start: { column: 6, row: 5 }, end: { column: 1, row: 5 } }), + ("ecmascript", { start: { column: 10, row: 1 }, end: { column: 10, row: 10 } }), + ("rust", { start: { column: 9, row: 5 }, end: { column: 9, row: 2 } }), + ("java", { start: { column: 1, row: 1 }, end: { column: 4, row: 4 } }), + ("lua", { start: { column: 8, row: 9 }, end: { column: 6, row: 7 } }), + ("lisp", { start: { column: 3, row: 6 }, end: { column: 6, row: 3 } }), + ], + ) result == expected # Should locate words written top right to bottom left @@ -360,16 +396,18 @@ expect """ words_to_search_for = ["clojure", "elixir", "ecmascript", "rust", "java", "lua", "lisp", "ruby"] result = grid |> search words_to_search_for - expected = Dict.from_list [ - ("clojure", { start: { column: 1, row: 10 }, end: { column: 7, row: 10 } }), - ("elixir", { start: { column: 6, row: 5 }, end: { column: 1, row: 5 } }), - ("ecmascript", { start: { column: 10, row: 1 }, end: { column: 10, row: 10 } }), - ("rust", { start: { column: 9, row: 5 }, end: { column: 9, row: 2 } }), - ("java", { start: { column: 1, row: 1 }, end: { column: 4, row: 4 } }), - ("lua", { start: { column: 8, row: 9 }, end: { column: 6, row: 7 } }), - ("lisp", { start: { column: 3, row: 6 }, end: { column: 6, row: 3 } }), - ("ruby", { start: { column: 8, row: 6 }, end: { column: 5, row: 9 } }), - ] + expected = Dict.from_list( + [ + ("clojure", { start: { column: 1, row: 10 }, end: { column: 7, row: 10 } }), + ("elixir", { start: { column: 6, row: 5 }, end: { column: 1, row: 5 } }), + ("ecmascript", { start: { column: 10, row: 1 }, end: { column: 10, row: 10 } }), + ("rust", { start: { column: 9, row: 5 }, end: { column: 9, row: 2 } }), + ("java", { start: { column: 1, row: 1 }, end: { column: 4, row: 4 } }), + ("lua", { start: { column: 8, row: 9 }, end: { column: 6, row: 7 } }), + ("lisp", { start: { column: 3, row: 6 }, end: { column: 6, row: 3 } }), + ("ruby", { start: { column: 8, row: 6 }, end: { column: 5, row: 9 } }), + ], + ) result == expected # Should fail to locate a word that is not in the puzzle @@ -389,17 +427,19 @@ expect """ words_to_search_for = ["clojure", "elixir", "ecmascript", "rust", "java", "lua", "lisp", "ruby", "haskell"] result = grid |> search words_to_search_for - expected = Dict.from_list [ - ("clojure", { start: { column: 1, row: 10 }, end: { column: 7, row: 10 } }), - ("elixir", { start: { column: 6, row: 5 }, end: { column: 1, row: 5 } }), - ("ecmascript", { start: { column: 10, row: 1 }, end: { column: 10, row: 10 } }), - ("rust", { start: { column: 9, row: 5 }, end: { column: 9, row: 2 } }), - ("java", { start: { column: 1, row: 1 }, end: { column: 4, row: 4 } }), - ("lua", { start: { column: 8, row: 9 }, end: { column: 6, row: 7 } }), - ("lisp", { start: { column: 3, row: 6 }, end: { column: 6, row: 3 } }), - ("ruby", { start: { column: 8, row: 6 }, end: { column: 5, row: 9 } }), - # "haskell" is not in the grid - ] + expected = Dict.from_list( + [ + ("clojure", { start: { column: 1, row: 10 }, end: { column: 7, row: 10 } }), + ("elixir", { start: { column: 6, row: 5 }, end: { column: 1, row: 5 } }), + ("ecmascript", { start: { column: 10, row: 1 }, end: { column: 10, row: 10 } }), + ("rust", { start: { column: 9, row: 5 }, end: { column: 9, row: 2 } }), + ("java", { start: { column: 1, row: 1 }, end: { column: 4, row: 4 } }), + ("lua", { start: { column: 8, row: 9 }, end: { column: 6, row: 7 } }), + ("lisp", { start: { column: 3, row: 6 }, end: { column: 6, row: 3 } }), + ("ruby", { start: { column: 8, row: 6 }, end: { column: 5, row: 9 } }), + # "haskell" is not in the grid + ], + ) result == expected # Should fail to locate words that are not on horizontal, vertical, or diagonal lines @@ -411,12 +451,14 @@ expect """ words_to_search_for = ["aef", "ced", "abf", "cbd"] result = grid |> search words_to_search_for - expected = Dict.from_list [ - # "aef" is not in the grid - # "ced" is not in the grid - # "abf" is not in the grid - # "cbd" is not in the grid - ] + expected = Dict.from_list( + [ + # "aef" is not in the grid + # "ced" is not in the grid + # "abf" is not in the grid + # "cbd" is not in the grid + ], + ) result == expected # Should not concatenate different lines to find a horizontal word @@ -428,9 +470,11 @@ expect """ words_to_search_for = ["elixir"] result = grid |> search words_to_search_for - expected = Dict.from_list [ - # "elixir" is not in the grid - ] + expected = Dict.from_list( + [ + # "elixir" is not in the grid + ], + ) result == expected # Should not wrap around horizontally to find a word @@ -438,9 +482,11 @@ expect grid = "silabcdefp" words_to_search_for = ["lisp"] result = grid |> search words_to_search_for - expected = Dict.from_list [ - # "lisp" is not in the grid - ] + expected = Dict.from_list( + [ + # "lisp" is not in the grid + ], + ) result == expected # Should not wrap around vertically to find a word @@ -457,8 +503,10 @@ expect """ words_to_search_for = ["rust"] result = grid |> search words_to_search_for - expected = Dict.from_list [ - # "rust" is not in the grid - ] + expected = Dict.from_list( + [ + # "rust" is not in the grid + ], + ) result == expected From f0b2500fcb1bef4efa237796e7a3f9267fc66348 Mon Sep 17 00:00:00 2001 From: Anton-4 <17049058+Anton-4@users.noreply.github.com> Date: Sat, 26 Jul 2025 19:25:42 +0200 Subject: [PATCH 6/8] more syntax updates --- .../practice/accumulate/.meta/template.j2 | 2 +- .../practice/accumulate/accumulate-test.roc | 2 +- .../circular-buffer/.meta/template.j2 | 2 +- .../circular-buffer/circular-buffer-test.roc | 28 +- exercises/practice/clock/.meta/template.j2 | 8 +- exercises/practice/clock/clock-test.roc | 148 ++++----- .../complex-numbers/.meta/template.j2 | 4 +- .../complex-numbers/complex-numbers-test.roc | 24 +- .../practice/custom-set/.meta/template.j2 | 4 +- .../practice/custom-set/custom-set-test.roc | 34 +- exercises/practice/dominoes/.meta/template.j2 | 6 +- exercises/practice/dominoes/dominoes-test.roc | 6 +- exercises/practice/etl/.meta/template.j2 | 2 +- exercises/practice/etl/etl-test.roc | 8 +- .../practice/flatten-array/.meta/plugins.py | 4 +- .../flatten-array/flatten-array-test.roc | 300 +++++++++++------- exercises/practice/forth/.meta/template.j2 | 2 +- exercises/practice/forth/forth-test.roc | 131 ++++---- .../practice/go-counting/.meta/template.j2 | 10 +- .../practice/go-counting/go-counting-test.roc | 36 +-- exercises/practice/grains/.meta/template.j2 | 2 +- exercises/practice/grains/grains-test.roc | 18 +- .../practice/high-scores/.meta/template.j2 | 2 +- .../practice/high-scores/high-scores-test.roc | 4 +- .../killer-sudoku-helper/.meta/template.j2 | 2 +- .../killer-sudoku-helper-test.roc | 26 +- exercises/practice/leap/.meta/template.j2 | 2 +- exercises/practice/leap/leap-test.roc | 18 +- .../practice/ocr-numbers/.meta/template.j2 | 2 +- .../practice/ocr-numbers/ocr-numbers-test.roc | 34 +- .../palindrome-products/.meta/template.j2 | 8 +- .../palindrome-products-test.roc | 28 +- .../pascals-triangle/.meta/template.j2 | 2 +- .../pascals-triangle-test.roc | 16 +- .../practice/queen-attack/.meta/template.j2 | 18 +- .../queen-attack/queen-attack-test.roc | 66 ++-- .../rational-numbers/.meta/plugins.py | 2 +- .../rational-numbers/.meta/template.j2 | 2 +- .../rational-numbers-test.roc | 172 +++++----- 39 files changed, 629 insertions(+), 556 deletions(-) diff --git a/exercises/practice/accumulate/.meta/template.j2 b/exercises/practice/accumulate/.meta/template.j2 index 1ca22045..3b652ad1 100644 --- a/exercises/practice/accumulate/.meta/template.j2 +++ b/exercises/practice/accumulate/.meta/template.j2 @@ -8,7 +8,7 @@ import {{ exercise | to_pascal }} exposing [{{ cases[0]["property"] | to_snake } "(x) => x * x": "|x|\n x * x", "(x) => upcase(x)": "to_upper", "(x) => reverse(x)": "reverse", - "(x) => accumulate([\"1\", \"2\", \"3\"], (y) => x + y)": "|x|\n accumulate [\"1\", \"2\", \"3\"] (\\y -> Str.concat(x, y))" + "(x) => accumulate([\"1\", \"2\", \"3\"], (y) => x + y)": "|x|\n accumulate([\"1\", \"2\", \"3\"], |y| Str.concat(x, y))" } -%} {% for case in cases -%} diff --git a/exercises/practice/accumulate/accumulate-test.roc b/exercises/practice/accumulate/accumulate-test.roc index fd2acf16..fbf6ed81 100644 --- a/exercises/practice/accumulate/accumulate-test.roc +++ b/exercises/practice/accumulate/accumulate-test.roc @@ -45,7 +45,7 @@ expect result = accumulate( ["a", "b", "c"], |x| - accumulate ["1", "2", "3"] (|y| Str.concat(x, y)), + accumulate(["1", "2", "3"], |y| Str.concat(x, y)), ) result == [["a1", "a2", "a3"], ["b1", "b2", "b3"], ["c1", "c2", "c3"]] diff --git a/exercises/practice/circular-buffer/.meta/template.j2 b/exercises/practice/circular-buffer/.meta/template.j2 index f3565715..0c550d7d 100644 --- a/exercises/practice/circular-buffer/.meta/template.j2 +++ b/exercises/practice/circular-buffer/.meta/template.j2 @@ -8,7 +8,7 @@ import {{ exercise | to_pascal }} exposing [create, read, write, overwrite, clea # {{ case["description"] }} run_operations{{ loop.index }} = |_| result = - create { capacity: {{ case["input"]["capacity"] }} } + create({ capacity: {{ case["input"]["capacity"] }} }) {%- for op in case["input"]["operations"] -%} {%- if op["operation"] == "clear" %} |> clear diff --git a/exercises/practice/circular-buffer/circular-buffer-test.roc b/exercises/practice/circular-buffer/circular-buffer-test.roc index 2b186309..f6a2fb2f 100644 --- a/exercises/practice/circular-buffer/circular-buffer-test.roc +++ b/exercises/practice/circular-buffer/circular-buffer-test.roc @@ -15,7 +15,7 @@ import CircularBuffer exposing [create, read, write, overwrite, clear] # reading empty buffer should fail run_operations1 = |_| result = - create { capacity: 1 } + create({ capacity: 1 }) |> |buffer_before_read| read_result = buffer_before_read |> read expect read_result == Err(BufferEmpty) @@ -29,7 +29,7 @@ expect # can read an item just written run_operations2 = |_| result = - create { capacity: 1 } + create({ capacity: 1 }) |> write(1)? |> read? |> |read_result| @@ -44,7 +44,7 @@ expect # each item may only be read once run_operations3 = |_| result = - create { capacity: 1 } + create({ capacity: 1 }) |> write(1)? |> read? |> |read_result| @@ -63,7 +63,7 @@ expect # items are read in the order they are written run_operations4 = |_| result = - create { capacity: 2 } + create({ capacity: 2 }) |> write(1)? |> write(2)? |> read? @@ -83,7 +83,7 @@ expect # full buffer can't be written to run_operations5 = |_| result = - create { capacity: 1 } + create({ capacity: 1 }) |> write(1)? |> |buffer_before_write| write_result = buffer_before_write |> write 2 @@ -98,7 +98,7 @@ expect # a read frees up capacity for another write run_operations6 = |_| result = - create { capacity: 1 } + create({ capacity: 1 }) |> write(1)? |> read? |> |read_result| @@ -118,7 +118,7 @@ expect # read position is maintained even across multiple writes run_operations7 = |_| result = - create { capacity: 3 } + create({ capacity: 3 }) |> write(1)? |> write(2)? |> read? @@ -143,7 +143,7 @@ expect # items cleared out of buffer can't be read run_operations8 = |_| result = - create { capacity: 1 } + create({ capacity: 1 }) |> write(1)? |> clear |> |buffer_before_read| @@ -159,7 +159,7 @@ expect # clear frees up capacity for another write run_operations9 = |_| result = - create { capacity: 1 } + create({ capacity: 1 }) |> write(1)? |> clear |> write(2)? @@ -176,7 +176,7 @@ expect # clear does nothing on empty buffer run_operations10 = |_| result = - create { capacity: 1 } + create({ capacity: 1 }) |> clear |> write(1)? |> read? @@ -192,7 +192,7 @@ expect # overwrite acts like write on non-full buffer run_operations11 = |_| result = - create { capacity: 2 } + create({ capacity: 2 }) |> write(1)? |> overwrite 2 |> read? @@ -212,7 +212,7 @@ expect # overwrite replaces the oldest item on full buffer run_operations12 = |_| result = - create { capacity: 2 } + create({ capacity: 2 }) |> write(1)? |> write(2)? |> overwrite 3 @@ -233,7 +233,7 @@ expect # overwrite replaces the oldest item remaining in buffer following a read run_operations13 = |_| result = - create { capacity: 3 } + create({ capacity: 3 }) |> write(1)? |> write(2)? |> write(3)? @@ -264,7 +264,7 @@ expect # initial clear does not affect wrapping around run_operations14 = |_| result = - create { capacity: 2 } + create({ capacity: 2 }) |> clear |> write(1)? |> write(2)? diff --git a/exercises/practice/clock/.meta/template.j2 b/exercises/practice/clock/.meta/template.j2 index 4c98e23a..0455601a 100644 --- a/exercises/practice/clock/.meta/template.j2 +++ b/exercises/practice/clock/.meta/template.j2 @@ -9,20 +9,20 @@ import {{ exercise | to_pascal }} exposing [create, add, subtract, to_str] {%- if case["property"] == "create" %} expect - clock = create {{ plugins.to_hours_minutes_record(case["input"]) }} + clock = create({{ plugins.to_hours_minutes_record(case["input"]) }}) result = clock |> to_str expected = {{ case["expected"] | to_roc }} result == expected {%- elif case["property"] in ["add", "subtract"] %} expect - clock = create {{ plugins.to_hours_minutes_record(case["input"]) }} + clock = create({{ plugins.to_hours_minutes_record(case["input"]) }}) result = clock |> {{ case["property"] | to_snake }}({ minutes: {{ case["input"]["value"] }} }) |> to_str expected = {{ case["expected"] | to_roc }} result == expected {%- elif case["property"] == "equal" %} expect - clock1 = create {{ plugins.to_hours_minutes_record(case["input"]["clock1"]) }} - clock2 = create {{ plugins.to_hours_minutes_record(case["input"]["clock2"]) }} + clock1 = create({{ plugins.to_hours_minutes_record(case["input"]["clock1"]) }}) + clock2 = create({{ plugins.to_hours_minutes_record(case["input"]["clock2"]) }}) clock1 {%- if case["expected"] %} == {%- else %} != {% endif %} clock2 {%- else %} diff --git a/exercises/practice/clock/clock-test.roc b/exercises/practice/clock/clock-test.roc index 93b43591..92d6a396 100644 --- a/exercises/practice/clock/clock-test.roc +++ b/exercises/practice/clock/clock-test.roc @@ -18,140 +18,140 @@ import Clock exposing [create, add, subtract, to_str] # on the hour expect - clock = create { hours: 8 } + clock = create({ hours: 8 }) result = clock |> to_str expected = "08:00" result == expected # past the hour expect - clock = create { hours: 11, minutes: 9 } + clock = create({ hours: 11, minutes: 9 }) result = clock |> to_str expected = "11:09" result == expected # midnight is zero hours expect - clock = create { hours: 24 } + clock = create({ hours: 24 }) result = clock |> to_str expected = "00:00" result == expected # hour rolls over expect - clock = create { hours: 25 } + clock = create({ hours: 25 }) result = clock |> to_str expected = "01:00" result == expected # hour rolls over continuously expect - clock = create { hours: 100 } + clock = create({ hours: 100 }) result = clock |> to_str expected = "04:00" result == expected # sixty minutes is next hour expect - clock = create { hours: 1, minutes: 60 } + clock = create({ hours: 1, minutes: 60 }) result = clock |> to_str expected = "02:00" result == expected # minutes roll over expect - clock = create { minutes: 160 } + clock = create({ minutes: 160 }) result = clock |> to_str expected = "02:40" result == expected # minutes roll over continuously expect - clock = create { minutes: 1723 } + clock = create({ minutes: 1723 }) result = clock |> to_str expected = "04:43" result == expected # hour and minutes roll over expect - clock = create { hours: 25, minutes: 160 } + clock = create({ hours: 25, minutes: 160 }) result = clock |> to_str expected = "03:40" result == expected # hour and minutes roll over continuously expect - clock = create { hours: 201, minutes: 3001 } + clock = create({ hours: 201, minutes: 3001 }) result = clock |> to_str expected = "11:01" result == expected # hour and minutes roll over to exactly midnight expect - clock = create { hours: 72, minutes: 8640 } + clock = create({ hours: 72, minutes: 8640 }) result = clock |> to_str expected = "00:00" result == expected # negative hour expect - clock = create { hours: -1, minutes: 15 } + clock = create({ hours: -1, minutes: 15 }) result = clock |> to_str expected = "23:15" result == expected # negative hour rolls over expect - clock = create { hours: -25 } + clock = create({ hours: -25 }) result = clock |> to_str expected = "23:00" result == expected # negative hour rolls over continuously expect - clock = create { hours: -91 } + clock = create({ hours: -91 }) result = clock |> to_str expected = "05:00" result == expected # negative minutes expect - clock = create { hours: 1, minutes: -40 } + clock = create({ hours: 1, minutes: -40 }) result = clock |> to_str expected = "00:20" result == expected # negative minutes roll over expect - clock = create { hours: 1, minutes: -160 } + clock = create({ hours: 1, minutes: -160 }) result = clock |> to_str expected = "22:20" result == expected # negative minutes roll over continuously expect - clock = create { hours: 1, minutes: -4820 } + clock = create({ hours: 1, minutes: -4820 }) result = clock |> to_str expected = "16:40" result == expected # negative sixty minutes is previous hour expect - clock = create { hours: 2, minutes: -60 } + clock = create({ hours: 2, minutes: -60 }) result = clock |> to_str expected = "01:00" result == expected # negative hour and minutes both roll over expect - clock = create { hours: -25, minutes: -160 } + clock = create({ hours: -25, minutes: -160 }) result = clock |> to_str expected = "20:20" result == expected # negative hour and minutes both roll over continuously expect - clock = create { hours: -121, minutes: -5810 } + clock = create({ hours: -121, minutes: -5810 }) result = clock |> to_str expected = "22:10" result == expected @@ -162,56 +162,56 @@ expect # add minutes expect - clock = create { hours: 10 } + clock = create({ hours: 10 }) result = clock |> add({ minutes: 3 }) |> to_str expected = "10:03" result == expected # add no minutes expect - clock = create { hours: 6, minutes: 41 } + clock = create({ hours: 6, minutes: 41 }) result = clock |> add({ minutes: 0 }) |> to_str expected = "06:41" result == expected # add to next hour expect - clock = create { minutes: 45 } + clock = create({ minutes: 45 }) result = clock |> add({ minutes: 40 }) |> to_str expected = "01:25" result == expected # add more than one hour expect - clock = create { hours: 10 } + clock = create({ hours: 10 }) result = clock |> add({ minutes: 61 }) |> to_str expected = "11:01" result == expected # add more than two hours with carry expect - clock = create { minutes: 45 } + clock = create({ minutes: 45 }) result = clock |> add({ minutes: 160 }) |> to_str expected = "03:25" result == expected # add across midnight expect - clock = create { hours: 23, minutes: 59 } + clock = create({ hours: 23, minutes: 59 }) result = clock |> add({ minutes: 2 }) |> to_str expected = "00:01" result == expected # add more than one day (1500 min = 25 hrs) expect - clock = create { hours: 5, minutes: 32 } + clock = create({ hours: 5, minutes: 32 }) result = clock |> add({ minutes: 1500 }) |> to_str expected = "06:32" result == expected # add more than two days expect - clock = create { hours: 1, minutes: 1 } + clock = create({ hours: 1, minutes: 1 }) result = clock |> add({ minutes: 3500 }) |> to_str expected = "11:21" result == expected @@ -222,56 +222,56 @@ expect # subtract minutes expect - clock = create { hours: 10, minutes: 3 } + clock = create({ hours: 10, minutes: 3 }) result = clock |> subtract({ minutes: 3 }) |> to_str expected = "10:00" result == expected # subtract to previous hour expect - clock = create { hours: 10, minutes: 3 } + clock = create({ hours: 10, minutes: 3 }) result = clock |> subtract({ minutes: 30 }) |> to_str expected = "09:33" result == expected # subtract more than an hour expect - clock = create { hours: 10, minutes: 3 } + clock = create({ hours: 10, minutes: 3 }) result = clock |> subtract({ minutes: 70 }) |> to_str expected = "08:53" result == expected # subtract across midnight expect - clock = create { minutes: 3 } + clock = create({ minutes: 3 }) result = clock |> subtract({ minutes: 4 }) |> to_str expected = "23:59" result == expected # subtract more than two hours expect - clock = create {} + clock = create({}) result = clock |> subtract({ minutes: 160 }) |> to_str expected = "21:20" result == expected # subtract more than two hours with borrow expect - clock = create { hours: 6, minutes: 15 } + clock = create({ hours: 6, minutes: 15 }) result = clock |> subtract({ minutes: 160 }) |> to_str expected = "03:35" result == expected # subtract more than one day (1500 min = 25 hrs) expect - clock = create { hours: 5, minutes: 32 } + clock = create({ hours: 5, minutes: 32 }) result = clock |> subtract({ minutes: 1500 }) |> to_str expected = "04:32" result == expected # subtract more than two days expect - clock = create { hours: 2, minutes: 20 } + clock = create({ hours: 2, minutes: 20 }) result = clock |> subtract({ minutes: 3000 }) |> to_str expected = "00:20" result == expected @@ -282,98 +282,98 @@ expect # clocks with same time expect - clock1 = create { hours: 15, minutes: 37 } - clock2 = create { hours: 15, minutes: 37 } + clock1 = create({ hours: 15, minutes: 37 }) + clock2 = create({ hours: 15, minutes: 37 }) clock1 == clock2 # clocks a minute apart expect - clock1 = create { hours: 15, minutes: 36 } - clock2 = create { hours: 15, minutes: 37 } + clock1 = create({ hours: 15, minutes: 36 }) + clock2 = create({ hours: 15, minutes: 37 }) clock1 != clock2 # clocks an hour apart expect - clock1 = create { hours: 14, minutes: 37 } - clock2 = create { hours: 15, minutes: 37 } + clock1 = create({ hours: 14, minutes: 37 }) + clock2 = create({ hours: 15, minutes: 37 }) clock1 != clock2 # clocks with hour overflow expect - clock1 = create { hours: 10, minutes: 37 } - clock2 = create { hours: 34, minutes: 37 } + clock1 = create({ hours: 10, minutes: 37 }) + clock2 = create({ hours: 34, minutes: 37 }) clock1 == clock2 # clocks with hour overflow by several days expect - clock1 = create { hours: 3, minutes: 11 } - clock2 = create { hours: 99, minutes: 11 } + clock1 = create({ hours: 3, minutes: 11 }) + clock2 = create({ hours: 99, minutes: 11 }) clock1 == clock2 # clocks with negative hour expect - clock1 = create { hours: 22, minutes: 40 } - clock2 = create { hours: -2, minutes: 40 } + clock1 = create({ hours: 22, minutes: 40 }) + clock2 = create({ hours: -2, minutes: 40 }) clock1 == clock2 # clocks with negative hour that wraps expect - clock1 = create { hours: 17, minutes: 3 } - clock2 = create { hours: -31, minutes: 3 } + clock1 = create({ hours: 17, minutes: 3 }) + clock2 = create({ hours: -31, minutes: 3 }) clock1 == clock2 # clocks with negative hour that wraps multiple times expect - clock1 = create { hours: 13, minutes: 49 } - clock2 = create { hours: -83, minutes: 49 } + clock1 = create({ hours: 13, minutes: 49 }) + clock2 = create({ hours: -83, minutes: 49 }) clock1 == clock2 # clocks with minute overflow expect - clock1 = create { minutes: 1 } - clock2 = create { minutes: 1441 } + clock1 = create({ minutes: 1 }) + clock2 = create({ minutes: 1441 }) clock1 == clock2 # clocks with minute overflow by several days expect - clock1 = create { hours: 2, minutes: 2 } - clock2 = create { hours: 2, minutes: 4322 } + clock1 = create({ hours: 2, minutes: 2 }) + clock2 = create({ hours: 2, minutes: 4322 }) clock1 == clock2 # clocks with negative minute expect - clock1 = create { hours: 2, minutes: 40 } - clock2 = create { hours: 3, minutes: -20 } + clock1 = create({ hours: 2, minutes: 40 }) + clock2 = create({ hours: 3, minutes: -20 }) clock1 == clock2 # clocks with negative minute that wraps expect - clock1 = create { hours: 4, minutes: 10 } - clock2 = create { hours: 5, minutes: -1490 } + clock1 = create({ hours: 4, minutes: 10 }) + clock2 = create({ hours: 5, minutes: -1490 }) clock1 == clock2 # clocks with negative minute that wraps multiple times expect - clock1 = create { hours: 6, minutes: 15 } - clock2 = create { hours: 6, minutes: -4305 } + clock1 = create({ hours: 6, minutes: 15 }) + clock2 = create({ hours: 6, minutes: -4305 }) clock1 == clock2 # clocks with negative hours and minutes expect - clock1 = create { hours: 7, minutes: 32 } - clock2 = create { hours: -12, minutes: -268 } + clock1 = create({ hours: 7, minutes: 32 }) + clock2 = create({ hours: -12, minutes: -268 }) clock1 == clock2 # clocks with negative hours and minutes that wrap expect - clock1 = create { hours: 18, minutes: 7 } - clock2 = create { hours: -54, minutes: -11513 } + clock1 = create({ hours: 18, minutes: 7 }) + clock2 = create({ hours: -54, minutes: -11513 }) clock1 == clock2 # full clock and zeroed clock expect - clock1 = create { hours: 24 } - clock2 = create {} + clock1 = create({ hours: 24 }) + clock2 = create({}) clock1 == clock2 ## @@ -382,42 +382,42 @@ expect # Can create a clock with max I64 values expect - clock = create { hours: 9223372036854775807, minutes: 9223372036854775807 } + clock = create({ hours: 9223372036854775807, minutes: 9223372036854775807 }) result = clock |> to_str expected = "01:07" result == expected # Can create a clock with min I64 values expect - clock = create { hours: -9223372036854775808, minutes: -9223372036854775808 } + clock = create({ hours: -9223372036854775808, minutes: -9223372036854775808 }) result = clock |> to_str expected = "21:52" result == expected # Can add max I64 values to a clock expect - clock = create { hours: 23, minutes: 59 } + clock = create({ hours: 23, minutes: 59 }) result = clock |> add({ minutes: 9223372036854775807 }) |> to_str expected = "18:06" result == expected # Can add min I64 values to a clock expect - clock = create { hours: 23, minutes: 59 } + clock = create({ hours: 23, minutes: 59 }) result = clock |> add({ minutes: -9223372036854775808 }) |> to_str expected = "05:51" result == expected # Can subtract max I64 values from a clock expect - clock = create { hours: 23, minutes: 59 } + clock = create({ hours: 23, minutes: 59 }) result = clock |> subtract({ minutes: 9223372036854775807 }) |> to_str expected = "05:52" result == expected # Can subtract min I64 values from a clock expect - clock = create { hours: 23, minutes: 59 } + clock = create({ hours: 23, minutes: 59 }) result = clock |> subtract({ minutes: -9223372036854775808 }) |> to_str expected = "18:07" result == expected diff --git a/exercises/practice/complex-numbers/.meta/template.j2 b/exercises/practice/complex-numbers/.meta/template.j2 index fa2a6d85..4b777eed 100644 --- a/exercises/practice/complex-numbers/.meta/template.j2 +++ b/exercises/practice/complex-numbers/.meta/template.j2 @@ -5,7 +5,7 @@ import {{ exercise | to_pascal }} exposing [real, imaginary, add, sub, mul, div, conjugate, abs, exp] is_approx_eq = |z1, z2| - z1.re |> Num.is_approx_eq z2.re {} && z1.im |> Num.is_approx_eq z2.im {} + z1.re |> Num.is_approx_eq(z2.re, {}) && z1.im |> Num.is_approx_eq(z2.im, {}) {% for supercase in cases %} ### @@ -30,7 +30,7 @@ expect expected = {{ plugins.to_complex_number(subcase["expected"]) }} result |> is_approx_eq expected {%- else %} - result |> Num.is_approx_eq {{ subcase["expected"] | to_roc }} {} + result |> Num.is_approx_eq({{ subcase["expected"] | to_roc }}, {}) {%- endif %} {%- elif subcase["input"]["z1"] %} expect diff --git a/exercises/practice/complex-numbers/complex-numbers-test.roc b/exercises/practice/complex-numbers/complex-numbers-test.roc index bad13743..4d4ec898 100644 --- a/exercises/practice/complex-numbers/complex-numbers-test.roc +++ b/exercises/practice/complex-numbers/complex-numbers-test.roc @@ -13,7 +13,7 @@ main! = |_args| import ComplexNumbers exposing [real, imaginary, add, sub, mul, div, conjugate, abs, exp] is_approx_eq = |z1, z2| - z1.re |> Num.is_approx_eq z2.re {} and z1.im |> Num.is_approx_eq z2.im {} + z1.re |> Num.is_approx_eq(z2.re, {}) and z1.im |> Num.is_approx_eq(z2.im, {}) ### ### Real part @@ -23,19 +23,19 @@ is_approx_eq = |z1, z2| expect z = { re: 1, im: 0 } result = real z - result |> Num.is_approx_eq 1 {} + result |> Num.is_approx_eq(1, {}) # Real part of a purely imaginary number expect z = { re: 0, im: 1 } result = real z - result |> Num.is_approx_eq 0 {} + result |> Num.is_approx_eq(0, {}) # Real part of a number with real and imaginary part expect z = { re: 1, im: 2 } result = real z - result |> Num.is_approx_eq 1 {} + result |> Num.is_approx_eq(1, {}) ### ### Imaginary part @@ -45,19 +45,19 @@ expect expect z = { re: 1, im: 0 } result = imaginary z - result |> Num.is_approx_eq 0 {} + result |> Num.is_approx_eq(0, {}) # Imaginary part of a purely imaginary number expect z = { re: 0, im: 1 } result = imaginary z - result |> Num.is_approx_eq 1 {} + result |> Num.is_approx_eq(1, {}) # Imaginary part of a number with real and imaginary part expect z = { re: 1, im: 2 } result = imaginary z - result |> Num.is_approx_eq 2 {} + result |> Num.is_approx_eq(2, {}) ### ### Imaginary unit @@ -179,31 +179,31 @@ expect expect z = { re: 5, im: 0 } result = abs z - result |> Num.is_approx_eq 5 {} + result |> Num.is_approx_eq(5, {}) # Absolute value of a negative purely real number expect z = { re: -5, im: 0 } result = abs z - result |> Num.is_approx_eq 5 {} + result |> Num.is_approx_eq(5, {}) # Absolute value of a purely imaginary number with positive imaginary part expect z = { re: 0, im: 5 } result = abs z - result |> Num.is_approx_eq 5 {} + result |> Num.is_approx_eq(5, {}) # Absolute value of a purely imaginary number with negative imaginary part expect z = { re: 0, im: -5 } result = abs z - result |> Num.is_approx_eq 5 {} + result |> Num.is_approx_eq(5, {}) # Absolute value of a number with real and imaginary part expect z = { re: 3, im: 4 } result = abs z - result |> Num.is_approx_eq 5 {} + result |> Num.is_approx_eq(5, {}) ### ### Complex conjugate diff --git a/exercises/practice/custom-set/.meta/template.j2 b/exercises/practice/custom-set/.meta/template.j2 index 188d3a2a..6826a1a7 100644 --- a/exercises/practice/custom-set/.meta/template.j2 +++ b/exercises/practice/custom-set/.meta/template.j2 @@ -38,7 +38,7 @@ expect {%- if "set" in case["input"] %} set = from_list({{ case["input"]["set"] | to_roc }}) result = set |> {{ property | to_snake }} - {%- if "element" in case["input"] %} {{ case["input"]["element"] }}{%- endif %} + {%- if "element" in case["input"] %} {{(case["input"]["element"])}}{%- endif %} {%- else %} set1 = from_list({{ case["input"]["set1"] | to_roc }}) set2 = from_list({{ case["input"]["set2"] | to_roc }}) @@ -46,7 +46,7 @@ expect {%- endif %} {%- if case["expected"] is iterable %} expected = {{ case["expected"] | to_roc }} |> from_list - result |> is_eq expected + result |> is_eq(expected) {%- else %} expected = {{ case["expected"] | to_roc }} result == expected diff --git a/exercises/practice/custom-set/custom-set-test.roc b/exercises/practice/custom-set/custom-set-test.roc index c51c9d97..49e3fef5 100644 --- a/exercises/practice/custom-set/custom-set-test.roc +++ b/exercises/practice/custom-set/custom-set-test.roc @@ -256,7 +256,7 @@ expect set = from_list([]) result = set |> insert 3 expected = [3] |> from_list - result |> is_eq expected + result |> is_eq(expected) # add to non-empty set @@ -264,7 +264,7 @@ expect set = from_list([1, 2, 4]) result = set |> insert 3 expected = [1, 2, 3, 4] |> from_list - result |> is_eq expected + result |> is_eq(expected) # adding an existing element does not change the set @@ -272,7 +272,7 @@ expect set = from_list([1, 2, 3]) result = set |> insert 3 expected = [1, 2, 3] |> from_list - result |> is_eq expected + result |> is_eq(expected) ## ## Intersection returns a set of all shared elements @@ -285,7 +285,7 @@ expect set2 = from_list([]) result = set1 |> intersection(set2) expected = [] |> from_list - result |> is_eq expected + result |> is_eq(expected) # intersection of an empty set and non-empty set is an empty set @@ -294,7 +294,7 @@ expect set2 = from_list([3, 2, 5]) result = set1 |> intersection(set2) expected = [] |> from_list - result |> is_eq expected + result |> is_eq(expected) # intersection of a non-empty set and an empty set is an empty set @@ -303,7 +303,7 @@ expect set2 = from_list([]) result = set1 |> intersection(set2) expected = [] |> from_list - result |> is_eq expected + result |> is_eq(expected) # intersection of two sets with no shared elements is an empty set @@ -312,7 +312,7 @@ expect set2 = from_list([4, 5, 6]) result = set1 |> intersection(set2) expected = [] |> from_list - result |> is_eq expected + result |> is_eq(expected) # intersection of two sets with shared elements is a set of the shared elements @@ -321,7 +321,7 @@ expect set2 = from_list([3, 2, 5]) result = set1 |> intersection(set2) expected = [2, 3] |> from_list - result |> is_eq expected + result |> is_eq(expected) ## ## Difference (or Complement) of a set is a set of all elements that are only in the first set @@ -334,7 +334,7 @@ expect set2 = from_list([]) result = set1 |> difference(set2) expected = [] |> from_list - result |> is_eq expected + result |> is_eq(expected) # difference of empty set and non-empty set is an empty set @@ -343,7 +343,7 @@ expect set2 = from_list([3, 2, 5]) result = set1 |> difference(set2) expected = [] |> from_list - result |> is_eq expected + result |> is_eq(expected) # difference of a non-empty set and an empty set is the non-empty set @@ -352,7 +352,7 @@ expect set2 = from_list([]) result = set1 |> difference(set2) expected = [1, 2, 3, 4] |> from_list - result |> is_eq expected + result |> is_eq(expected) # difference of two non-empty sets is a set of elements that are only in the first set @@ -361,7 +361,7 @@ expect set2 = from_list([2, 4]) result = set1 |> difference(set2) expected = [1, 3] |> from_list - result |> is_eq expected + result |> is_eq(expected) # difference removes all duplicates in the first set @@ -370,7 +370,7 @@ expect set2 = from_list([1]) result = set1 |> difference(set2) expected = [] |> from_list - result |> is_eq expected + result |> is_eq(expected) ## ## Union returns a set of all elements in either set @@ -383,7 +383,7 @@ expect set2 = from_list([]) result = set1 |> union(set2) expected = [] |> from_list - result |> is_eq expected + result |> is_eq(expected) # union of an empty set and non-empty set is the non-empty set @@ -392,7 +392,7 @@ expect set2 = from_list([2]) result = set1 |> union(set2) expected = [2] |> from_list - result |> is_eq expected + result |> is_eq(expected) # union of a non-empty set and empty set is the non-empty set @@ -401,7 +401,7 @@ expect set2 = from_list([]) result = set1 |> union(set2) expected = [1, 3] |> from_list - result |> is_eq expected + result |> is_eq(expected) # union of non-empty sets contains all unique elements @@ -410,7 +410,7 @@ expect set2 = from_list([2, 3]) result = set1 |> union(set2) expected = [3, 2, 1] |> from_list - result |> is_eq expected + result |> is_eq(expected) ## ## A set can be converted to a list of items diff --git a/exercises/practice/dominoes/.meta/template.j2 b/exercises/practice/dominoes/.meta/template.j2 index 036913ee..cd28e4a8 100644 --- a/exercises/practice/dominoes/.meta/template.j2 +++ b/exercises/practice/dominoes/.meta/template.j2 @@ -25,11 +25,11 @@ canonicalize = |dominoes| ## Ensure that the given result is Ok and is a valid chain for the ## given list of dominoes is_valid_chain_for : Result (List Domino) _, List Domino -> Bool -is_valid_chain_for = |maybeChain, dominoes| - when maybeChain is +is_valid_chain_for = |maybe_chain, dominoes| + when maybe_chain is Err(_) -> Bool.false Ok(chain) -> - if Set.from_list(canonicalize chain) == Set.from_list(canonicalize dominoes) then + if Set.from_list(canonicalize(chain)) == Set.from_list(canonicalize(dominoes)) then when chain is [] -> Bool.true [.., last] -> diff --git a/exercises/practice/dominoes/dominoes-test.roc b/exercises/practice/dominoes/dominoes-test.roc index 049d7ae9..63e9270f 100644 --- a/exercises/practice/dominoes/dominoes-test.roc +++ b/exercises/practice/dominoes/dominoes-test.roc @@ -26,11 +26,11 @@ canonicalize = |dominoes| ## Ensure that the given result is Ok and is a valid chain for the ## given list of dominoes is_valid_chain_for : Result (List Domino) _, List Domino -> Bool -is_valid_chain_for = |maybeChain, dominoes| - when maybeChain is +is_valid_chain_for = |maybe_chain, dominoes| + when maybe_chain is Err(_) -> Bool.false Ok(chain) -> - if Set.from_list(canonicalize chain) == Set.from_list(canonicalize dominoes) then + if Set.from_list(canonicalize(chain)) == Set.from_list(canonicalize(dominoes)) then when chain is [] -> Bool.true [.., last] -> diff --git a/exercises/practice/etl/.meta/template.j2 b/exercises/practice/etl/.meta/template.j2 index 5058d36f..eb107999 100644 --- a/exercises/practice/etl/.meta/template.j2 +++ b/exercises/practice/etl/.meta/template.j2 @@ -19,6 +19,6 @@ expect ('{{letter}}', {{ score }}), {%- endfor %} ]) - transform legacy == expected + transform(legacy) == expected {% endfor %} diff --git a/exercises/practice/etl/etl-test.roc b/exercises/practice/etl/etl-test.roc index 99490d46..8f7e0061 100644 --- a/exercises/practice/etl/etl-test.roc +++ b/exercises/practice/etl/etl-test.roc @@ -26,7 +26,7 @@ expect ('a', 1), ], ) - transform legacy == expected + transform(legacy) == expected # single score with multiple letters expect @@ -46,7 +46,7 @@ expect ('u', 1), ], ) - transform legacy == expected + transform(legacy) == expected # multiple scores with multiple letters expect @@ -66,7 +66,7 @@ expect ('g', 2), ], ) - transform legacy == expected + transform(legacy) == expected # multiple scores with differing numbers of letters expect @@ -113,5 +113,5 @@ expect ('z', 10), ], ) - transform legacy == expected + transform(legacy) == expected diff --git a/exercises/practice/flatten-array/.meta/plugins.py b/exercises/practice/flatten-array/.meta/plugins.py index b8d04960..83ba7509 100644 --- a/exercises/practice/flatten-array/.meta/plugins.py +++ b/exercises/practice/flatten-array/.meta/plugins.py @@ -2,7 +2,7 @@ def to_nested(value, top_level=True): if value is None: return "Null" elif isinstance(value, int): - return f"Value {value}" + return f"Value({value})" else: content = ", ".join([to_nested(elem, False) for elem in value]) - return f"NestedArray [\n{content}]" + return f"NestedArray([\n{content}])" diff --git a/exercises/practice/flatten-array/flatten-array-test.roc b/exercises/practice/flatten-array/flatten-array-test.roc index b31a60d7..1ec17e05 100644 --- a/exercises/practice/flatten-array/flatten-array-test.roc +++ b/exercises/practice/flatten-array/flatten-array-test.roc @@ -15,193 +15,265 @@ import FlattenArray exposing [flatten] # empty expect result = flatten( - NestedArray [ - ], + NestedArray( + [ + ], + ), ) result == [] # no nesting expect result = flatten( - NestedArray [ - Value 0, - Value 1, - Value 2, - ], + NestedArray( + [ + Value(0), + Value(1), + Value(2), + ], + ), ) result == [0, 1, 2] # flattens a nested array expect result = flatten( - NestedArray [ - NestedArray [ - NestedArray [ - ], + NestedArray( + [ + NestedArray( + [ + NestedArray( + [ + ], + ), + ], + ), ], - ], + ), ) result == [] # flattens array with just integers present expect result = flatten( - NestedArray [ - Value 1, - NestedArray [ - Value 2, - Value 3, - Value 4, - Value 5, - Value 6, - Value 7, + NestedArray( + [ + Value(1), + NestedArray( + [ + Value(2), + Value(3), + Value(4), + Value(5), + Value(6), + Value(7), + ], + ), + Value(8), ], - Value 8, - ], + ), ) result == [1, 2, 3, 4, 5, 6, 7, 8] # 5 level nesting expect result = flatten( - NestedArray [ - Value 0, - Value 2, - NestedArray [ - NestedArray [ - Value 2, - Value 3, - ], - Value 8, - Value 100, - Value 4, - NestedArray [ - NestedArray [ - NestedArray [ - Value 50, - ], + NestedArray( + [ + Value(0), + Value(2), + NestedArray( + [ + NestedArray( + [ + Value(2), + Value(3), + ], + ), + Value(8), + Value(100), + Value(4), + NestedArray( + [ + NestedArray( + [ + NestedArray( + [ + Value(50), + ], + ), + ], + ), + ], + ), ], - ], + ), + Value(-2), ], - Value -2, - ], + ), ) result == [0, 2, 2, 3, 8, 100, 4, 50, -2] # 6 level nesting expect result = flatten( - NestedArray [ - Value 1, - NestedArray [ - Value 2, - NestedArray [ - NestedArray [ - Value 3, - ], - ], - NestedArray [ - Value 4, - NestedArray [ - NestedArray [ - Value 5, - ], + NestedArray( + [ + Value(1), + NestedArray( + [ + Value(2), + NestedArray( + [ + NestedArray( + [ + Value(3), + ], + ), + ], + ), + NestedArray( + [ + Value(4), + NestedArray( + [ + NestedArray( + [ + Value(5), + ], + ), + ], + ), + ], + ), + Value(6), + Value(7), ], - ], - Value 6, - Value 7, + ), + Value(8), ], - Value 8, - ], + ), ) result == [1, 2, 3, 4, 5, 6, 7, 8] # null values are omitted from the final result expect result = flatten( - NestedArray [ - Value 1, - Value 2, - Null, - ], + NestedArray( + [ + Value(1), + Value(2), + Null, + ], + ), ) result == [1, 2] # consecutive null values at the front of the array are omitted from the final result expect result = flatten( - NestedArray [ - Null, - Null, - Value 3, - ], + NestedArray( + [ + Null, + Null, + Value(3), + ], + ), ) result == [3] # consecutive null values in the middle of the array are omitted from the final result expect result = flatten( - NestedArray [ - Value 1, - Null, - Null, - Value 4, - ], + NestedArray( + [ + Value(1), + Null, + Null, + Value(4), + ], + ), ) result == [1, 4] # 6 level nested array with null values expect result = flatten( - NestedArray [ - Value 0, - Value 2, - NestedArray [ - NestedArray [ - Value 2, - Value 3, - ], - Value 8, - NestedArray [ - NestedArray [ - Value 100, - ], - ], - Null, - NestedArray [ - NestedArray [ + NestedArray( + [ + Value(0), + Value(2), + NestedArray( + [ + NestedArray( + [ + Value(2), + Value(3), + ], + ), + Value(8), + NestedArray( + [ + NestedArray( + [ + Value(100), + ], + ), + ], + ), Null, + NestedArray( + [ + NestedArray( + [ + Null, + ], + ), + ], + ), ], - ], + ), + Value(-2), ], - Value -2, - ], + ), ) result == [0, 2, 2, 3, 8, 100, -2] # all values in nested array are null expect result = flatten( - NestedArray [ - Null, - NestedArray [ - NestedArray [ - NestedArray [ + NestedArray( + [ + Null, + NestedArray( + [ + NestedArray( + [ + NestedArray( + [ + Null, + ], + ), + ], + ), + ], + ), + Null, + Null, + NestedArray( + [ + NestedArray( + [ + Null, + Null, + ], + ), Null, ], - ], - ], - Null, - Null, - NestedArray [ - NestedArray [ - Null, - Null, - ], + ), Null, ], - Null, - ], + ), ) result == [] diff --git a/exercises/practice/forth/.meta/template.j2 b/exercises/practice/forth/.meta/template.j2 index e964f09a..2a51879e 100644 --- a/exercises/practice/forth/.meta/template.j2 +++ b/exercises/practice/forth/.meta/template.j2 @@ -8,7 +8,7 @@ import Forth exposing [evaluate] {% for innerCase in case["cases"] %} # {{ case["description"] }}: {{ innerCase["description"] }} expect - result = evaluate {{ innerCase["input"]["instructions"] | join('\n') | to_roc_multiline_string | indent(8) }} + result = evaluate({{ innerCase["input"]["instructions"] | join('\n') | to_roc_multiline_string | indent(8) }}) {%- if innerCase["expected"]["error"] %} Result.is_err(result) {%- else %} diff --git a/exercises/practice/forth/forth-test.roc b/exercises/practice/forth/forth-test.roc index be1a4084..615818eb 100644 --- a/exercises/practice/forth/forth-test.roc +++ b/exercises/practice/forth/forth-test.roc @@ -14,301 +14,310 @@ import Forth exposing [evaluate] # parsing and numbers: numbers just get pushed onto the stack expect - result = evaluate "1 2 3 4 5" + result = evaluate("1 2 3 4 5") result == Ok([1, 2, 3, 4, 5]) # parsing and numbers: pushes negative numbers onto the stack expect - result = evaluate "-1 -2 -3 -4 -5" + result = evaluate("-1 -2 -3 -4 -5") result == Ok([-1, -2, -3, -4, -5]) # addition: can add two numbers expect - result = evaluate "1 2 +" + result = evaluate("1 2 +") result == Ok([3]) # addition: errors if there is nothing on the stack expect - result = evaluate "+" + result = evaluate("+") Result.is_err(result) # addition: errors if there is only one value on the stack expect - result = evaluate "1 +" + result = evaluate("1 +") Result.is_err(result) # addition: more than two values on the stack expect - result = evaluate "1 2 3 +" + result = evaluate("1 2 3 +") result == Ok([1, 5]) # subtraction: can subtract two numbers expect - result = evaluate "3 4 -" + result = evaluate("3 4 -") result == Ok([-1]) # subtraction: errors if there is nothing on the stack expect - result = evaluate "-" + result = evaluate("-") Result.is_err(result) # subtraction: errors if there is only one value on the stack expect - result = evaluate "1 -" + result = evaluate("1 -") Result.is_err(result) # subtraction: more than two values on the stack expect - result = evaluate "1 12 3 -" + result = evaluate("1 12 3 -") result == Ok([1, 9]) # multiplication: can multiply two numbers expect - result = evaluate "2 4 *" + result = evaluate("2 4 *") result == Ok([8]) # multiplication: errors if there is nothing on the stack expect - result = evaluate "*" + result = evaluate("*") Result.is_err(result) # multiplication: errors if there is only one value on the stack expect - result = evaluate "1 *" + result = evaluate("1 *") Result.is_err(result) # multiplication: more than two values on the stack expect - result = evaluate "1 2 3 *" + result = evaluate("1 2 3 *") result == Ok([1, 6]) # division: can divide two numbers expect - result = evaluate "12 3 /" + result = evaluate("12 3 /") result == Ok([4]) # division: performs integer division expect - result = evaluate "8 3 /" + result = evaluate("8 3 /") result == Ok([2]) # division: errors if dividing by zero expect - result = evaluate "4 0 /" + result = evaluate("4 0 /") Result.is_err(result) # division: errors if there is nothing on the stack expect - result = evaluate "/" + result = evaluate("/") Result.is_err(result) # division: errors if there is only one value on the stack expect - result = evaluate "1 /" + result = evaluate("1 /") Result.is_err(result) # division: more than two values on the stack expect - result = evaluate "1 12 3 /" + result = evaluate("1 12 3 /") result == Ok([1, 4]) # combined arithmetic: addition and subtraction expect - result = evaluate "1 2 + 4 -" + result = evaluate("1 2 + 4 -") result == Ok([-1]) # combined arithmetic: multiplication and division expect - result = evaluate "2 4 * 3 /" + result = evaluate("2 4 * 3 /") result == Ok([2]) # combined arithmetic: multiplication and addition expect - result = evaluate "1 3 4 * +" + result = evaluate("1 3 4 * +") result == Ok([13]) # combined arithmetic: addition and multiplication expect - result = evaluate "1 3 4 + *" + result = evaluate("1 3 4 + *") result == Ok([7]) # dup: copies a value on the stack expect - result = evaluate "1 dup" + result = evaluate("1 dup") result == Ok([1, 1]) # dup: copies the top value on the stack expect - result = evaluate "1 2 dup" + result = evaluate("1 2 dup") result == Ok([1, 2, 2]) # dup: errors if there is nothing on the stack expect - result = evaluate "dup" + result = evaluate("dup") Result.is_err(result) # drop: removes the top value on the stack if it is the only one expect - result = evaluate "1 drop" + result = evaluate("1 drop") result == Ok([]) # drop: removes the top value on the stack if it is not the only one expect - result = evaluate "1 2 drop" + result = evaluate("1 2 drop") result == Ok([1]) # drop: errors if there is nothing on the stack expect - result = evaluate "drop" + result = evaluate("drop") Result.is_err(result) # swap: swaps the top two values on the stack if they are the only ones expect - result = evaluate "1 2 swap" + result = evaluate("1 2 swap") result == Ok([2, 1]) # swap: swaps the top two values on the stack if they are not the only ones expect - result = evaluate "1 2 3 swap" + result = evaluate("1 2 3 swap") result == Ok([1, 3, 2]) # swap: errors if there is nothing on the stack expect - result = evaluate "swap" + result = evaluate("swap") Result.is_err(result) # swap: errors if there is only one value on the stack expect - result = evaluate "1 swap" + result = evaluate("1 swap") Result.is_err(result) # over: copies the second element if there are only two expect - result = evaluate "1 2 over" + result = evaluate("1 2 over") result == Ok([1, 2, 1]) # over: copies the second element if there are more than two expect - result = evaluate "1 2 3 over" + result = evaluate("1 2 3 over") result == Ok([1, 2, 3, 2]) # over: errors if there is nothing on the stack expect - result = evaluate "over" + result = evaluate("over") Result.is_err(result) # over: errors if there is only one value on the stack expect - result = evaluate "1 over" + result = evaluate("1 over") Result.is_err(result) # user-defined words: can consist of built-in words expect - result = evaluate + result = evaluate( """ : dup-twice dup dup ; 1 dup-twice - """ + """, + ) result == Ok([1, 1, 1]) # user-defined words: execute in the right order expect - result = evaluate + result = evaluate( """ : countup 1 2 3 ; countup - """ + """, + ) result == Ok([1, 2, 3]) # user-defined words: can override other user-defined words expect - result = evaluate + result = evaluate( """ : foo dup ; : foo dup dup ; 1 foo - """ + """, + ) result == Ok([1, 1, 1]) # user-defined words: can override built-in words expect - result = evaluate + result = evaluate( """ : swap dup ; 1 swap - """ + """, + ) result == Ok([1, 1]) # user-defined words: can override built-in operators expect - result = evaluate + result = evaluate( """ : + * ; 3 4 + - """ + """, + ) result == Ok([12]) # user-defined words: can use different words with the same name expect - result = evaluate + result = evaluate( """ : foo 5 ; : bar foo ; : foo 6 ; bar foo - """ + """, + ) result == Ok([5, 6]) # user-defined words: can define word that uses word with the same name expect - result = evaluate + result = evaluate( """ : foo 10 ; : foo foo 1 + ; foo - """ + """, + ) result == Ok([11]) # user-defined words: errors if executing a non-existent word expect - result = evaluate "foo" + result = evaluate("foo") Result.is_err(result) # case-insensitivity: DUP is case-insensitive expect - result = evaluate "1 DUP Dup dup" + result = evaluate("1 DUP Dup dup") result == Ok([1, 1, 1, 1]) # case-insensitivity: DROP is case-insensitive expect - result = evaluate "1 2 3 4 DROP Drop drop" + result = evaluate("1 2 3 4 DROP Drop drop") result == Ok([1]) # case-insensitivity: SWAP is case-insensitive expect - result = evaluate "1 2 SWAP 3 Swap 4 swap" + result = evaluate("1 2 SWAP 3 Swap 4 swap") result == Ok([2, 3, 4, 1]) # case-insensitivity: OVER is case-insensitive expect - result = evaluate "1 2 OVER Over over" + result = evaluate("1 2 OVER Over over") result == Ok([1, 2, 1, 2, 1]) # case-insensitivity: user-defined words are case-insensitive expect - result = evaluate + result = evaluate( """ : foo dup ; 1 FOO Foo foo - """ + """, + ) result == Ok([1, 1, 1, 1]) # case-insensitivity: definitions are case-insensitive expect - result = evaluate + result = evaluate( """ : SWAP DUP Dup dup ; 1 swap - """ + """, + ) result == Ok([1, 1, 1, 1]) diff --git a/exercises/practice/go-counting/.meta/template.j2 b/exercises/practice/go-counting/.meta/template.j2 index 44f896cd..39965f97 100644 --- a/exercises/practice/go-counting/.meta/template.j2 +++ b/exercises/practice/go-counting/.meta/template.j2 @@ -20,12 +20,12 @@ import {{ exercise | to_pascal }} exposing [territory, territories] ## comparing tags or records containing sets sometimes returns the wrong result ## depending on the internal order of the set data, so we have to unwrap the sets ## in order to compare them properly. -compareTerritory = |maybe_result, maybe_expected| +compare_territory = |maybe_result, maybe_expected| when (maybe_result, maybe_expected) is (Ok(result), Ok(expected)) -> result.owner == expected.owner && result.territory == expected.territory _ -> Bool.false -compareTerritories = |maybe_result, maybe_expected| +compare_territories = |maybe_result, maybe_expected| when (maybe_result, maybe_expected) is (Ok(result), Ok(expected)) -> result.black == expected.black && result.white == expected.white && result.none == expected.none _ -> Bool.false @@ -33,7 +33,7 @@ compareTerritories = |maybe_result, maybe_expected| {% for case in cases -%} # {{ case["description"] }} expect - board = {{ case["input"]["board"] | to_roc_multiline_string | replace(" ", "·") | indent(8) }} |> Str.replace_each "·" " " + board = {{ case["input"]["board"] | to_roc_multiline_string | replace(" ", "·") | indent(8) }} |> Str.replace_each("·", " ") result = board |> {{ case["property"] | to_snake }} {%- if case["property"] == "territory" %} { x : {{ case["input"]["x"] }}, y : {{ case["input"]["y"] }} }{% endif %} {%- if case["expected"]["error"] %} @@ -43,14 +43,14 @@ expect owner: {{ case["expected"]["owner"] | to_pascal }}, territory: {{ to_territory(case["expected"]["territory"]) }}, }) - result |> compareTerritory expected + result |> compare_territory(expected) {%- else %} expected = Ok({ black: {{ to_territory(case["expected"]["territoryBlack"]) }}, white: {{ to_territory(case["expected"]["territoryWhite"]) }}, none: {{ to_territory(case["expected"]["territoryNone"]) }}, }) - result |> compareTerritories expected + result |> compare_territories(expected) {%- endif %} diff --git a/exercises/practice/go-counting/go-counting-test.roc b/exercises/practice/go-counting/go-counting-test.roc index 2fc2b28b..6abb8aef 100644 --- a/exercises/practice/go-counting/go-counting-test.roc +++ b/exercises/practice/go-counting/go-counting-test.roc @@ -16,12 +16,12 @@ import GoCounting exposing [territory, territories] ## comparing tags or records containing sets sometimes returns the wrong result ## depending on the internal order of the set data, so we have to unwrap the sets ## in order to compare them properly. -compareTerritory = |maybe_result, maybe_expected| +compare_territory = |maybe_result, maybe_expected| when (maybe_result, maybe_expected) is (Ok(result), Ok(expected)) -> result.owner == expected.owner and result.territory == expected.territory _ -> Bool.false -compareTerritories = |maybe_result, maybe_expected| +compare_territories = |maybe_result, maybe_expected| when (maybe_result, maybe_expected) is (Ok(result), Ok(expected)) -> result.black == expected.black and result.white == expected.white and result.none == expected.none _ -> Bool.false @@ -36,7 +36,7 @@ expect ·W·W· ··W·· """ - |> Str.replace_each "·" " " + |> Str.replace_each("·", " ") result = board |> territory { x: 0, y: 1 } expected = Ok( { @@ -50,7 +50,7 @@ expect ), }, ) - result |> compareTerritory expected + result |> compare_territory(expected) # White center territory on 5x5 board expect @@ -62,7 +62,7 @@ expect ·W·W· ··W·· """ - |> Str.replace_each "·" " " + |> Str.replace_each("·", " ") result = board |> territory { x: 2, y: 3 } expected = Ok( { @@ -74,7 +74,7 @@ expect ), }, ) - result |> compareTerritory expected + result |> compare_territory(expected) # Open corner territory on 5x5 board expect @@ -86,7 +86,7 @@ expect ·W·W· ··W·· """ - |> Str.replace_each "·" " " + |> Str.replace_each("·", " ") result = board |> territory { x: 1, y: 4 } expected = Ok( { @@ -100,7 +100,7 @@ expect ), }, ) - result |> compareTerritory expected + result |> compare_territory(expected) # A stone and not a territory on 5x5 board expect @@ -112,7 +112,7 @@ expect ·W·W· ··W·· """ - |> Str.replace_each "·" " " + |> Str.replace_each("·", " ") result = board |> territory { x: 1, y: 1 } expected = Ok( { @@ -120,7 +120,7 @@ expect territory: Set.empty {}, }, ) - result |> compareTerritory expected + result |> compare_territory(expected) # Invalid because X is too high for 5x5 board expect @@ -132,7 +132,7 @@ expect ·W·W· ··W·· """ - |> Str.replace_each "·" " " + |> Str.replace_each("·", " ") result = board |> territory { x: 5, y: 1 } result |> Result.is_err @@ -146,13 +146,13 @@ expect ·W·W· ··W·· """ - |> Str.replace_each "·" " " + |> Str.replace_each("·", " ") result = board |> territory { x: 1, y: 5 } result |> Result.is_err # One territory is the whole board expect - board = "·" |> Str.replace_each "·" " " + board = "·" |> Str.replace_each("·", " ") result = board |> territories expected = Ok( { @@ -167,7 +167,7 @@ expect ), }, ) - result |> compareTerritories expected + result |> compare_territories(expected) # Two territory rectangular board expect @@ -176,7 +176,7 @@ expect ·BW· ·BW· """ - |> Str.replace_each "·" " " + |> Str.replace_each("·", " ") result = board |> territories expected = Ok( { @@ -197,11 +197,11 @@ expect none: Set.empty {}, }, ) - result |> compareTerritories expected + result |> compare_territories(expected) # Two region rectangular board expect - board = "·B·" |> Str.replace_each "·" " " + board = "·B·" |> Str.replace_each("·", " ") result = board |> territories expected = Ok( { @@ -217,5 +217,5 @@ expect none: Set.empty {}, }, ) - result |> compareTerritories expected + result |> compare_territories(expected) diff --git a/exercises/practice/grains/.meta/template.j2 b/exercises/practice/grains/.meta/template.j2 index 1d014c69..70005fdf 100644 --- a/exercises/practice/grains/.meta/template.j2 +++ b/exercises/practice/grains/.meta/template.j2 @@ -16,7 +16,7 @@ expect {% for subcase in case["cases"] -%} # {{ subcase["description"] }} expect - result = grains_on_square {{ subcase["input"]["square"] }} + result = grains_on_square({{ subcase["input"]["square"] }}) {%- if subcase["expected"]["error"] %} Result.is_err(result) {%- else %} diff --git a/exercises/practice/grains/grains-test.roc b/exercises/practice/grains/grains-test.roc index 07b9f5bb..938d9bc1 100644 --- a/exercises/practice/grains/grains-test.roc +++ b/exercises/practice/grains/grains-test.roc @@ -18,47 +18,47 @@ import Grains exposing [grains_on_square, total_grains] # grains on square 1 expect - result = grains_on_square 1 + result = grains_on_square(1) result == Ok(1) # grains on square 2 expect - result = grains_on_square 2 + result = grains_on_square(2) result == Ok(2) # grains on square 3 expect - result = grains_on_square 3 + result = grains_on_square(3) result == Ok(4) # grains on square 4 expect - result = grains_on_square 4 + result = grains_on_square(4) result == Ok(8) # grains on square 16 expect - result = grains_on_square 16 + result = grains_on_square(16) result == Ok(32768) # grains on square 32 expect - result = grains_on_square 32 + result = grains_on_square(32) result == Ok(2147483648) # grains on square 64 expect - result = grains_on_square 64 + result = grains_on_square(64) result == Ok(9223372036854775808) # square 0 is invalid expect - result = grains_on_square 0 + result = grains_on_square(0) Result.is_err(result) # square greater than 64 is invalid expect - result = grains_on_square 65 + result = grains_on_square(65) Result.is_err(result) ## diff --git a/exercises/practice/high-scores/.meta/template.j2 b/exercises/practice/high-scores/.meta/template.j2 index 8607c15a..0c7b1cc5 100644 --- a/exercises/practice/high-scores/.meta/template.j2 +++ b/exercises/practice/high-scores/.meta/template.j2 @@ -17,7 +17,7 @@ import {{ exercise | to_pascal }} exposing [latest, personal_best, personal_top_ {%- endif %} expect result = {{ case["property"] | to_snake }}({{ case["input"]["scores"] }}) - result == {% if case["property"] != "personalTopThree" %}Ok({{ case["expected"] | to_roc }}){% endif %}{{ case["expected"] | to_roc }} + result == {% if case["property"] != "personalTopThree" %}Ok({{ case["expected"] | to_roc }}){%- else -%}{{ case["expected"] | to_roc }}{% endif %} {% endfor -%} {%- endfor %} diff --git a/exercises/practice/high-scores/high-scores-test.roc b/exercises/practice/high-scores/high-scores-test.roc index c0ab80a7..69eeb89e 100644 --- a/exercises/practice/high-scores/high-scores-test.roc +++ b/exercises/practice/high-scores/high-scores-test.roc @@ -15,12 +15,12 @@ import HighScores exposing [latest, personal_best, personal_top_three] ## Latest score expect result = latest([100, 0, 90, 30]) - result == Ok(30) 30 + result == Ok(30) ## Personal best expect result = personal_best([40, 100, 70]) - result == Ok(100) 100 + result == Ok(100) ## Top 3 scores # Personal top three from a list of scores diff --git a/exercises/practice/killer-sudoku-helper/.meta/template.j2 b/exercises/practice/killer-sudoku-helper/.meta/template.j2 index bf7ac864..8d4e33e3 100644 --- a/exercises/practice/killer-sudoku-helper/.meta/template.j2 +++ b/exercises/practice/killer-sudoku-helper/.meta/template.j2 @@ -23,7 +23,7 @@ import {{ exercise | to_pascal }} exposing [combinations] # {{ case["description"] }} {%- endif %} expect - result = {{ case["property"] }} {{ to_cage(case["input"]["cage"]) }} + result = {{ case["property"] }}({{ to_cage(case["input"]["cage"]) }}) result == {{ case["expected"] | to_roc }} {% endfor -%} diff --git a/exercises/practice/killer-sudoku-helper/killer-sudoku-helper-test.roc b/exercises/practice/killer-sudoku-helper/killer-sudoku-helper-test.roc index 2687a5fb..57249442 100644 --- a/exercises/practice/killer-sudoku-helper/killer-sudoku-helper-test.roc +++ b/exercises/practice/killer-sudoku-helper/killer-sudoku-helper-test.roc @@ -15,66 +15,66 @@ import KillerSudokuHelper exposing [combinations] ## Trivial 1-digit cages # 1 expect - result = combinations { sum: 1, size: 1 } + result = combinations({ sum: 1, size: 1 }) result == [[1]] # 2 expect - result = combinations { sum: 2, size: 1 } + result = combinations({ sum: 2, size: 1 }) result == [[2]] # 3 expect - result = combinations { sum: 3, size: 1 } + result = combinations({ sum: 3, size: 1 }) result == [[3]] # 4 expect - result = combinations { sum: 4, size: 1 } + result = combinations({ sum: 4, size: 1 }) result == [[4]] # 5 expect - result = combinations { sum: 5, size: 1 } + result = combinations({ sum: 5, size: 1 }) result == [[5]] # 6 expect - result = combinations { sum: 6, size: 1 } + result = combinations({ sum: 6, size: 1 }) result == [[6]] # 7 expect - result = combinations { sum: 7, size: 1 } + result = combinations({ sum: 7, size: 1 }) result == [[7]] # 8 expect - result = combinations { sum: 8, size: 1 } + result = combinations({ sum: 8, size: 1 }) result == [[8]] # 9 expect - result = combinations { sum: 9, size: 1 } + result = combinations({ sum: 9, size: 1 }) result == [[9]] ## Cage with sum 45 contains all digits 1:9 expect - result = combinations { sum: 45, size: 9 } + result = combinations({ sum: 45, size: 9 }) result == [[1, 2, 3, 4, 5, 6, 7, 8, 9]] ## Cage with only 1 possible combination expect - result = combinations { sum: 7, size: 3 } + result = combinations({ sum: 7, size: 3 }) result == [[1, 2, 4]] ## Cage with several combinations expect - result = combinations { sum: 10, size: 2 } + result = combinations({ sum: 10, size: 2 }) result == [[1, 9], [2, 8], [3, 7], [4, 6]] ## Cage with several combinations that is restricted expect - result = combinations { sum: 10, size: 2, exclude: [1, 4] } + result = combinations({ sum: 10, size: 2, exclude: [1, 4] }) result == [[2, 8], [3, 7]] diff --git a/exercises/practice/leap/.meta/template.j2 b/exercises/practice/leap/.meta/template.j2 index e03fa3f8..c974c801 100644 --- a/exercises/practice/leap/.meta/template.j2 +++ b/exercises/practice/leap/.meta/template.j2 @@ -8,7 +8,7 @@ import Leap exposing [is_leap_year] {% for case in cases -%} # {{ case["description"] }} expect - result = (is_leap_year {{ case["input"]["year"] }}) + result = is_leap_year({{ case["input"]["year"] }}) result == {{ case ["expected"] | to_roc }} {% endfor %} diff --git a/exercises/practice/leap/leap-test.roc b/exercises/practice/leap/leap-test.roc index d6d745b0..111d743b 100644 --- a/exercises/practice/leap/leap-test.roc +++ b/exercises/practice/leap/leap-test.roc @@ -14,46 +14,46 @@ import Leap exposing [is_leap_year] # year not divisible by 4 in common year expect - result = is_leap_year 2015 + result = is_leap_year(2015) result == Bool.false # year divisible by 2, not divisible by 4 in common year expect - result = is_leap_year 1970 + result = is_leap_year(1970) result == Bool.false # year divisible by 4, not divisible by 100 in leap year expect - result = is_leap_year 1996 + result = is_leap_year(1996) result == Bool.true # year divisible by 4 and 5 is still a leap year expect - result = is_leap_year 1960 + result = is_leap_year(1960) result == Bool.true # year divisible by 100, not divisible by 400 in common year expect - result = is_leap_year 2100 + result = is_leap_year(2100) result == Bool.false # year divisible by 100 but not by 3 is still not a leap year expect - result = is_leap_year 1900 + result = is_leap_year(1900) result == Bool.false # year divisible by 400 is leap year expect - result = is_leap_year 2000 + result = is_leap_year(2000) result == Bool.true # year divisible by 400 but not by 125 is still a leap year expect - result = is_leap_year 2400 + result = is_leap_year(2400) result == Bool.true # year divisible by 200, not divisible by 400 in common year expect - result = is_leap_year 1800 + result = is_leap_year(1800) result == Bool.false diff --git a/exercises/practice/ocr-numbers/.meta/template.j2 b/exercises/practice/ocr-numbers/.meta/template.j2 index 468210a2..85b49b0b 100644 --- a/exercises/practice/ocr-numbers/.meta/template.j2 +++ b/exercises/practice/ocr-numbers/.meta/template.j2 @@ -8,7 +8,7 @@ import {{ exercise | to_pascal }} exposing [{{ cases[0]["property"] | to_snake } # {{ case["description"] }} expect grid = {{ case["input"]["rows"] | to_roc_multiline_string | indent(8) }} - result = {{ case["property"] | to_snake }} grid + result = {{ case["property"] | to_snake }}(grid) {%- if case["expected"]["error"] %} result |> Result.is_err {%- else %} diff --git a/exercises/practice/ocr-numbers/ocr-numbers-test.roc b/exercises/practice/ocr-numbers/ocr-numbers-test.roc index c86700ae..99565618 100644 --- a/exercises/practice/ocr-numbers/ocr-numbers-test.roc +++ b/exercises/practice/ocr-numbers/ocr-numbers-test.roc @@ -21,7 +21,7 @@ expect |_| """ - result = convert grid + result = convert(grid) expected = Ok("0") result == expected @@ -34,7 +34,7 @@ expect | """ - result = convert grid + result = convert(grid) expected = Ok("1") result == expected @@ -47,7 +47,7 @@ expect | """ - result = convert grid + result = convert(grid) expected = Ok("?") result == expected @@ -59,7 +59,7 @@ expect | | """ - result = convert grid + result = convert(grid) result |> Result.is_err # Input with a number of columns that is not a multiple of three raises an error @@ -71,7 +71,7 @@ expect | """ - result = convert grid + result = convert(grid) result |> Result.is_err # Recognizes 110101100 @@ -83,7 +83,7 @@ expect | ||_| ||_| | ||_||_| """ - result = convert grid + result = convert(grid) expected = Ok("110101100") result == expected @@ -96,7 +96,7 @@ expect | | _| ||_| | ||_||_| """ - result = convert grid + result = convert(grid) expected = Ok("11?10?1?0") result == expected @@ -109,7 +109,7 @@ expect |_ """ - result = convert grid + result = convert(grid) expected = Ok("2") result == expected @@ -122,7 +122,7 @@ expect _| """ - result = convert grid + result = convert(grid) expected = Ok("3") result == expected @@ -135,7 +135,7 @@ expect | """ - result = convert grid + result = convert(grid) expected = Ok("4") result == expected @@ -148,7 +148,7 @@ expect _| """ - result = convert grid + result = convert(grid) expected = Ok("5") result == expected @@ -161,7 +161,7 @@ expect |_| """ - result = convert grid + result = convert(grid) expected = Ok("6") result == expected @@ -174,7 +174,7 @@ expect | """ - result = convert grid + result = convert(grid) expected = Ok("7") result == expected @@ -187,7 +187,7 @@ expect |_| """ - result = convert grid + result = convert(grid) expected = Ok("8") result == expected @@ -200,7 +200,7 @@ expect _| """ - result = convert grid + result = convert(grid) expected = Ok("9") result == expected @@ -213,7 +213,7 @@ expect ||_ _| | _||_| ||_| _||_| """ - result = convert grid + result = convert(grid) expected = Ok("1234567890") result == expected @@ -234,7 +234,7 @@ expect ||_| _| """ - result = convert grid + result = convert(grid) expected = Ok("123,456,789") result == expected diff --git a/exercises/practice/palindrome-products/.meta/template.j2 b/exercises/practice/palindrome-products/.meta/template.j2 index 5cb06a1f..7c80bd28 100644 --- a/exercises/practice/palindrome-products/.meta/template.j2 +++ b/exercises/practice/palindrome-products/.meta/template.j2 @@ -4,10 +4,10 @@ import {{ exercise | to_pascal }} exposing [smallest, largest] -isEq = |result, expected| +is_eq = |result, expected| when (result, expected) is - (Ok({value, factors}), Ok({value: expectedValue, factors: expectedFactors})) -> - value == expectedValue && factors == expectedFactors + (Ok({value, factors}), Ok({value: expected_value, factors: expected_factors})) -> + value == expected_value && factors == expected_factors _ -> Bool.false {% for case in cases -%} @@ -24,7 +24,7 @@ expect ({{ pair[0] }}, {{ pair[1] }}),{% endfor %} ]) }) - result |> isEq expected + result |> is_eq(expected) {%- endif %} {% endfor %} diff --git a/exercises/practice/palindrome-products/palindrome-products-test.roc b/exercises/practice/palindrome-products/palindrome-products-test.roc index 26f14da2..77613521 100644 --- a/exercises/practice/palindrome-products/palindrome-products-test.roc +++ b/exercises/practice/palindrome-products/palindrome-products-test.roc @@ -12,10 +12,10 @@ main! = |_args| import PalindromeProducts exposing [smallest, largest] -isEq = |result, expected| +is_eq = |result, expected| when (result, expected) is - (Ok({ value, factors }), Ok({ value: expectedValue, factors: expectedFactors })) -> - value == expectedValue and factors == expectedFactors + (Ok({ value, factors }), Ok({ value: expected_value, factors: expected_factors })) -> + value == expected_value and factors == expected_factors _ -> Bool.false @@ -32,7 +32,7 @@ expect ), }, ) - result |> isEq expected + result |> is_eq(expected) # find the largest palindrome from single digit factors expect @@ -48,7 +48,7 @@ expect ), }, ) - result |> isEq expected + result |> is_eq(expected) # find the smallest palindrome from double digit factors expect @@ -63,7 +63,7 @@ expect ), }, ) - result |> isEq expected + result |> is_eq(expected) # find the largest palindrome from double digit factors expect @@ -78,7 +78,7 @@ expect ), }, ) - result |> isEq expected + result |> is_eq(expected) # find the smallest palindrome from triple digit factors expect @@ -93,7 +93,7 @@ expect ), }, ) - result |> isEq expected + result |> is_eq(expected) # find the largest palindrome from triple digit factors expect @@ -108,7 +108,7 @@ expect ), }, ) - result |> isEq expected + result |> is_eq(expected) # find the smallest palindrome from four digit factors expect @@ -123,7 +123,7 @@ expect ), }, ) - result |> isEq expected + result |> is_eq(expected) # find the largest palindrome from four digit factors expect @@ -138,7 +138,7 @@ expect ), }, ) - result |> isEq expected + result |> is_eq(expected) # empty result for smallest if no palindrome in the range expect @@ -152,7 +152,7 @@ expect ), }, ) - result |> isEq expected + result |> is_eq(expected) # empty result for largest if no palindrome in the range expect @@ -166,7 +166,7 @@ expect ), }, ) - result |> isEq expected + result |> is_eq(expected) # error result for smallest if min is more than max expect @@ -191,5 +191,5 @@ expect ), }, ) - result |> isEq expected + result |> is_eq(expected) diff --git a/exercises/practice/pascals-triangle/.meta/template.j2 b/exercises/practice/pascals-triangle/.meta/template.j2 index ba5d20dc..db72aca9 100644 --- a/exercises/practice/pascals-triangle/.meta/template.j2 +++ b/exercises/practice/pascals-triangle/.meta/template.j2 @@ -7,7 +7,7 @@ import {{ exercise | to_pascal }} exposing [pascals_triangle] {% for case in cases -%} # {{ case["description"] }} expect - result = pascals_triangle {{ case["input"]["count"] | to_roc }} + result = pascals_triangle({{ case["input"]["count"] | to_roc }}) expected = [{%- for row in case["expected"] %} {{ row | to_roc }}, {%- endfor %}] diff --git a/exercises/practice/pascals-triangle/pascals-triangle-test.roc b/exercises/practice/pascals-triangle/pascals-triangle-test.roc index 1c3191d6..e702adf3 100644 --- a/exercises/practice/pascals-triangle/pascals-triangle-test.roc +++ b/exercises/practice/pascals-triangle/pascals-triangle-test.roc @@ -14,13 +14,13 @@ import PascalsTriangle exposing [pascals_triangle] # zero rows expect - result = pascals_triangle 0 + result = pascals_triangle(0) expected = [] result == expected # single row expect - result = pascals_triangle 1 + result = pascals_triangle(1) expected = [ [1], ] @@ -28,7 +28,7 @@ expect # two rows expect - result = pascals_triangle 2 + result = pascals_triangle(2) expected = [ [1], [1, 1], @@ -37,7 +37,7 @@ expect # three rows expect - result = pascals_triangle 3 + result = pascals_triangle(3) expected = [ [1], [1, 1], @@ -47,7 +47,7 @@ expect # four rows expect - result = pascals_triangle 4 + result = pascals_triangle(4) expected = [ [1], [1, 1], @@ -58,7 +58,7 @@ expect # five rows expect - result = pascals_triangle 5 + result = pascals_triangle(5) expected = [ [1], [1, 1], @@ -70,7 +70,7 @@ expect # six rows expect - result = pascals_triangle 6 + result = pascals_triangle(6) expected = [ [1], [1, 1], @@ -83,7 +83,7 @@ expect # ten rows expect - result = pascals_triangle 10 + result = pascals_triangle(10) expected = [ [1], [1, 1], diff --git a/exercises/practice/queen-attack/.meta/template.j2 b/exercises/practice/queen-attack/.meta/template.j2 index 96f19398..1aad003c 100644 --- a/exercises/practice/queen-attack/.meta/template.j2 +++ b/exercises/practice/queen-attack/.meta/template.j2 @@ -14,26 +14,24 @@ import {{ exercise | to_pascal }} exposing [create, rank, file, queen_can_attack {%- if case["property"] == "create" %} {%- if case["expected"] == 0 %} expect - maybeSquare = create("{{ plugins.to_square(case["input"]["queen"]) }}") - result = maybeSquare |> Result.try |square| - Ok((rank square)) + maybe_square = create("{{ plugins.to_square(case["input"]["queen"]) }}") + result = maybe_square |> Result.try( |square| Ok(rank square) ) result == Ok({{ plugins.to_rank(case["input"]["queen"]["position"]["row"]) }}) expect - maybeSquare = create "{{ plugins.to_square(case["input"]["queen"]) }}" - result = maybeSquare |> Result.try |square| - Ok(file square) + maybe_square = create("{{ plugins.to_square(case["input"]["queen"]) }}") + result = maybe_square |> Result.try( |square| Ok(file square) ) result == Ok('{{ plugins.to_file(case["input"]["queen"]["position"]["column"]) }}') {%- else %} expect - result = create "{{ plugins.to_square(case["input"]["queen"]) }}" + result = create("{{ plugins.to_square(case["input"]["queen"]) }}") result |> Result.is_err {%- endif %} {%- elif case["property"] == "canAttack" %} expect - maybeSquare1 = create("{{ plugins.to_square(case["input"]["white_queen"]) }}") - maybeSquare2 = create("{{ plugins.to_square(case["input"]["black_queen"]) }}") - result = when (maybeSquare1, maybeSquare2) is + maybe_square1 = create("{{ plugins.to_square(case["input"]["white_queen"]) }}") + maybe_square2 = create("{{ plugins.to_square(case["input"]["black_queen"]) }}") + result = when (maybe_square1, maybe_square2) is (Ok(square1), Ok(square2)) -> square1 |> queen_can_attack square2 _ -> crash "Unreachable: {{ plugins.to_square(case["input"]["white_queen"]) }} and {{ plugins.to_square(case["input"]["black_queen"]) }} are both valid squares" diff --git a/exercises/practice/queen-attack/queen-attack-test.roc b/exercises/practice/queen-attack/queen-attack-test.roc index 21563511..8cf8c8a1 100644 --- a/exercises/practice/queen-attack/queen-attack-test.roc +++ b/exercises/practice/queen-attack/queen-attack-test.roc @@ -18,29 +18,23 @@ import QueenAttack exposing [create, rank, file, queen_can_attack] # queen with a valid position expect - maybeSquare = create("C6") - result = - maybeSquare - |> Result.try |square| - Ok(rank square) + maybe_square = create("C6") + result = maybe_square |> Result.try(|square| Ok(rank square)) result == Ok(6) expect - maybeSquare = create "C6" - result = - maybeSquare - |> Result.try |square| - Ok(file square) + maybe_square = create("C6") + result = maybe_square |> Result.try(|square| Ok(file square)) result == Ok('C') # queen must have row on board expect - result = create "E0" + result = create("E0") result |> Result.is_err # queen must have column on board expect - result = create "I4" + result = create("I4") result |> Result.is_err ## @@ -49,10 +43,10 @@ expect # cannot attack expect - maybeSquare1 = create("E6") - maybeSquare2 = create("G2") + maybe_square1 = create("E6") + maybe_square2 = create("G2") result = - when (maybeSquare1, maybeSquare2) is + when (maybe_square1, maybe_square2) is (Ok(square1), Ok(square2)) -> square1 |> queen_can_attack square2 @@ -61,10 +55,10 @@ expect # can attack on same row expect - maybeSquare1 = create("E6") - maybeSquare2 = create("G6") + maybe_square1 = create("E6") + maybe_square2 = create("G6") result = - when (maybeSquare1, maybeSquare2) is + when (maybe_square1, maybe_square2) is (Ok(square1), Ok(square2)) -> square1 |> queen_can_attack square2 @@ -73,10 +67,10 @@ expect # can attack on same column expect - maybeSquare1 = create("F4") - maybeSquare2 = create("F6") + maybe_square1 = create("F4") + maybe_square2 = create("F6") result = - when (maybeSquare1, maybeSquare2) is + when (maybe_square1, maybe_square2) is (Ok(square1), Ok(square2)) -> square1 |> queen_can_attack square2 @@ -85,10 +79,10 @@ expect # can attack on first diagonal expect - maybeSquare1 = create("C6") - maybeSquare2 = create("E8") + maybe_square1 = create("C6") + maybe_square2 = create("E8") result = - when (maybeSquare1, maybeSquare2) is + when (maybe_square1, maybe_square2) is (Ok(square1), Ok(square2)) -> square1 |> queen_can_attack square2 @@ -97,10 +91,10 @@ expect # can attack on second diagonal expect - maybeSquare1 = create("C6") - maybeSquare2 = create("B5") + maybe_square1 = create("C6") + maybe_square2 = create("B5") result = - when (maybeSquare1, maybeSquare2) is + when (maybe_square1, maybe_square2) is (Ok(square1), Ok(square2)) -> square1 |> queen_can_attack square2 @@ -109,10 +103,10 @@ expect # can attack on third diagonal expect - maybeSquare1 = create("C6") - maybeSquare2 = create("B7") + maybe_square1 = create("C6") + maybe_square2 = create("B7") result = - when (maybeSquare1, maybeSquare2) is + when (maybe_square1, maybe_square2) is (Ok(square1), Ok(square2)) -> square1 |> queen_can_attack square2 @@ -121,10 +115,10 @@ expect # can attack on fourth diagonal expect - maybeSquare1 = create("H7") - maybeSquare2 = create("G8") + maybe_square1 = create("H7") + maybe_square2 = create("G8") result = - when (maybeSquare1, maybeSquare2) is + when (maybe_square1, maybe_square2) is (Ok(square1), Ok(square2)) -> square1 |> queen_can_attack square2 @@ -133,10 +127,10 @@ expect # cannot attack if falling diagonals are only the same when reflected across the longest falling diagonal expect - maybeSquare1 = create("B4") - maybeSquare2 = create("F6") + maybe_square1 = create("B4") + maybe_square2 = create("F6") result = - when (maybeSquare1, maybeSquare2) is + when (maybe_square1, maybe_square2) is (Ok(square1), Ok(square2)) -> square1 |> queen_can_attack square2 diff --git a/exercises/practice/rational-numbers/.meta/plugins.py b/exercises/practice/rational-numbers/.meta/plugins.py index b26258c4..26d36cee 100644 --- a/exercises/practice/rational-numbers/.meta/plugins.py +++ b/exercises/practice/rational-numbers/.meta/plugins.py @@ -1,2 +1,2 @@ def to_roc_rational(r): - return f"Rational {r[0]} {r[1]}" + return f"Rational({r[0]}, {r[1]})" diff --git a/exercises/practice/rational-numbers/.meta/template.j2 b/exercises/practice/rational-numbers/.meta/template.j2 index bebc0bad..6d0855cf 100644 --- a/exercises/practice/rational-numbers/.meta/template.j2 +++ b/exercises/practice/rational-numbers/.meta/template.j2 @@ -35,7 +35,7 @@ expect {%- if case["expected"] is iterable %} result == {{ plugins.to_roc_rational(case["expected"]) }} {%- else %} - result |> Num.is_approx_eq {{ case["expected"] | to_roc }} {} + result |> Num.is_approx_eq({{ case["expected"] | to_roc }}, {}) {%- endif %} {% endmacro %} diff --git a/exercises/practice/rational-numbers/rational-numbers-test.roc b/exercises/practice/rational-numbers/rational-numbers-test.roc index 2ce6a548..abadf63c 100644 --- a/exercises/practice/rational-numbers/rational-numbers-test.roc +++ b/exercises/practice/rational-numbers/rational-numbers-test.roc @@ -18,93 +18,93 @@ import RationalNumbers exposing [add, sub, mul, div, abs, exp, exp_real, reduce] # Add two positive rational numbers expect - result = Rational 1 2 |> add(Rational 2 3) - result == Rational 7 6 + result = Rational(1, 2) |> add(Rational(2, 3)) + result == Rational(7, 6) # Add a positive rational number and a negative rational number expect - result = Rational 1 2 |> add(Rational -2 3) - result == Rational -1 6 + result = Rational(1, 2) |> add(Rational(-2, 3)) + result == Rational(-1, 6) # Add two negative rational numbers expect - result = Rational -1 2 |> add(Rational -2 3) - result == Rational -7 6 + result = Rational(-1, 2) |> add(Rational(-2, 3)) + result == Rational(-7, 6) # Add a rational number to its additive inverse expect - result = Rational 1 2 |> add(Rational -1 2) - result == Rational 0 1 + result = Rational(1, 2) |> add(Rational(-1, 2)) + result == Rational(0, 1) # Subtract two positive rational numbers expect - result = Rational 1 2 |> sub(Rational 2 3) - result == Rational -1 6 + result = Rational(1, 2) |> sub(Rational(2, 3)) + result == Rational(-1, 6) # Subtract a positive rational number and a negative rational number expect - result = Rational 1 2 |> sub(Rational -2 3) - result == Rational 7 6 + result = Rational(1, 2) |> sub(Rational(-2, 3)) + result == Rational(7, 6) # Subtract two negative rational numbers expect - result = Rational -1 2 |> sub(Rational -2 3) - result == Rational 1 6 + result = Rational(-1, 2) |> sub(Rational(-2, 3)) + result == Rational(1, 6) # Subtract a rational number from itself expect - result = Rational 1 2 |> sub(Rational 1 2) - result == Rational 0 1 + result = Rational(1, 2) |> sub(Rational(1, 2)) + result == Rational(0, 1) # Multiply two positive rational numbers expect - result = Rational 1 2 |> mul(Rational 2 3) - result == Rational 1 3 + result = Rational(1, 2) |> mul(Rational(2, 3)) + result == Rational(1, 3) # Multiply a negative rational number by a positive rational number expect - result = Rational -1 2 |> mul(Rational 2 3) - result == Rational -1 3 + result = Rational(-1, 2) |> mul(Rational(2, 3)) + result == Rational(-1, 3) # Multiply two negative rational numbers expect - result = Rational -1 2 |> mul(Rational -2 3) - result == Rational 1 3 + result = Rational(-1, 2) |> mul(Rational(-2, 3)) + result == Rational(1, 3) # Multiply a rational number by its reciprocal expect - result = Rational 1 2 |> mul(Rational 2 1) - result == Rational 1 1 + result = Rational(1, 2) |> mul(Rational(2, 1)) + result == Rational(1, 1) # Multiply a rational number by 1 expect - result = Rational 1 2 |> mul(Rational 1 1) - result == Rational 1 2 + result = Rational(1, 2) |> mul(Rational(1, 1)) + result == Rational(1, 2) # Multiply a rational number by 0 expect - result = Rational 1 2 |> mul(Rational 0 1) - result == Rational 0 1 + result = Rational(1, 2) |> mul(Rational(0, 1)) + result == Rational(0, 1) # Divide two positive rational numbers expect - result = Rational 1 2 |> div(Rational 2 3) - result == Rational 3 4 + result = Rational(1, 2) |> div(Rational(2, 3)) + result == Rational(3, 4) # Divide a positive rational number by a negative rational number expect - result = Rational 1 2 |> div(Rational -2 3) - result == Rational -3 4 + result = Rational(1, 2) |> div(Rational(-2, 3)) + result == Rational(-3, 4) # Divide two negative rational numbers expect - result = Rational -1 2 |> div(Rational -2 3) - result == Rational 3 4 + result = Rational(-1, 2) |> div(Rational(-2, 3)) + result == Rational(3, 4) # Divide a rational number by 1 expect - result = Rational 1 2 |> div(Rational 1 1) - result == Rational 1 2 + result = Rational(1, 2) |> div(Rational(1, 1)) + result == Rational(1, 2) ## ## Absolute value @@ -112,33 +112,33 @@ expect # Absolute value of a positive rational number expect - result = Rational 1 2 |> abs - result == Rational 1 2 + result = Rational(1, 2) |> abs + result == Rational(1, 2) # Absolute value of a positive rational number with negative numerator and denominator expect - result = Rational -1 -2 |> abs - result == Rational 1 2 + result = Rational(-1, -2) |> abs + result == Rational(1, 2) # Absolute value of a negative rational number expect - result = Rational -1 2 |> abs - result == Rational 1 2 + result = Rational(-1, 2) |> abs + result == Rational(1, 2) # Absolute value of a negative rational number with negative denominator expect - result = Rational 1 -2 |> abs - result == Rational 1 2 + result = Rational(1, -2) |> abs + result == Rational(1, 2) # Absolute value of zero expect - result = Rational 0 1 |> abs - result == Rational 0 1 + result = Rational(0, 1) |> abs + result == Rational(0, 1) # Absolute value of a rational number is reduced to lowest terms expect - result = Rational 2 4 |> abs - result == Rational 1 2 + result = Rational(2, 4) |> abs + result == Rational(1, 2) ## ## Exponentiation of a rational number @@ -146,48 +146,48 @@ expect # Raise a positive rational number to a positive integer power expect - result = Rational 1 2 |> exp(3) - result == Rational 1 8 + result = Rational(1, 2) |> exp(3) + result == Rational(1, 8) # Raise a negative rational number to a positive integer power expect - result = Rational -1 2 |> exp(3) - result == Rational -1 8 + result = Rational(-1, 2) |> exp(3) + result == Rational(-1, 8) # Raise a positive rational number to a negative integer power expect - result = Rational 3 5 |> exp(-2) - result == Rational 25 9 + result = Rational(3, 5) |> exp(-2) + result == Rational(25, 9) # Raise a negative rational number to an even negative integer power expect - result = Rational -3 5 |> exp(-2) - result == Rational 25 9 + result = Rational(-3, 5) |> exp(-2) + result == Rational(25, 9) # Raise a negative rational number to an odd negative integer power expect - result = Rational -3 5 |> exp(-3) - result == Rational -125 27 + result = Rational(-3, 5) |> exp(-3) + result == Rational(-125, 27) # Raise zero to an integer power expect - result = Rational 0 1 |> exp(5) - result == Rational 0 1 + result = Rational(0, 1) |> exp(5) + result == Rational(0, 1) # Raise one to an integer power expect - result = Rational 1 1 |> exp(4) - result == Rational 1 1 + result = Rational(1, 1) |> exp(4) + result == Rational(1, 1) # Raise a positive rational number to the power of zero expect - result = Rational 1 2 |> exp(0) - result == Rational 1 1 + result = Rational(1, 2) |> exp(0) + result == Rational(1, 1) # Raise a negative rational number to the power of zero expect - result = Rational -1 2 |> exp(0) - result == Rational 1 1 + result = Rational(-1, 2) |> exp(0) + result == Rational(1, 1) ## ## Exponentiation of a real number to a rational number @@ -195,18 +195,18 @@ expect # Raise a real number to a positive rational number expect - result = 8 |> exp_real(Rational 4 3) - result |> Num.is_approx_eq 16.0f64 {} + result = 8 |> exp_real(Rational(4, 3)) + result |> Num.is_approx_eq(16.0f64, {}) # Raise a real number to a negative rational number expect - result = 9 |> exp_real(Rational -1 2) - result |> Num.is_approx_eq 0.3333333333333333f64 {} + result = 9 |> exp_real(Rational(-1, 2)) + result |> Num.is_approx_eq(0.3333333333333333f64, {}) # Raise a real number to a zero rational number expect - result = 2 |> exp_real(Rational 0 1) - result |> Num.is_approx_eq 1.0f64 {} + result = 2 |> exp_real(Rational(0, 1)) + result |> Num.is_approx_eq(1.0f64, {}) ## ## Reduction to lowest terms @@ -214,36 +214,36 @@ expect # Reduce a positive rational number to lowest terms expect - result = Rational 2 4 |> reduce - result == Rational 1 2 + result = Rational(2, 4) |> reduce + result == Rational(1, 2) # Reduce places the minus sign on the numerator expect - result = Rational 3 -4 |> reduce - result == Rational -3 4 + result = Rational(3, -4) |> reduce + result == Rational(-3, 4) # Reduce a negative rational number to lowest terms expect - result = Rational -4 6 |> reduce - result == Rational -2 3 + result = Rational(-4, 6) |> reduce + result == Rational(-2, 3) # Reduce a rational number with a negative denominator to lowest terms expect - result = Rational 3 -9 |> reduce - result == Rational -1 3 + result = Rational(3, -9) |> reduce + result == Rational(-1, 3) # Reduce zero to lowest terms expect - result = Rational 0 6 |> reduce - result == Rational 0 1 + result = Rational(0, 6) |> reduce + result == Rational(0, 1) # Reduce an integer to lowest terms expect - result = Rational -14 7 |> reduce - result == Rational -2 1 + result = Rational(-14, 7) |> reduce + result == Rational(-2, 1) # Reduce one to lowest terms expect - result = Rational 13 13 |> reduce - result == Rational 1 1 + result = Rational(13, 13) |> reduce + result == Rational(1, 1) From fe75df892fee3bcb9db8dbc2d869fcbca3817cdb Mon Sep 17 00:00:00 2001 From: Anton-4 <17049058+Anton-4@users.noreply.github.com> Date: Sat, 26 Jul 2025 19:41:39 +0200 Subject: [PATCH 7/8] more syntax updates --- .../circular-buffer/.meta/template.j2 | 4 +- .../circular-buffer/circular-buffer-test.roc | 12 +- .../complex-numbers/.meta/template.j2 | 8 +- .../complex-numbers/complex-numbers-test.roc | 134 ++--- .../practice/custom-set/.meta/template.j2 | 2 +- .../practice/custom-set/custom-set-test.roc | 12 +- .../practice/go-counting/.meta/template.j2 | 2 +- .../practice/go-counting/go-counting-test.roc | 12 +- .../practice/queen-attack/.meta/template.j2 | 2 +- .../queen-attack/queen-attack-test.roc | 16 +- exercises/practice/rest-api/.meta/template.j2 | 4 +- exercises/practice/rest-api/rest-api-test.roc | 20 +- .../robot-simulator/.meta/template.j2 | 6 +- .../robot-simulator/robot-simulator-test.roc | 68 +-- .../practice/saddle-points/.meta/template.j2 | 4 +- .../saddle-points/saddle-points-test.roc | 36 +- .../practice/sgf-parsing/.meta/template.j2 | 6 +- .../practice/sgf-parsing/sgf-parsing-test.roc | 458 ++++++++++-------- exercises/practice/strain/.meta/template.j2 | 4 +- exercises/practice/strain/strain-test.roc | 8 +- exercises/practice/triangle/.meta/template.j2 | 2 +- exercises/practice/triangle/triangle-test.roc | 42 +- exercises/practice/two-fer/.meta/template.j2 | 4 +- exercises/practice/two-fer/two-fer-test.roc | 6 +- .../.meta/template.j2 | 2 +- .../variable-length-quantity-test.roc | 46 +- .../practice/word-search/.meta/template.j2 | 2 +- .../practice/word-search/word-search-test.roc | 48 +- 28 files changed, 508 insertions(+), 462 deletions(-) diff --git a/exercises/practice/circular-buffer/.meta/template.j2 b/exercises/practice/circular-buffer/.meta/template.j2 index 0c550d7d..a03dbc83 100644 --- a/exercises/practice/circular-buffer/.meta/template.j2 +++ b/exercises/practice/circular-buffer/.meta/template.j2 @@ -13,13 +13,13 @@ run_operations{{ loop.index }} = |_| {%- if op["operation"] == "clear" %} |> clear {%- elif op["operation"] == "overwrite" %} - |> overwrite {{ op["item"] }} + |> overwrite({{ op["item"] }}) {%- elif op["operation"] == "write" %} {%- if op["should_succeed"] %} |> write({{ op["item"] }})? {%- else %} |> |buffer_before_write| - write_result = buffer_before_write |> write {{ op["item"] }} + write_result = buffer_before_write |> write({{ op["item"] }}) expect write_result == Err(BufferFull) buffer_before_write {%- endif %} diff --git a/exercises/practice/circular-buffer/circular-buffer-test.roc b/exercises/practice/circular-buffer/circular-buffer-test.roc index f6a2fb2f..7dec8d0e 100644 --- a/exercises/practice/circular-buffer/circular-buffer-test.roc +++ b/exercises/practice/circular-buffer/circular-buffer-test.roc @@ -86,7 +86,7 @@ run_operations5 = |_| create({ capacity: 1 }) |> write(1)? |> |buffer_before_write| - write_result = buffer_before_write |> write 2 + write_result = buffer_before_write |> write(2) expect write_result == Err(BufferFull) buffer_before_write Ok(result) @@ -194,7 +194,7 @@ run_operations11 = |_| result = create({ capacity: 2 }) |> write(1)? - |> overwrite 2 + |> overwrite(2) |> read? |> |read_result| expect read_result.value == 1 @@ -215,7 +215,7 @@ run_operations12 = |_| create({ capacity: 2 }) |> write(1)? |> write(2)? - |> overwrite 3 + |> overwrite(3) |> read? |> |read_result| expect read_result.value == 2 @@ -242,7 +242,7 @@ run_operations13 = |_| expect read_result.value == 1 read_result.new_buffer |> write(4)? - |> overwrite 5 + |> overwrite(5) |> read? |> |read_result| expect read_result.value == 3 @@ -268,8 +268,8 @@ run_operations14 = |_| |> clear |> write(1)? |> write(2)? - |> overwrite 3 - |> overwrite 4 + |> overwrite(3) + |> overwrite(4) |> read? |> |read_result| expect read_result.value == 3 diff --git a/exercises/practice/complex-numbers/.meta/template.j2 b/exercises/practice/complex-numbers/.meta/template.j2 index 4b777eed..64464d1e 100644 --- a/exercises/practice/complex-numbers/.meta/template.j2 +++ b/exercises/practice/complex-numbers/.meta/template.j2 @@ -25,10 +25,10 @@ is_approx_eq = |z1, z2| {%- if subcase["input"]["z"] %} expect z = {{ plugins.to_complex_number(subcase["input"]["z"]) }} - result = {{ subcase["property"] }} z + result = {{ subcase["property"] }}(z) {%- if subcase["expected"] is iterable and subcase["expected"] is not string %} expected = {{ plugins.to_complex_number(subcase["expected"]) }} - result |> is_approx_eq expected + result |> is_approx_eq(expected) {%- else %} result |> Num.is_approx_eq({{ subcase["expected"] | to_roc }}, {}) {%- endif %} @@ -36,9 +36,9 @@ expect expect z1 = {{ plugins.to_complex_number(subcase["input"]["z1"]) }} z2 = {{ plugins.to_complex_number(subcase["input"]["z2"]) }} - result = z1 |> {{ subcase["property"] }} z2 + result = z1 |> {{ subcase["property"] }}(z2) expected = {{ plugins.to_complex_number(subcase["expected"]) }} - result |> is_approx_eq expected + result |> is_approx_eq(expected) {%- endif %} {% endfor %} diff --git a/exercises/practice/complex-numbers/complex-numbers-test.roc b/exercises/practice/complex-numbers/complex-numbers-test.roc index 4d4ec898..671a5fa1 100644 --- a/exercises/practice/complex-numbers/complex-numbers-test.roc +++ b/exercises/practice/complex-numbers/complex-numbers-test.roc @@ -22,19 +22,19 @@ is_approx_eq = |z1, z2| # Real part of a purely real number expect z = { re: 1, im: 0 } - result = real z + result = real(z) result |> Num.is_approx_eq(1, {}) # Real part of a purely imaginary number expect z = { re: 0, im: 1 } - result = real z + result = real(z) result |> Num.is_approx_eq(0, {}) # Real part of a number with real and imaginary part expect z = { re: 1, im: 2 } - result = real z + result = real(z) result |> Num.is_approx_eq(1, {}) ### @@ -44,19 +44,19 @@ expect # Imaginary part of a purely real number expect z = { re: 1, im: 0 } - result = imaginary z + result = imaginary(z) result |> Num.is_approx_eq(0, {}) # Imaginary part of a purely imaginary number expect z = { re: 0, im: 1 } - result = imaginary z + result = imaginary(z) result |> Num.is_approx_eq(1, {}) # Imaginary part of a number with real and imaginary part expect z = { re: 1, im: 2 } - result = imaginary z + result = imaginary(z) result |> Num.is_approx_eq(2, {}) ### @@ -73,25 +73,25 @@ expect expect z1 = { re: 1, im: 0 } z2 = { re: 2, im: 0 } - result = z1 |> add z2 + result = z1 |> add(z2) expected = { re: 3, im: 0 } - result |> is_approx_eq expected + result |> is_approx_eq(expected) # Add purely imaginary numbers expect z1 = { re: 0, im: 1 } z2 = { re: 0, im: 2 } - result = z1 |> add z2 + result = z1 |> add(z2) expected = { re: 0, im: 3 } - result |> is_approx_eq expected + result |> is_approx_eq(expected) # Add numbers with real and imaginary part expect z1 = { re: 1, im: 2 } z2 = { re: 3, im: 4 } - result = z1 |> add z2 + result = z1 |> add(z2) expected = { re: 4, im: 6 } - result |> is_approx_eq expected + result |> is_approx_eq(expected) ## Subtraction @@ -99,25 +99,25 @@ expect expect z1 = { re: 1, im: 0 } z2 = { re: 2, im: 0 } - result = z1 |> sub z2 + result = z1 |> sub(z2) expected = { re: -1, im: 0 } - result |> is_approx_eq expected + result |> is_approx_eq(expected) # Subtract purely imaginary numbers expect z1 = { re: 0, im: 1 } z2 = { re: 0, im: 2 } - result = z1 |> sub z2 + result = z1 |> sub(z2) expected = { re: 0, im: -1 } - result |> is_approx_eq expected + result |> is_approx_eq(expected) # Subtract numbers with real and imaginary part expect z1 = { re: 1, im: 2 } z2 = { re: 3, im: 4 } - result = z1 |> sub z2 + result = z1 |> sub(z2) expected = { re: -2, im: -2 } - result |> is_approx_eq expected + result |> is_approx_eq(expected) ## Multiplication @@ -125,25 +125,25 @@ expect expect z1 = { re: 1, im: 0 } z2 = { re: 2, im: 0 } - result = z1 |> mul z2 + result = z1 |> mul(z2) expected = { re: 2, im: 0 } - result |> is_approx_eq expected + result |> is_approx_eq(expected) # Multiply purely imaginary numbers expect z1 = { re: 0, im: 1 } z2 = { re: 0, im: 2 } - result = z1 |> mul z2 + result = z1 |> mul(z2) expected = { re: -2, im: 0 } - result |> is_approx_eq expected + result |> is_approx_eq(expected) # Multiply numbers with real and imaginary part expect z1 = { re: 1, im: 2 } z2 = { re: 3, im: 4 } - result = z1 |> mul z2 + result = z1 |> mul(z2) expected = { re: -5, im: 10 } - result |> is_approx_eq expected + result |> is_approx_eq(expected) ## Division @@ -151,25 +151,25 @@ expect expect z1 = { re: 1, im: 0 } z2 = { re: 2, im: 0 } - result = z1 |> div z2 + result = z1 |> div(z2) expected = { re: 0.5, im: 0 } - result |> is_approx_eq expected + result |> is_approx_eq(expected) # Divide purely imaginary numbers expect z1 = { re: 0, im: 1 } z2 = { re: 0, im: 2 } - result = z1 |> div z2 + result = z1 |> div(z2) expected = { re: 0.5, im: 0 } - result |> is_approx_eq expected + result |> is_approx_eq(expected) # Divide numbers with real and imaginary part expect z1 = { re: 1, im: 2 } z2 = { re: 3, im: 4 } - result = z1 |> div z2 + result = z1 |> div(z2) expected = { re: 0.44, im: 0.08 } - result |> is_approx_eq expected + result |> is_approx_eq(expected) ### ### Absolute value @@ -178,31 +178,31 @@ expect # Absolute value of a positive purely real number expect z = { re: 5, im: 0 } - result = abs z + result = abs(z) result |> Num.is_approx_eq(5, {}) # Absolute value of a negative purely real number expect z = { re: -5, im: 0 } - result = abs z + result = abs(z) result |> Num.is_approx_eq(5, {}) # Absolute value of a purely imaginary number with positive imaginary part expect z = { re: 0, im: 5 } - result = abs z + result = abs(z) result |> Num.is_approx_eq(5, {}) # Absolute value of a purely imaginary number with negative imaginary part expect z = { re: 0, im: -5 } - result = abs z + result = abs(z) result |> Num.is_approx_eq(5, {}) # Absolute value of a number with real and imaginary part expect z = { re: 3, im: 4 } - result = abs z + result = abs(z) result |> Num.is_approx_eq(5, {}) ### @@ -212,23 +212,23 @@ expect # Conjugate a purely real number expect z = { re: 5, im: 0 } - result = conjugate z + result = conjugate(z) expected = { re: 5, im: 0 } - result |> is_approx_eq expected + result |> is_approx_eq(expected) # Conjugate a purely imaginary number expect z = { re: 0, im: 5 } - result = conjugate z + result = conjugate(z) expected = { re: 0, im: -5 } - result |> is_approx_eq expected + result |> is_approx_eq(expected) # Conjugate a number with real and imaginary part expect z = { re: 1, im: 1 } - result = conjugate z + result = conjugate(z) expected = { re: 1, im: -1 } - result |> is_approx_eq expected + result |> is_approx_eq(expected) ### ### Complex exponential function @@ -237,37 +237,37 @@ expect # Euler's identity/formula expect z = { re: 0, im: Num.pi } - result = exp z + result = exp(z) expected = { re: -1, im: 0 } - result |> is_approx_eq expected + result |> is_approx_eq(expected) # Exponential of 0 expect z = { re: 0, im: 0 } - result = exp z + result = exp(z) expected = { re: 1, im: 0 } - result |> is_approx_eq expected + result |> is_approx_eq(expected) # Exponential of a purely real number expect z = { re: 1, im: 0 } - result = exp z + result = exp(z) expected = { re: Num.e, im: 0 } - result |> is_approx_eq expected + result |> is_approx_eq(expected) # Exponential of a number with real and imaginary part expect z = { re: Num.log 2f64, im: Num.pi } - result = exp z + result = exp(z) expected = { re: -2, im: 0 } - result |> is_approx_eq expected + result |> is_approx_eq(expected) # Exponential resulting in a number with real and imaginary part expect z = { re: Num.log 2f64 / 2, im: Num.pi / 4 } - result = exp z + result = exp(z) expected = { re: 1, im: 1 } - result |> is_approx_eq expected + result |> is_approx_eq(expected) ### ### Operations between real numbers and complex numbers @@ -277,63 +277,63 @@ expect expect z1 = { re: 1, im: 2 } z2 = { re: 5, im: 0 } - result = z1 |> add z2 + result = z1 |> add(z2) expected = { re: 6, im: 2 } - result |> is_approx_eq expected + result |> is_approx_eq(expected) # Add complex number to real number expect z1 = { re: 5, im: 0 } z2 = { re: 1, im: 2 } - result = z1 |> add z2 + result = z1 |> add(z2) expected = { re: 6, im: 2 } - result |> is_approx_eq expected + result |> is_approx_eq(expected) # Subtract real number from complex number expect z1 = { re: 5, im: 7 } z2 = { re: 4, im: 0 } - result = z1 |> sub z2 + result = z1 |> sub(z2) expected = { re: 1, im: 7 } - result |> is_approx_eq expected + result |> is_approx_eq(expected) # Subtract complex number from real number expect z1 = { re: 4, im: 0 } z2 = { re: 5, im: 7 } - result = z1 |> sub z2 + result = z1 |> sub(z2) expected = { re: -1, im: -7 } - result |> is_approx_eq expected + result |> is_approx_eq(expected) # Multiply complex number by real number expect z1 = { re: 2, im: 5 } z2 = { re: 5, im: 0 } - result = z1 |> mul z2 + result = z1 |> mul(z2) expected = { re: 10, im: 25 } - result |> is_approx_eq expected + result |> is_approx_eq(expected) # Multiply real number by complex number expect z1 = { re: 5, im: 0 } z2 = { re: 2, im: 5 } - result = z1 |> mul z2 + result = z1 |> mul(z2) expected = { re: 10, im: 25 } - result |> is_approx_eq expected + result |> is_approx_eq(expected) # Divide complex number by real number expect z1 = { re: 10, im: 100 } z2 = { re: 10, im: 0 } - result = z1 |> div z2 + result = z1 |> div(z2) expected = { re: 1, im: 10 } - result |> is_approx_eq expected + result |> is_approx_eq(expected) # Divide real number by complex number expect z1 = { re: 5, im: 0 } z2 = { re: 1, im: 1 } - result = z1 |> div z2 + result = z1 |> div(z2) expected = { re: 2.5, im: -2.5 } - result |> is_approx_eq expected + result |> is_approx_eq(expected) diff --git a/exercises/practice/custom-set/.meta/template.j2 b/exercises/practice/custom-set/.meta/template.j2 index 6826a1a7..e99d682e 100644 --- a/exercises/practice/custom-set/.meta/template.j2 +++ b/exercises/practice/custom-set/.meta/template.j2 @@ -38,7 +38,7 @@ expect {%- if "set" in case["input"] %} set = from_list({{ case["input"]["set"] | to_roc }}) result = set |> {{ property | to_snake }} - {%- if "element" in case["input"] %} {{(case["input"]["element"])}}{%- endif %} + {%- if "element" in case["input"] %}({{(case["input"]["element"])}}){%- endif %} {%- else %} set1 = from_list({{ case["input"]["set1"] | to_roc }}) set2 = from_list({{ case["input"]["set2"] | to_roc }}) diff --git a/exercises/practice/custom-set/custom-set-test.roc b/exercises/practice/custom-set/custom-set-test.roc index 49e3fef5..a494c52c 100644 --- a/exercises/practice/custom-set/custom-set-test.roc +++ b/exercises/practice/custom-set/custom-set-test.roc @@ -52,7 +52,7 @@ expect expect set = from_list([]) - result = set |> contains 1 + result = set |> contains(1) expected = Bool.false result == expected @@ -60,7 +60,7 @@ expect expect set = from_list([1, 2, 3]) - result = set |> contains 1 + result = set |> contains(1) expected = Bool.true result == expected @@ -68,7 +68,7 @@ expect expect set = from_list([1, 2, 3]) - result = set |> contains 4 + result = set |> contains(4) expected = Bool.false result == expected @@ -254,7 +254,7 @@ expect expect set = from_list([]) - result = set |> insert 3 + result = set |> insert(3) expected = [3] |> from_list result |> is_eq(expected) @@ -262,7 +262,7 @@ expect expect set = from_list([1, 2, 4]) - result = set |> insert 3 + result = set |> insert(3) expected = [1, 2, 3, 4] |> from_list result |> is_eq(expected) @@ -270,7 +270,7 @@ expect expect set = from_list([1, 2, 3]) - result = set |> insert 3 + result = set |> insert(3) expected = [1, 2, 3] |> from_list result |> is_eq(expected) diff --git a/exercises/practice/go-counting/.meta/template.j2 b/exercises/practice/go-counting/.meta/template.j2 index 39965f97..5b4444cd 100644 --- a/exercises/practice/go-counting/.meta/template.j2 +++ b/exercises/practice/go-counting/.meta/template.j2 @@ -35,7 +35,7 @@ compare_territories = |maybe_result, maybe_expected| expect board = {{ case["input"]["board"] | to_roc_multiline_string | replace(" ", "·") | indent(8) }} |> Str.replace_each("·", " ") result = board |> {{ case["property"] | to_snake }} - {%- if case["property"] == "territory" %} { x : {{ case["input"]["x"] }}, y : {{ case["input"]["y"] }} }{% endif %} + {%- if case["property"] == "territory" %}({ x : {{ case["input"]["x"] }}, y : {{ case["input"]["y"] }} }){% endif %} {%- if case["expected"]["error"] %} result |> Result.is_err {%- elif case["expected"]["owner"] %} diff --git a/exercises/practice/go-counting/go-counting-test.roc b/exercises/practice/go-counting/go-counting-test.roc index 6abb8aef..b8e9a306 100644 --- a/exercises/practice/go-counting/go-counting-test.roc +++ b/exercises/practice/go-counting/go-counting-test.roc @@ -37,7 +37,7 @@ expect ··W·· """ |> Str.replace_each("·", " ") - result = board |> territory { x: 0, y: 1 } + result = board |> territory({ x: 0, y: 1 }) expected = Ok( { owner: Black, @@ -63,7 +63,7 @@ expect ··W·· """ |> Str.replace_each("·", " ") - result = board |> territory { x: 2, y: 3 } + result = board |> territory({ x: 2, y: 3 }) expected = Ok( { owner: White, @@ -87,7 +87,7 @@ expect ··W·· """ |> Str.replace_each("·", " ") - result = board |> territory { x: 1, y: 4 } + result = board |> territory({ x: 1, y: 4 }) expected = Ok( { owner: None, @@ -113,7 +113,7 @@ expect ··W·· """ |> Str.replace_each("·", " ") - result = board |> territory { x: 1, y: 1 } + result = board |> territory({ x: 1, y: 1 }) expected = Ok( { owner: None, @@ -133,7 +133,7 @@ expect ··W·· """ |> Str.replace_each("·", " ") - result = board |> territory { x: 5, y: 1 } + result = board |> territory({ x: 5, y: 1 }) result |> Result.is_err # Invalid because Y is too high for 5x5 board @@ -147,7 +147,7 @@ expect ··W·· """ |> Str.replace_each("·", " ") - result = board |> territory { x: 1, y: 5 } + result = board |> territory({ x: 1, y: 5 }) result |> Result.is_err # One territory is the whole board diff --git a/exercises/practice/queen-attack/.meta/template.j2 b/exercises/practice/queen-attack/.meta/template.j2 index 1aad003c..34720f73 100644 --- a/exercises/practice/queen-attack/.meta/template.j2 +++ b/exercises/practice/queen-attack/.meta/template.j2 @@ -33,7 +33,7 @@ expect maybe_square2 = create("{{ plugins.to_square(case["input"]["black_queen"]) }}") result = when (maybe_square1, maybe_square2) is (Ok(square1), Ok(square2)) -> - square1 |> queen_can_attack square2 + square1 |> queen_can_attack(square2) _ -> crash "Unreachable: {{ plugins.to_square(case["input"]["white_queen"]) }} and {{ plugins.to_square(case["input"]["black_queen"]) }} are both valid squares" result == {{ case["expected"] | to_roc }} {%- endif %} diff --git a/exercises/practice/queen-attack/queen-attack-test.roc b/exercises/practice/queen-attack/queen-attack-test.roc index 8cf8c8a1..476b1f8b 100644 --- a/exercises/practice/queen-attack/queen-attack-test.roc +++ b/exercises/practice/queen-attack/queen-attack-test.roc @@ -48,7 +48,7 @@ expect result = when (maybe_square1, maybe_square2) is (Ok(square1), Ok(square2)) -> - square1 |> queen_can_attack square2 + square1 |> queen_can_attack(square2) _ -> crash "Unreachable: E6 and G2 are both valid squares" result == Bool.false @@ -60,7 +60,7 @@ expect result = when (maybe_square1, maybe_square2) is (Ok(square1), Ok(square2)) -> - square1 |> queen_can_attack square2 + square1 |> queen_can_attack(square2) _ -> crash "Unreachable: E6 and G6 are both valid squares" result == Bool.true @@ -72,7 +72,7 @@ expect result = when (maybe_square1, maybe_square2) is (Ok(square1), Ok(square2)) -> - square1 |> queen_can_attack square2 + square1 |> queen_can_attack(square2) _ -> crash "Unreachable: F4 and F6 are both valid squares" result == Bool.true @@ -84,7 +84,7 @@ expect result = when (maybe_square1, maybe_square2) is (Ok(square1), Ok(square2)) -> - square1 |> queen_can_attack square2 + square1 |> queen_can_attack(square2) _ -> crash "Unreachable: C6 and E8 are both valid squares" result == Bool.true @@ -96,7 +96,7 @@ expect result = when (maybe_square1, maybe_square2) is (Ok(square1), Ok(square2)) -> - square1 |> queen_can_attack square2 + square1 |> queen_can_attack(square2) _ -> crash "Unreachable: C6 and B5 are both valid squares" result == Bool.true @@ -108,7 +108,7 @@ expect result = when (maybe_square1, maybe_square2) is (Ok(square1), Ok(square2)) -> - square1 |> queen_can_attack square2 + square1 |> queen_can_attack(square2) _ -> crash "Unreachable: C6 and B7 are both valid squares" result == Bool.true @@ -120,7 +120,7 @@ expect result = when (maybe_square1, maybe_square2) is (Ok(square1), Ok(square2)) -> - square1 |> queen_can_attack square2 + square1 |> queen_can_attack(square2) _ -> crash "Unreachable: H7 and G8 are both valid squares" result == Bool.true @@ -132,7 +132,7 @@ expect result = when (maybe_square1, maybe_square2) is (Ok(square1), Ok(square2)) -> - square1 |> queen_can_attack square2 + square1 |> queen_can_attack(square2) _ -> crash "Unreachable: B4 and F6 are both valid squares" result == Bool.false diff --git a/exercises/practice/rest-api/.meta/template.j2 b/exercises/practice/rest-api/.meta/template.j2 index 0c5bc9ea..2a6d44c7 100644 --- a/exercises/practice/rest-api/.meta/template.j2 +++ b/exercises/practice/rest-api/.meta/template.j2 @@ -4,7 +4,7 @@ import {{ exercise | to_pascal }} exposing [get, post] -standardizeResult = |result| +standardize_result = |result| result |> Result.try |string| string |> Str.replace_each(".0,", ",") @@ -46,7 +46,7 @@ expect {%- if case["input"].get("payload", {}) != {} %} payload: {{ case["input"]["payload"] | tojson | to_roc }} {%- endif %} - }) |> standardizeResult + }) |> standardize_result expected = Ok({{ case["expected"] | tojson | replace(".0,", ",") | replace(".0}", "}") | replace(" ", "") | to_roc }}) result == expected diff --git a/exercises/practice/rest-api/rest-api-test.roc b/exercises/practice/rest-api/rest-api-test.roc index 359b80c2..6afeac45 100644 --- a/exercises/practice/rest-api/rest-api-test.roc +++ b/exercises/practice/rest-api/rest-api-test.roc @@ -13,7 +13,7 @@ main! = |_args| import RestApi exposing [get, post] -standardizeResult = |result| +standardize_result = |result| result |> Result.try |string| string @@ -40,7 +40,7 @@ expect url: "/users", }, ) - |> standardizeResult + |> standardize_result expected = Ok("{\"users\":[]}") result == expected @@ -58,7 +58,7 @@ expect payload: "{\"user\": \"Adam\"}", }, ) - |> standardizeResult + |> standardize_result expected = Ok("{\"balance\":0,\"name\":\"Adam\",\"owed_by\":{},\"owes\":{}}") result == expected @@ -88,7 +88,7 @@ expect payload: "{\"users\": [\"Bob\"]}", }, ) - |> standardizeResult + |> standardize_result expected = Ok("{\"users\":[{\"balance\":0,\"name\":\"Bob\",\"owed_by\":{},\"owes\":{}}]}") result == expected @@ -122,7 +122,7 @@ expect payload: "{\"amount\": 3.0, \"borrower\": \"Bob\", \"lender\": \"Adam\"}", }, ) - |> standardizeResult + |> standardize_result expected = Ok("{\"users\":[{\"balance\":3,\"name\":\"Adam\",\"owed_by\":{\"Bob\":3},\"owes\":{}},{\"balance\":-3,\"name\":\"Bob\",\"owed_by\":{},\"owes\":{\"Adam\":3}}]}") result == expected @@ -166,7 +166,7 @@ expect payload: "{\"amount\": 3.0, \"borrower\": \"Bob\", \"lender\": \"Adam\"}", }, ) - |> standardizeResult + |> standardize_result expected = Ok("{\"users\":[{\"balance\":3,\"name\":\"Adam\",\"owed_by\":{\"Bob\":3},\"owes\":{}},{\"balance\":-6,\"name\":\"Bob\",\"owed_by\":{},\"owes\":{\"Adam\":3,\"Chuck\":3}}]}") result == expected @@ -210,7 +210,7 @@ expect payload: "{\"amount\": 3.0, \"borrower\": \"Adam\", \"lender\": \"Bob\"}", }, ) - |> standardizeResult + |> standardize_result expected = Ok("{\"users\":[{\"balance\":-3,\"name\":\"Adam\",\"owed_by\":{},\"owes\":{\"Bob\":3}},{\"balance\":0,\"name\":\"Bob\",\"owed_by\":{\"Adam\":3},\"owes\":{\"Chuck\":3}}]}") result == expected @@ -248,7 +248,7 @@ expect payload: "{\"amount\": 2.0, \"borrower\": \"Bob\", \"lender\": \"Adam\"}", }, ) - |> standardizeResult + |> standardize_result expected = Ok("{\"users\":[{\"balance\":-1,\"name\":\"Adam\",\"owed_by\":{},\"owes\":{\"Bob\":1}},{\"balance\":1,\"name\":\"Bob\",\"owed_by\":{\"Adam\":1},\"owes\":{}}]}") result == expected @@ -286,7 +286,7 @@ expect payload: "{\"amount\": 4.0, \"borrower\": \"Bob\", \"lender\": \"Adam\"}", }, ) - |> standardizeResult + |> standardize_result expected = Ok("{\"users\":[{\"balance\":1,\"name\":\"Adam\",\"owed_by\":{\"Bob\":1},\"owes\":{}},{\"balance\":-1,\"name\":\"Bob\",\"owed_by\":{},\"owes\":{\"Adam\":1}}]}") result == expected @@ -324,7 +324,7 @@ expect payload: "{\"amount\": 3.0, \"borrower\": \"Bob\", \"lender\": \"Adam\"}", }, ) - |> standardizeResult + |> standardize_result expected = Ok("{\"users\":[{\"balance\":0,\"name\":\"Adam\",\"owed_by\":{},\"owes\":{}},{\"balance\":0,\"name\":\"Bob\",\"owed_by\":{},\"owes\":{}}]}") result == expected diff --git a/exercises/practice/robot-simulator/.meta/template.j2 b/exercises/practice/robot-simulator/.meta/template.j2 index 29f2715c..71c11f7b 100644 --- a/exercises/practice/robot-simulator/.meta/template.j2 +++ b/exercises/practice/robot-simulator/.meta/template.j2 @@ -13,10 +13,10 @@ import {{ exercise | to_pascal }} exposing [create, move] # {{ case["description"] }} expect {%- if case["input"]["instructions"] %} - robot = create {{ plugins.to_robot(case["input"], with_defaults=True) }} - result = robot |> move {{ case["input"]["instructions"] | to_roc }} + robot = create({{ plugins.to_robot(case["input"], with_defaults=True) }}) + result = robot |> move({{ case["input"]["instructions"] | to_roc }}) {%- else %} - result = create {{ plugins.to_robot(case["input"], with_defaults=True) }} + result = create({{ plugins.to_robot(case["input"], with_defaults=True) }}) {%- endif %} result == {{ plugins.to_robot(case["expected"], with_defaults=False) }} diff --git a/exercises/practice/robot-simulator/robot-simulator-test.roc b/exercises/practice/robot-simulator/robot-simulator-test.roc index 35235a16..7d7138d7 100644 --- a/exercises/practice/robot-simulator/robot-simulator-test.roc +++ b/exercises/practice/robot-simulator/robot-simulator-test.roc @@ -18,12 +18,12 @@ import RobotSimulator exposing [create, move] # at origin facing north expect - result = create {} + result = create({}) result == { x: 0, y: 0, direction: North } # at negative position facing south expect - result = create { x: -1, y: -1, direction: South } + result = create({ x: -1, y: -1, direction: South }) result == { x: -1, y: -1, direction: South } ## @@ -32,26 +32,26 @@ expect # changes north to east expect - robot = create {} - result = robot |> move "R" + robot = create({}) + result = robot |> move("R") result == { x: 0, y: 0, direction: East } # changes east to south expect - robot = create { direction: East } - result = robot |> move "R" + robot = create({ direction: East }) + result = robot |> move("R") result == { x: 0, y: 0, direction: South } # changes south to west expect - robot = create { direction: South } - result = robot |> move "R" + robot = create({ direction: South }) + result = robot |> move("R") result == { x: 0, y: 0, direction: West } # changes west to north expect - robot = create { direction: West } - result = robot |> move "R" + robot = create({ direction: West }) + result = robot |> move("R") result == { x: 0, y: 0, direction: North } ## @@ -60,26 +60,26 @@ expect # changes north to west expect - robot = create {} - result = robot |> move "L" + robot = create({}) + result = robot |> move("L") result == { x: 0, y: 0, direction: West } # changes west to south expect - robot = create { direction: West } - result = robot |> move "L" + robot = create({ direction: West }) + result = robot |> move("L") result == { x: 0, y: 0, direction: South } # changes south to east expect - robot = create { direction: South } - result = robot |> move "L" + robot = create({ direction: South }) + result = robot |> move("L") result == { x: 0, y: 0, direction: East } # changes east to north expect - robot = create { direction: East } - result = robot |> move "L" + robot = create({ direction: East }) + result = robot |> move("L") result == { x: 0, y: 0, direction: North } ## @@ -88,26 +88,26 @@ expect # facing north increments Y expect - robot = create {} - result = robot |> move "A" + robot = create({}) + result = robot |> move("A") result == { x: 0, y: 1, direction: North } # facing south decrements Y expect - robot = create { direction: South } - result = robot |> move "A" + robot = create({ direction: South }) + result = robot |> move("A") result == { x: 0, y: -1, direction: South } # facing east increments X expect - robot = create { direction: East } - result = robot |> move "A" + robot = create({ direction: East }) + result = robot |> move("A") result == { x: 1, y: 0, direction: East } # facing west decrements X expect - robot = create { direction: West } - result = robot |> move "A" + robot = create({ direction: West }) + result = robot |> move("A") result == { x: -1, y: 0, direction: West } ## @@ -116,25 +116,25 @@ expect # moving east and north from README expect - robot = create { x: 7, y: 3 } - result = robot |> move "RAALAL" + robot = create({ x: 7, y: 3 }) + result = robot |> move("RAALAL") result == { x: 9, y: 4, direction: West } # moving west and north expect - robot = create {} - result = robot |> move "LAAARALA" + robot = create({}) + result = robot |> move("LAAARALA") result == { x: -4, y: 1, direction: West } # moving west and south expect - robot = create { x: 2, y: -7, direction: East } - result = robot |> move "RRAAAAALA" + robot = create({ x: 2, y: -7, direction: East }) + result = robot |> move("RRAAAAALA") result == { x: -3, y: -8, direction: South } # moving east and north expect - robot = create { x: 8, y: 4, direction: South } - result = robot |> move "LAAARRRALLLL" + robot = create({ x: 8, y: 4, direction: South }) + result = robot |> move("LAAARRRALLLL") result == { x: 11, y: 5, direction: North } diff --git a/exercises/practice/saddle-points/.meta/template.j2 b/exercises/practice/saddle-points/.meta/template.j2 index 05478de4..f8b9d3ad 100644 --- a/exercises/practice/saddle-points/.meta/template.j2 +++ b/exercises/practice/saddle-points/.meta/template.j2 @@ -7,12 +7,12 @@ import {{ exercise | to_pascal }} exposing [{{ cases[0]["property"] | to_snake } {% for case in cases -%} # {{ case["description"] }} expect - treeHeights = [ + tree_heights = [ {%- for row in case["input"]["matrix"] %} {{ row | to_roc }}, {%- endfor %} ] - result = treeHeights |> {{ case["property"] | to_snake }} + result = tree_heights |> {{ case["property"] | to_snake }} expected = Set.from_list([ {%- for tree in case["expected"] %} {{ tree | to_roc }}, diff --git a/exercises/practice/saddle-points/saddle-points-test.roc b/exercises/practice/saddle-points/saddle-points-test.roc index 488d4cf6..a9f2ddc3 100644 --- a/exercises/practice/saddle-points/saddle-points-test.roc +++ b/exercises/practice/saddle-points/saddle-points-test.roc @@ -14,12 +14,12 @@ import SaddlePoints exposing [saddle_points] # Can identify single saddle point expect - treeHeights = [ + tree_heights = [ [9, 8, 7], [5, 3, 2], [6, 6, 7], ] - result = treeHeights |> saddle_points + result = tree_heights |> saddle_points expected = Set.from_list( [ { row: 2, column: 1 }, @@ -29,10 +29,10 @@ expect # Can identify that empty matrix has no saddle points expect - treeHeights = [ + tree_heights = [ [], ] - result = treeHeights |> saddle_points + result = tree_heights |> saddle_points expected = Set.from_list( [ ], @@ -41,12 +41,12 @@ expect # Can identify lack of saddle points when there are none expect - treeHeights = [ + tree_heights = [ [1, 2, 3], [3, 1, 2], [2, 3, 1], ] - result = treeHeights |> saddle_points + result = tree_heights |> saddle_points expected = Set.from_list( [ ], @@ -55,12 +55,12 @@ expect # Can identify multiple saddle points in a column expect - treeHeights = [ + tree_heights = [ [4, 5, 4], [3, 5, 5], [1, 5, 4], ] - result = treeHeights |> saddle_points + result = tree_heights |> saddle_points expected = Set.from_list( [ { row: 1, column: 2 }, @@ -72,12 +72,12 @@ expect # Can identify multiple saddle points in a row expect - treeHeights = [ + tree_heights = [ [6, 7, 8], [5, 5, 5], [7, 5, 6], ] - result = treeHeights |> saddle_points + result = tree_heights |> saddle_points expected = Set.from_list( [ { row: 2, column: 1 }, @@ -89,12 +89,12 @@ expect # Can identify saddle point in bottom right corner expect - treeHeights = [ + tree_heights = [ [8, 7, 9], [6, 7, 6], [3, 2, 5], ] - result = treeHeights |> saddle_points + result = tree_heights |> saddle_points expected = Set.from_list( [ { row: 3, column: 3 }, @@ -104,11 +104,11 @@ expect # Can identify saddle points in a non square matrix expect - treeHeights = [ + tree_heights = [ [3, 1, 3], [3, 2, 4], ] - result = treeHeights |> saddle_points + result = tree_heights |> saddle_points expected = Set.from_list( [ { row: 1, column: 3 }, @@ -119,13 +119,13 @@ expect # Can identify that saddle points in a single column matrix are those with the minimum value expect - treeHeights = [ + tree_heights = [ [2], [1], [4], [1], ] - result = treeHeights |> saddle_points + result = tree_heights |> saddle_points expected = Set.from_list( [ { row: 2, column: 1 }, @@ -136,10 +136,10 @@ expect # Can identify that saddle points in a single row matrix are those with the maximum value expect - treeHeights = [ + tree_heights = [ [2, 5, 3, 5], ] - result = treeHeights |> saddle_points + result = tree_heights |> saddle_points expected = Set.from_list( [ { row: 1, column: 2 }, diff --git a/exercises/practice/sgf-parsing/.meta/template.j2 b/exercises/practice/sgf-parsing/.meta/template.j2 index ffc16594..3f4e160d 100644 --- a/exercises/practice/sgf-parsing/.meta/template.j2 +++ b/exercises/practice/sgf-parsing/.meta/template.j2 @@ -5,7 +5,7 @@ import {{ exercise | to_pascal }} exposing [{{ cases[0]["property"] | to_snake }}] {%- macro to_node(node) %} -GameNode { +GameNode({ properties: Dict.from_list([ {%- for name, values in node["properties"].items() %} ({{ name | to_roc }}, {{ values | to_roc }}), @@ -14,7 +14,7 @@ GameNode { {%- for child_node in node["children"] %} {{ to_node(child_node) }}, {%- endfor %}], -} +}) {%- endmacro %} @@ -22,7 +22,7 @@ GameNode { # {{ case["description"] }} expect sgf = {{ case["input"]["encoded"] | to_roc }} - result = {{ case["property"] | to_snake }} sgf + result = {{ case["property"] | to_snake }}(sgf) {%- if case["expected"]["error"] %} result |> Result.is_err {%- else %} diff --git a/exercises/practice/sgf-parsing/sgf-parsing-test.roc b/exercises/practice/sgf-parsing/sgf-parsing-test.roc index d156ca52..3f286558 100644 --- a/exercises/practice/sgf-parsing/sgf-parsing-test.roc +++ b/exercises/practice/sgf-parsing/sgf-parsing-test.roc @@ -16,344 +16,390 @@ import SgfParsing exposing [parse] # empty input expect sgf = "" - result = parse sgf + result = parse(sgf) result |> Result.is_err # tree with no nodes expect sgf = "()" - result = parse sgf + result = parse(sgf) result |> Result.is_err # node without tree expect sgf = ";" - result = parse sgf + result = parse(sgf) result |> Result.is_err # node without properties expect sgf = "(;)" - result = parse sgf + result = parse(sgf) expected = - GameNode { - properties: Dict.from_list([]), - children: [], - } + GameNode( + { + properties: Dict.from_list([]), + children: [], + }, + ) result == Ok(expected) # single node tree expect sgf = "(;A[B])" - result = parse sgf + result = parse(sgf) expected = - GameNode { - properties: Dict.from_list( - [ - ("A", ["B"]), - ], - ), - children: [], - } + GameNode( + { + properties: Dict.from_list( + [ + ("A", ["B"]), + ], + ), + children: [], + }, + ) result == Ok(expected) # multiple properties expect sgf = "(;A[b]C[d])" - result = parse sgf + result = parse(sgf) expected = - GameNode { - properties: Dict.from_list( - [ - ("A", ["b"]), - ("C", ["d"]), - ], - ), - children: [], - } + GameNode( + { + properties: Dict.from_list( + [ + ("A", ["b"]), + ("C", ["d"]), + ], + ), + children: [], + }, + ) result == Ok(expected) # properties without delimiter expect sgf = "(;A)" - result = parse sgf + result = parse(sgf) result |> Result.is_err # all lowercase property expect sgf = "(;a[b])" - result = parse sgf + result = parse(sgf) result |> Result.is_err # upper and lowercase property expect sgf = "(;Aa[b])" - result = parse sgf + result = parse(sgf) result |> Result.is_err # two nodes expect sgf = "(;A[B];B[C])" - result = parse sgf + result = parse(sgf) expected = - GameNode { - properties: Dict.from_list( - [ - ("A", ["B"]), - ], - ), - children: [ - GameNode { - properties: Dict.from_list( - [ - ("B", ["C"]), - ], + GameNode( + { + properties: Dict.from_list( + [ + ("A", ["B"]), + ], + ), + children: [ + GameNode( + { + properties: Dict.from_list( + [ + ("B", ["C"]), + ], + ), + children: [], + }, ), - children: [], - }, - ], - } + ], + }, + ) result == Ok(expected) # two child trees expect sgf = "(;A[B](;B[C])(;C[D]))" - result = parse sgf + result = parse(sgf) expected = - GameNode { - properties: Dict.from_list( - [ - ("A", ["B"]), - ], - ), - children: [ - GameNode { - properties: Dict.from_list( - [ - ("B", ["C"]), - ], + GameNode( + { + properties: Dict.from_list( + [ + ("A", ["B"]), + ], + ), + children: [ + GameNode( + { + properties: Dict.from_list( + [ + ("B", ["C"]), + ], + ), + children: [], + }, ), - children: [], - }, - GameNode { - properties: Dict.from_list( - [ - ("C", ["D"]), - ], + GameNode( + { + properties: Dict.from_list( + [ + ("C", ["D"]), + ], + ), + children: [], + }, ), - children: [], - }, - ], - } + ], + }, + ) result == Ok(expected) # multiple property values expect sgf = "(;A[b][c][d])" - result = parse sgf + result = parse(sgf) expected = - GameNode { - properties: Dict.from_list( - [ - ("A", ["b", "c", "d"]), - ], - ), - children: [], - } + GameNode( + { + properties: Dict.from_list( + [ + ("A", ["b", "c", "d"]), + ], + ), + children: [], + }, + ) result == Ok(expected) # within property values, whitespace characters such as tab are converted to spaces expect sgf = "(;A[hello\t\tworld])" - result = parse sgf + result = parse(sgf) expected = - GameNode { - properties: Dict.from_list( - [ - ("A", ["hello world"]), - ], - ), - children: [], - } + GameNode( + { + properties: Dict.from_list( + [ + ("A", ["hello world"]), + ], + ), + children: [], + }, + ) result == Ok(expected) # within property values, newlines remain as newlines expect sgf = "(;A[hello\n\nworld])" - result = parse sgf + result = parse(sgf) expected = - GameNode { - properties: Dict.from_list( - [ - ("A", ["hello\n\nworld"]), - ], - ), - children: [], - } + GameNode( + { + properties: Dict.from_list( + [ + ("A", ["hello\n\nworld"]), + ], + ), + children: [], + }, + ) result == Ok(expected) # escaped closing bracket within property value becomes just a closing bracket expect sgf = "(;A[\\]])" - result = parse sgf + result = parse(sgf) expected = - GameNode { - properties: Dict.from_list( - [ - ("A", ["]"]), - ], - ), - children: [], - } + GameNode( + { + properties: Dict.from_list( + [ + ("A", ["]"]), + ], + ), + children: [], + }, + ) result == Ok(expected) # escaped backslash in property value becomes just a backslash expect sgf = "(;A[\\\\])" - result = parse sgf + result = parse(sgf) expected = - GameNode { - properties: Dict.from_list( - [ - ("A", ["\\"]), - ], - ), - children: [], - } + GameNode( + { + properties: Dict.from_list( + [ + ("A", ["\\"]), + ], + ), + children: [], + }, + ) result == Ok(expected) # opening bracket within property value doesn't need to be escaped expect sgf = "(;A[x[y\\]z][foo]B[bar];C[baz])" - result = parse sgf + result = parse(sgf) expected = - GameNode { - properties: Dict.from_list( - [ - ("A", ["x[y]z", "foo"]), - ("B", ["bar"]), - ], - ), - children: [ - GameNode { - properties: Dict.from_list( - [ - ("C", ["baz"]), - ], + GameNode( + { + properties: Dict.from_list( + [ + ("A", ["x[y]z", "foo"]), + ("B", ["bar"]), + ], + ), + children: [ + GameNode( + { + properties: Dict.from_list( + [ + ("C", ["baz"]), + ], + ), + children: [], + }, ), - children: [], - }, - ], - } + ], + }, + ) result == Ok(expected) # semicolon in property value doesn't need to be escaped expect sgf = "(;A[a;b][foo]B[bar];C[baz])" - result = parse sgf + result = parse(sgf) expected = - GameNode { - properties: Dict.from_list( - [ - ("A", ["a;b", "foo"]), - ("B", ["bar"]), - ], - ), - children: [ - GameNode { - properties: Dict.from_list( - [ - ("C", ["baz"]), - ], + GameNode( + { + properties: Dict.from_list( + [ + ("A", ["a;b", "foo"]), + ("B", ["bar"]), + ], + ), + children: [ + GameNode( + { + properties: Dict.from_list( + [ + ("C", ["baz"]), + ], + ), + children: [], + }, ), - children: [], - }, - ], - } + ], + }, + ) result == Ok(expected) # parentheses in property value don't need to be escaped expect sgf = "(;A[x(y)z][foo]B[bar];C[baz])" - result = parse sgf + result = parse(sgf) expected = - GameNode { - properties: Dict.from_list( - [ - ("A", ["x(y)z", "foo"]), - ("B", ["bar"]), - ], - ), - children: [ - GameNode { - properties: Dict.from_list( - [ - ("C", ["baz"]), - ], + GameNode( + { + properties: Dict.from_list( + [ + ("A", ["x(y)z", "foo"]), + ("B", ["bar"]), + ], + ), + children: [ + GameNode( + { + properties: Dict.from_list( + [ + ("C", ["baz"]), + ], + ), + children: [], + }, ), - children: [], - }, - ], - } + ], + }, + ) result == Ok(expected) # escaped tab in property value is converted to space expect sgf = "(;A[hello\\\tworld])" - result = parse sgf + result = parse(sgf) expected = - GameNode { - properties: Dict.from_list( - [ - ("A", ["hello world"]), - ], - ), - children: [], - } + GameNode( + { + properties: Dict.from_list( + [ + ("A", ["hello world"]), + ], + ), + children: [], + }, + ) result == Ok(expected) # escaped newline in property value is converted to nothing at all expect sgf = "(;A[hello\\\nworld])" - result = parse sgf + result = parse(sgf) expected = - GameNode { - properties: Dict.from_list( - [ - ("A", ["helloworld"]), - ], - ), - children: [], - } + GameNode( + { + properties: Dict.from_list( + [ + ("A", ["helloworld"]), + ], + ), + children: [], + }, + ) result == Ok(expected) # escaped t and n in property value are just letters, not whitespace expect sgf = "(;A[\\t = t and \\n = n])" - result = parse sgf + result = parse(sgf) expected = - GameNode { - properties: Dict.from_list( - [ - ("A", ["t = t and n = n"]), - ], - ), - children: [], - } + GameNode( + { + properties: Dict.from_list( + [ + ("A", ["t = t and n = n"]), + ], + ), + children: [], + }, + ) result == Ok(expected) # mixing various kinds of whitespace and escaped characters in property value expect sgf = "(;A[\\]b\nc\\\nd\t\te\\\\ \\\n\\]])" - result = parse sgf + result = parse(sgf) expected = - GameNode { - properties: Dict.from_list( - [ - ("A", ["]b\ncd e\\ ]"]), - ], - ), - children: [], - } + GameNode( + { + properties: Dict.from_list( + [ + ("A", ["]b\ncd e\\ ]"]), + ], + ), + children: [], + }, + ) result == Ok(expected) diff --git a/exercises/practice/strain/.meta/template.j2 b/exercises/practice/strain/.meta/template.j2 index 36aab54f..4635e345 100644 --- a/exercises/practice/strain/.meta/template.j2 +++ b/exercises/practice/strain/.meta/template.j2 @@ -5,9 +5,9 @@ import {{ exercise | to_pascal }} exposing [keep, discard] {% set function_map = { - "fn(x) -> contains(x, 5)": "\\x -> x |> List.contains 5", + "fn(x) -> contains(x, 5)": "|x| x |> List.contains(5)", "fn(x) -> false": "\\_ -> Bool.false", - "fn(x) -> starts_with(x, 'z')": "\\x -> x |> Str.starts_with \"z\"", + "fn(x) -> starts_with(x, 'z')": "|x| x |> Str.starts_with(\"z\")", "fn(x) -> true": "\\_ -> Bool.true", "fn(x) -> x % 2 == 0": "\\x -> x % 2 == 0", "fn(x) -> x % 2 == 1": "\\x -> x % 2 == 1", diff --git a/exercises/practice/strain/strain-test.roc b/exercises/practice/strain/strain-test.roc index a075345a..6d8483de 100644 --- a/exercises/practice/strain/strain-test.roc +++ b/exercises/practice/strain/strain-test.roc @@ -50,14 +50,14 @@ expect # keeps strings expect list = ["apple", "zebra", "banana", "zombies", "cherimoya", "zealot"] - result = list |> keep(|x| x |> Str.starts_with "z") + result = list |> keep(|x| x |> Str.starts_with("z")) expected = ["zebra", "zombies", "zealot"] result == expected # keeps lists expect list = [[1, 2, 3], [5, 5, 5], [5, 1, 2], [2, 1, 2], [1, 5, 2], [2, 2, 1], [1, 2, 5]] - result = list |> keep(|x| x |> List.contains 5) + result = list |> keep(|x| x |> List.contains(5)) expected = [[5, 5, 5], [5, 1, 2], [1, 5, 2], [1, 2, 5]] result == expected @@ -99,14 +99,14 @@ expect # discards strings expect list = ["apple", "zebra", "banana", "zombies", "cherimoya", "zealot"] - result = list |> discard(|x| x |> Str.starts_with "z") + result = list |> discard(|x| x |> Str.starts_with("z")) expected = ["apple", "banana", "cherimoya"] result == expected # discards lists expect list = [[1, 2, 3], [5, 5, 5], [5, 1, 2], [2, 1, 2], [1, 5, 2], [2, 2, 1], [1, 2, 5]] - result = list |> discard(|x| x |> List.contains 5) + result = list |> discard(|x| x |> List.contains(5)) expected = [[1, 2, 3], [2, 1, 2], [2, 2, 1]] result == expected diff --git a/exercises/practice/triangle/.meta/template.j2 b/exercises/practice/triangle/.meta/template.j2 index 539bb233..d32731f6 100644 --- a/exercises/practice/triangle/.meta/template.j2 +++ b/exercises/practice/triangle/.meta/template.j2 @@ -12,7 +12,7 @@ import {{ exercise | to_pascal }} exposing [is_equilateral, is_isosceles, is_sca {% for case in supercase["cases"] -%} # {{ case["description"] }} expect - result = is_{{ case["property"] }} {{ case["input"]["sides"] | to_roc_tuple }} + result = is_{{ case["property"] }}({{ case["input"]["sides"] | to_roc_tuple }}) result == {{ case["expected"] | to_roc }} {% endfor %} diff --git a/exercises/practice/triangle/triangle-test.roc b/exercises/practice/triangle/triangle-test.roc index 527c8d9e..64173744 100644 --- a/exercises/practice/triangle/triangle-test.roc +++ b/exercises/practice/triangle/triangle-test.roc @@ -18,27 +18,27 @@ import Triangle exposing [is_equilateral, is_isosceles, is_scalene] # all sides are equal expect - result = is_equilateral (2, 2, 2) + result = is_equilateral((2, 2, 2)) result == Bool.true # any side is unequal expect - result = is_equilateral (2, 3, 2) + result = is_equilateral((2, 3, 2)) result == Bool.false # no sides are equal expect - result = is_equilateral (5, 4, 6) + result = is_equilateral((5, 4, 6)) result == Bool.false # all zero sides is not a triangle expect - result = is_equilateral (0, 0, 0) + result = is_equilateral((0, 0, 0)) result == Bool.false # sides may be floats expect - result = is_equilateral (0.5f64, 0.5f64, 0.5f64) + result = is_equilateral((0.5f64, 0.5f64, 0.5f64)) result == Bool.true ## @@ -47,47 +47,47 @@ expect # last two sides are equal expect - result = is_isosceles (3, 4, 4) + result = is_isosceles((3, 4, 4)) result == Bool.true # first two sides are equal expect - result = is_isosceles (4, 4, 3) + result = is_isosceles((4, 4, 3)) result == Bool.true # first and last sides are equal expect - result = is_isosceles (4, 3, 4) + result = is_isosceles((4, 3, 4)) result == Bool.true # equilateral triangles are also isosceles expect - result = is_isosceles (4, 4, 4) + result = is_isosceles((4, 4, 4)) result == Bool.true # no sides are equal expect - result = is_isosceles (2, 3, 4) + result = is_isosceles((2, 3, 4)) result == Bool.false # first triangle inequality violation expect - result = is_isosceles (1, 1, 3) + result = is_isosceles((1, 1, 3)) result == Bool.false # second triangle inequality violation expect - result = is_isosceles (1, 3, 1) + result = is_isosceles((1, 3, 1)) result == Bool.false # third triangle inequality violation expect - result = is_isosceles (3, 1, 1) + result = is_isosceles((3, 1, 1)) result == Bool.false # sides may be floats expect - result = is_isosceles (0.5f64, 0.4f64, 0.5f64) + result = is_isosceles((0.5f64, 0.4f64, 0.5f64)) result == Bool.true ## @@ -96,36 +96,36 @@ expect # no sides are equal expect - result = is_scalene (5, 4, 6) + result = is_scalene((5, 4, 6)) result == Bool.true # all sides are equal expect - result = is_scalene (4, 4, 4) + result = is_scalene((4, 4, 4)) result == Bool.false # first and second sides are equal expect - result = is_scalene (4, 4, 3) + result = is_scalene((4, 4, 3)) result == Bool.false # first and third sides are equal expect - result = is_scalene (3, 4, 3) + result = is_scalene((3, 4, 3)) result == Bool.false # second and third sides are equal expect - result = is_scalene (4, 3, 3) + result = is_scalene((4, 3, 3)) result == Bool.false # may not violate triangle inequality expect - result = is_scalene (7, 3, 2) + result = is_scalene((7, 3, 2)) result == Bool.false # sides may be floats expect - result = is_scalene (0.5f64, 0.4f64, 0.6f64) + result = is_scalene((0.5f64, 0.4f64, 0.6f64)) result == Bool.true diff --git a/exercises/practice/two-fer/.meta/template.j2 b/exercises/practice/two-fer/.meta/template.j2 index fc892b19..e1673c82 100644 --- a/exercises/practice/two-fer/.meta/template.j2 +++ b/exercises/practice/two-fer/.meta/template.j2 @@ -8,9 +8,9 @@ import {{ exercise | to_pascal }} exposing [{{ exercise | to_snake }}] # {{ case["description"] }} expect {%- if case["input"]["name"] == None %} - result = {{ case["property"] | to_snake }} Anonymous + result = {{ case["property"] | to_snake }}(Anonymous) {%- else %} - result = {{ case["property"] | to_snake }}((Name {{ case["input"]["name"] | to_roc }})) + result = {{ case["property"] | to_snake }}((Name({{ case["input"]["name"] | to_roc }}))) {%- endif %} result == {{ case["expected"] | to_roc }} diff --git a/exercises/practice/two-fer/two-fer-test.roc b/exercises/practice/two-fer/two-fer-test.roc index ccc9b29b..03d1d49b 100644 --- a/exercises/practice/two-fer/two-fer-test.roc +++ b/exercises/practice/two-fer/two-fer-test.roc @@ -14,16 +14,16 @@ import TwoFer exposing [two_fer] # no name given expect - result = two_fer Anonymous + result = two_fer(Anonymous) result == "One for you, one for me." # a name given expect - result = two_fer(Name "Alice") + result = two_fer(Name("Alice")) result == "One for Alice, one for me." # another name given expect - result = two_fer(Name "Bob") + result = two_fer(Name("Bob")) result == "One for Bob, one for me." diff --git a/exercises/practice/variable-length-quantity/.meta/template.j2 b/exercises/practice/variable-length-quantity/.meta/template.j2 index e0965421..98023e7d 100644 --- a/exercises/practice/variable-length-quantity/.meta/template.j2 +++ b/exercises/practice/variable-length-quantity/.meta/template.j2 @@ -14,7 +14,7 @@ import {{ exercise | to_pascal }} exposing [encode, decode] {%- if case["property"] == "encode" %} expect integers = {{ case["input"]["integers"] | to_roc }} - result = encode integers + result = encode(integers) expected = {{ case["expected"] | to_roc }} result == expected {%- else %} diff --git a/exercises/practice/variable-length-quantity/variable-length-quantity-test.roc b/exercises/practice/variable-length-quantity/variable-length-quantity-test.roc index c6af1750..2afff9b2 100644 --- a/exercises/practice/variable-length-quantity/variable-length-quantity-test.roc +++ b/exercises/practice/variable-length-quantity/variable-length-quantity-test.roc @@ -19,161 +19,161 @@ import VariableLengthQuantity exposing [encode, decode] # zero expect integers = [0] - result = encode integers + result = encode(integers) expected = [0] result == expected # arbitrary single byte expect integers = [64] - result = encode integers + result = encode(integers) expected = [64] result == expected # asymmetric single byte expect integers = [83] - result = encode integers + result = encode(integers) expected = [83] result == expected # largest single byte expect integers = [127] - result = encode integers + result = encode(integers) expected = [127] result == expected # smallest double byte expect integers = [128] - result = encode integers + result = encode(integers) expected = [129, 0] result == expected # arbitrary double byte expect integers = [8192] - result = encode integers + result = encode(integers) expected = [192, 0] result == expected # asymmetric double byte expect integers = [173] - result = encode integers + result = encode(integers) expected = [129, 45] result == expected # largest double byte expect integers = [16383] - result = encode integers + result = encode(integers) expected = [255, 127] result == expected # smallest triple byte expect integers = [16384] - result = encode integers + result = encode(integers) expected = [129, 128, 0] result == expected # arbitrary triple byte expect integers = [1048576] - result = encode integers + result = encode(integers) expected = [192, 128, 0] result == expected # asymmetric triple byte expect integers = [120220] - result = encode integers + result = encode(integers) expected = [135, 171, 28] result == expected # largest triple byte expect integers = [2097151] - result = encode integers + result = encode(integers) expected = [255, 255, 127] result == expected # smallest quadruple byte expect integers = [2097152] - result = encode integers + result = encode(integers) expected = [129, 128, 128, 0] result == expected # arbitrary quadruple byte expect integers = [134217728] - result = encode integers + result = encode(integers) expected = [192, 128, 128, 0] result == expected # asymmetric quadruple byte expect integers = [3503876] - result = encode integers + result = encode(integers) expected = [129, 213, 238, 4] result == expected # largest quadruple byte expect integers = [268435455] - result = encode integers + result = encode(integers) expected = [255, 255, 255, 127] result == expected # smallest quintuple byte expect integers = [268435456] - result = encode integers + result = encode(integers) expected = [129, 128, 128, 128, 0] result == expected # arbitrary quintuple byte expect integers = [4278190080] - result = encode integers + result = encode(integers) expected = [143, 248, 128, 128, 0] result == expected # asymmetric quintuple byte expect integers = [2254790917] - result = encode integers + result = encode(integers) expected = [136, 179, 149, 194, 5] result == expected # maximum 32-bit integer input expect integers = [4294967295] - result = encode integers + result = encode(integers) expected = [143, 255, 255, 255, 127] result == expected # two single-byte values expect integers = [64, 127] - result = encode integers + result = encode(integers) expected = [64, 127] result == expected # two multi-byte values expect integers = [16384, 1193046] - result = encode integers + result = encode(integers) expected = [129, 128, 0, 200, 232, 86] result == expected # many multi-byte values expect integers = [8192, 1193046, 268435455, 0, 16383, 16384] - result = encode integers + result = encode(integers) expected = [192, 0, 200, 232, 86, 255, 255, 255, 127, 0, 255, 127, 129, 128, 0] result == expected diff --git a/exercises/practice/word-search/.meta/template.j2 b/exercises/practice/word-search/.meta/template.j2 index 7701506c..40fcd147 100644 --- a/exercises/practice/word-search/.meta/template.j2 +++ b/exercises/practice/word-search/.meta/template.j2 @@ -9,7 +9,7 @@ import {{ exercise | to_pascal }} exposing [{{ cases[0]["property"] | to_snake } expect grid = {{ case["input"]["grid"] | to_roc_multiline_string | indent(8) }} words_to_search_for = {{ case["input"]["wordsToSearchFor"] | to_roc }} - result = grid |> {{ case["property"] | to_snake }} words_to_search_for + result = grid |> {{ case["property"] | to_snake }}(words_to_search_for) expected = Dict.from_list([ {%- for word, result in case["expected"].items() %} {%- if result is none %} diff --git a/exercises/practice/word-search/word-search-test.roc b/exercises/practice/word-search/word-search-test.roc index d5790acc..6480ab66 100644 --- a/exercises/practice/word-search/word-search-test.roc +++ b/exercises/practice/word-search/word-search-test.roc @@ -16,7 +16,7 @@ import WordSearch exposing [search] expect grid = "jefblpepre" words_to_search_for = ["clojure"] - result = grid |> search words_to_search_for + result = grid |> search(words_to_search_for) expected = Dict.from_list( [ # "clojure" is not in the grid @@ -28,7 +28,7 @@ expect expect grid = "clojurermt" words_to_search_for = ["clojure"] - result = grid |> search words_to_search_for + result = grid |> search(words_to_search_for) expected = Dict.from_list( [ ("clojure", { start: { column: 1, row: 1 }, end: { column: 7, row: 1 } }), @@ -40,7 +40,7 @@ expect expect grid = "mtclojurer" words_to_search_for = ["clojure"] - result = grid |> search words_to_search_for + result = grid |> search(words_to_search_for) expected = Dict.from_list( [ ("clojure", { start: { column: 3, row: 1 }, end: { column: 9, row: 1 } }), @@ -52,7 +52,7 @@ expect expect grid = "coffeelplx" words_to_search_for = ["coffee"] - result = grid |> search words_to_search_for + result = grid |> search(words_to_search_for) expected = Dict.from_list( [ ("coffee", { start: { column: 1, row: 1 }, end: { column: 6, row: 1 } }), @@ -64,7 +64,7 @@ expect expect grid = "xcoffeezlp" words_to_search_for = ["coffee"] - result = grid |> search words_to_search_for + result = grid |> search(words_to_search_for) expected = Dict.from_list( [ ("coffee", { start: { column: 2, row: 1 }, end: { column: 7, row: 1 } }), @@ -80,7 +80,7 @@ expect tclojurerm """ words_to_search_for = ["clojure"] - result = grid |> search words_to_search_for + result = grid |> search(words_to_search_for) expected = Dict.from_list( [ ("clojure", { start: { column: 2, row: 2 }, end: { column: 8, row: 2 } }), @@ -97,7 +97,7 @@ expect clojurermt """ words_to_search_for = ["clojure"] - result = grid |> search words_to_search_for + result = grid |> search(words_to_search_for) expected = Dict.from_list( [ ("clojure", { start: { column: 1, row: 3 }, end: { column: 7, row: 3 } }), @@ -121,7 +121,7 @@ expect clojurermt """ words_to_search_for = ["clojure"] - result = grid |> search words_to_search_for + result = grid |> search(words_to_search_for) expected = Dict.from_list( [ ("clojure", { start: { column: 1, row: 10 }, end: { column: 7, row: 10 } }), @@ -145,7 +145,7 @@ expect jalaycalmp """ words_to_search_for = ["clojure"] - result = grid |> search words_to_search_for + result = grid |> search(words_to_search_for) expected = Dict.from_list( [ ("clojure", { start: { column: 1, row: 9 }, end: { column: 7, row: 9 } }), @@ -169,7 +169,7 @@ expect jalaycalmp """ words_to_search_for = ["fortran"] - result = grid |> search words_to_search_for + result = grid |> search(words_to_search_for) expected = Dict.from_list( [ ("fortran", { start: { column: 1, row: 7 }, end: { column: 7, row: 7 } }), @@ -193,7 +193,7 @@ expect clojurermt """ words_to_search_for = ["fortran", "clojure"] - result = grid |> search words_to_search_for + result = grid |> search(words_to_search_for) expected = Dict.from_list( [ ("clojure", { start: { column: 1, row: 10 }, end: { column: 7, row: 10 } }), @@ -206,7 +206,7 @@ expect expect grid = "rixilelhrs" words_to_search_for = ["elixir"] - result = grid |> search words_to_search_for + result = grid |> search(words_to_search_for) expected = Dict.from_list( [ ("elixir", { start: { column: 6, row: 1 }, end: { column: 1, row: 1 } }), @@ -230,7 +230,7 @@ expect clojurermt """ words_to_search_for = ["elixir", "clojure"] - result = grid |> search words_to_search_for + result = grid |> search(words_to_search_for) expected = Dict.from_list( [ ("clojure", { start: { column: 1, row: 10 }, end: { column: 7, row: 10 } }), @@ -255,7 +255,7 @@ expect clojurermt """ words_to_search_for = ["clojure", "elixir", "ecmascript"] - result = grid |> search words_to_search_for + result = grid |> search(words_to_search_for) expected = Dict.from_list( [ ("clojure", { start: { column: 1, row: 10 }, end: { column: 7, row: 10 } }), @@ -281,7 +281,7 @@ expect clojurermt """ words_to_search_for = ["clojure", "elixir", "ecmascript", "rust"] - result = grid |> search words_to_search_for + result = grid |> search(words_to_search_for) expected = Dict.from_list( [ ("clojure", { start: { column: 1, row: 10 }, end: { column: 7, row: 10 } }), @@ -308,7 +308,7 @@ expect clojurermt """ words_to_search_for = ["clojure", "elixir", "ecmascript", "rust", "java"] - result = grid |> search words_to_search_for + result = grid |> search(words_to_search_for) expected = Dict.from_list( [ ("clojure", { start: { column: 1, row: 10 }, end: { column: 7, row: 10 } }), @@ -336,7 +336,7 @@ expect clojurermt """ words_to_search_for = ["clojure", "elixir", "ecmascript", "rust", "java", "lua"] - result = grid |> search words_to_search_for + result = grid |> search(words_to_search_for) expected = Dict.from_list( [ ("clojure", { start: { column: 1, row: 10 }, end: { column: 7, row: 10 } }), @@ -365,7 +365,7 @@ expect clojurermt """ words_to_search_for = ["clojure", "elixir", "ecmascript", "rust", "java", "lua", "lisp"] - result = grid |> search words_to_search_for + result = grid |> search(words_to_search_for) expected = Dict.from_list( [ ("clojure", { start: { column: 1, row: 10 }, end: { column: 7, row: 10 } }), @@ -395,7 +395,7 @@ expect clojurermt """ words_to_search_for = ["clojure", "elixir", "ecmascript", "rust", "java", "lua", "lisp", "ruby"] - result = grid |> search words_to_search_for + result = grid |> search(words_to_search_for) expected = Dict.from_list( [ ("clojure", { start: { column: 1, row: 10 }, end: { column: 7, row: 10 } }), @@ -426,7 +426,7 @@ expect clojurermt """ words_to_search_for = ["clojure", "elixir", "ecmascript", "rust", "java", "lua", "lisp", "ruby", "haskell"] - result = grid |> search words_to_search_for + result = grid |> search(words_to_search_for) expected = Dict.from_list( [ ("clojure", { start: { column: 1, row: 10 }, end: { column: 7, row: 10 } }), @@ -450,7 +450,7 @@ expect def """ words_to_search_for = ["aef", "ced", "abf", "cbd"] - result = grid |> search words_to_search_for + result = grid |> search(words_to_search_for) expected = Dict.from_list( [ # "aef" is not in the grid @@ -469,7 +469,7 @@ expect xirdfg """ words_to_search_for = ["elixir"] - result = grid |> search words_to_search_for + result = grid |> search(words_to_search_for) expected = Dict.from_list( [ # "elixir" is not in the grid @@ -481,7 +481,7 @@ expect expect grid = "silabcdefp" words_to_search_for = ["lisp"] - result = grid |> search words_to_search_for + result = grid |> search(words_to_search_for) expected = Dict.from_list( [ # "lisp" is not in the grid @@ -502,7 +502,7 @@ expect t """ words_to_search_for = ["rust"] - result = grid |> search words_to_search_for + result = grid |> search(words_to_search_for) expected = Dict.from_list( [ # "rust" is not in the grid From 9ca581516f79954c24f7b7e5d36e408a98b0eade Mon Sep 17 00:00:00 2001 From: Anton-4 <17049058+Anton-4@users.noreply.github.com> Date: Sat, 26 Jul 2025 19:50:35 +0200 Subject: [PATCH 8/8] final syntax updates --- .../practice/complex-numbers/.meta/plugins.py | 4 ++-- .../complex-numbers/complex-numbers-test.roc | 4 ++-- .../practice/go-counting/.meta/template.j2 | 2 +- .../practice/go-counting/go-counting-test.roc | 12 ++++++------ exercises/practice/rest-api/.meta/template.j2 | 17 ++++++++++------- exercises/practice/rest-api/rest-api-test.roc | 16 +++++++++------- 6 files changed, 30 insertions(+), 25 deletions(-) diff --git a/exercises/practice/complex-numbers/.meta/plugins.py b/exercises/practice/complex-numbers/.meta/plugins.py index 394b2128..5459402e 100644 --- a/exercises/practice/complex-numbers/.meta/plugins.py +++ b/exercises/practice/complex-numbers/.meta/plugins.py @@ -1,7 +1,7 @@ float_map = { "e": "Num.e", - "ln(2)": "Num.log 2f64", - "ln(2)/2": "Num.log 2f64 / 2", + "ln(2)": "Num.log(2f64)", + "ln(2)/2": "Num.log(2f64) / 2", "pi": "Num.pi", "pi/4": "Num.pi / 4", } diff --git a/exercises/practice/complex-numbers/complex-numbers-test.roc b/exercises/practice/complex-numbers/complex-numbers-test.roc index 671a5fa1..147f2a3a 100644 --- a/exercises/practice/complex-numbers/complex-numbers-test.roc +++ b/exercises/practice/complex-numbers/complex-numbers-test.roc @@ -257,14 +257,14 @@ expect # Exponential of a number with real and imaginary part expect - z = { re: Num.log 2f64, im: Num.pi } + z = { re: Num.log(2f64), im: Num.pi } result = exp(z) expected = { re: -2, im: 0 } result |> is_approx_eq(expected) # Exponential resulting in a number with real and imaginary part expect - z = { re: Num.log 2f64 / 2, im: Num.pi / 4 } + z = { re: Num.log(2f64) / 2, im: Num.pi / 4 } result = exp(z) expected = { re: 1, im: 1 } result |> is_approx_eq(expected) diff --git a/exercises/practice/go-counting/.meta/template.j2 b/exercises/practice/go-counting/.meta/template.j2 index 5b4444cd..c9ded94a 100644 --- a/exercises/practice/go-counting/.meta/template.j2 +++ b/exercises/practice/go-counting/.meta/template.j2 @@ -4,7 +4,7 @@ {% macro to_territory(territory) %} {%- if territory == [] %} -Set.empty {} +Set.empty({}) {%- else %} Set.from_list([ {%- for intersection in territory %} diff --git a/exercises/practice/go-counting/go-counting-test.roc b/exercises/practice/go-counting/go-counting-test.roc index b8e9a306..5e76fc18 100644 --- a/exercises/practice/go-counting/go-counting-test.roc +++ b/exercises/practice/go-counting/go-counting-test.roc @@ -117,7 +117,7 @@ expect expected = Ok( { owner: None, - territory: Set.empty {}, + territory: Set.empty({}), }, ) result |> compare_territory(expected) @@ -156,9 +156,9 @@ expect result = board |> territories expected = Ok( { - black: Set.empty {}, + black: Set.empty({}), - white: Set.empty {}, + white: Set.empty({}), none: Set.from_list( [ @@ -194,7 +194,7 @@ expect ], ), - none: Set.empty {}, + none: Set.empty({}), }, ) result |> compare_territories(expected) @@ -212,9 +212,9 @@ expect ], ), - white: Set.empty {}, + white: Set.empty({}), - none: Set.empty {}, + none: Set.empty({}), }, ) result |> compare_territories(expected) diff --git a/exercises/practice/rest-api/.meta/template.j2 b/exercises/practice/rest-api/.meta/template.j2 index 2a6d44c7..109b5ee3 100644 --- a/exercises/practice/rest-api/.meta/template.j2 +++ b/exercises/practice/rest-api/.meta/template.j2 @@ -5,13 +5,16 @@ import {{ exercise | to_pascal }} exposing [get, post] standardize_result = |result| - result |> Result.try |string| - string - |> Str.replace_each(".0,", ",") - |> Str.replace_each(".0}", "}") - |> Str.to_utf8 - |> List.drop_if |c| [' ', '\t', '\n'] |> List.contains c - |> Str.from_utf8 + result + |> Result.try( + |string| + string + |> Str.replace_each(".0,", ",") + |> Str.replace_each(".0}", "}") + |> Str.to_utf8 + |> List.drop_if |c| [' ', '\t', '\n'] |> List.contains(c) + |> Str.from_utf8 + ) {% for supercase in cases %} ## diff --git a/exercises/practice/rest-api/rest-api-test.roc b/exercises/practice/rest-api/rest-api-test.roc index 6afeac45..d45aa8a2 100644 --- a/exercises/practice/rest-api/rest-api-test.roc +++ b/exercises/practice/rest-api/rest-api-test.roc @@ -15,13 +15,15 @@ import RestApi exposing [get, post] standardize_result = |result| result - |> Result.try |string| - string - |> Str.replace_each(".0,", ",") - |> Str.replace_each(".0}", "}") - |> Str.to_utf8 - |> List.drop_if |c| [' ', '\t', '\n'] |> List.contains c - |> Str.from_utf8 + |> Result.try( + |string| + string + |> Str.replace_each(".0,", ",") + |> Str.replace_each(".0}", "}") + |> Str.to_utf8 + |> List.drop_if |c| [' ', '\t', '\n'] |> List.contains(c) + |> Str.from_utf8, + ) ## ## user management