Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions config/generator_macros.j2
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ app [main!] {
{% if name == "unicode" -%}
unicode: "https://github.com/roc-lang/unicode/releases/download/3.0.0/ACj5ceJnEY6vaejuQArN1naVzcxeThATZrKYYgzJCZJ5.tar.zst",
{%- elif name == "isodate" -%}
isodate: "https://github.com/ageron/roc-isodate/releases/download/0.8.0/B2h6tefXQtEz9VG6QukLDBoGXhRtwGLj9sZHDEJaTHkS.tar.zst",
isodate: "https://github.com/ageron/roc-isodate/releases/download/0.8.1/DZNmAcoruJkepH2QNAzb6SAebPLKy8Nmru8oR4UZHAcr.tar.zst",
{%- elif name == "parser" -%}
parser: "https://github.com/lukewilliamboswell/roc-parser/releases/download/1.0.2/FrnJ4RGDKpQyoDyESNoBwFNviY4ZGbMVLnUjW9tvSRjk.tar.zst",
{%- elif name == "random" -%}
random: "https://github.com/kili-ilo/roc-random/releases/download/0.9.0/CwDEAmyUMCsqW6dh4pxYnp7suUZAj5b5gpZuh7udtyE7.tar.zst",
random: "https://github.com/kili-ilo/roc-random/releases/download/0.9.2/2ZXLX8WRqrosGu1V3VL5aXqgtfTRvJmjFPx8a26ecVmc.tar.zst",
{%- endif -%}
{%- endfor %}
}
Expand Down
1 change: 1 addition & 0 deletions exercises/practice/affine-cipher/.meta/Example.roc
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ AffineCipher :: { a : U64, b : U64, encode_map : List(U8), decode_map : List(U8)
encode_map : List(U8)
encode_map =
(0..<alphabet_size)
.iter()
.map(
|index| {
encoded_index = (a * index + b) % alphabet_size
Expand Down
2 changes: 1 addition & 1 deletion exercises/practice/bowling/.meta/Example.roc
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ map_triplets = |list, score_func| {
get_or_0 = |index| {
list.get(index) ?? Ball2(0, 0)
}
(0..<list.len()).map(
(0..<list.len()).iter().map(
|index| {
score_func(get_or_0(index), get_or_0((index + 1)), get_or_0((index + 2)))
},
Expand Down
2 changes: 2 additions & 0 deletions exercises/practice/connect/.meta/Example.roc
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,11 @@ transpose : Board -> Board
transpose = |board| {
width = (board |> first_row).len()
(0..<width)
.iter()
.map(
|x| {
(0..<board.len())
.iter()
.map(
|y| {
match board |> get_cell({ x, y }) {
Expand Down
1 change: 1 addition & 0 deletions exercises/practice/crypto-square/.meta/Example.roc
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ CryptoSquare :: {}.{
""
} else {
(0..<width)
.iter()
.map(
|column| {
rows.map(
Expand Down
2 changes: 2 additions & 0 deletions exercises/practice/diamond/.meta/Example.roc
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ Diamond :: {}.{
crash "Unreachable"
}
((-letter_index)..=letter_index)
.iter()
.map(
|row_index| {
((-letter_index)..=letter_index)
.iter()
.map(
|col_index| get_char(row_index, col_index, letter_index),
)
Expand Down
2 changes: 1 addition & 1 deletion exercises/practice/gigasecond/gigasecond-test.roc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# File last updated on 2026-08-01
app [main!] {
pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.21.0/4rAQg8kUYZ3Vksr4qMQHpaFYNiHSn9GgS7gVxghd1XYV.tar.zst",
isodate: "https://github.com/ageron/roc-isodate/releases/download/0.8.0/B2h6tefXQtEz9VG6QukLDBoGXhRtwGLj9sZHDEJaTHkS.tar.zst",
isodate: "https://github.com/ageron/roc-isodate/releases/download/0.8.1/DZNmAcoruJkepH2QNAzb6SAebPLKy8Nmru8oR4UZHAcr.tar.zst",
}

import Gigasecond exposing [add]
Expand Down
1 change: 1 addition & 0 deletions exercises/practice/house/.meta/Example.roc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ House :: {}.{
recite : U64, U64 -> Str
recite = |start_verse, end_verse| {
(start_verse..=end_verse)
.iter()
.map(verse)
|> List.from_iter
|> Str.join_with("\n")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ LargestSeriesProduct :: {}.{
Err(InvalidDigit)
} else {
(0..=(chars.len() - span))
.iter()
.map(
|start_index| {
chars
Expand Down
2 changes: 1 addition & 1 deletion exercises/practice/meetup/meetup-test.roc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# File last updated on 2026-08-01
app [main!] {
pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.21.0/4rAQg8kUYZ3Vksr4qMQHpaFYNiHSn9GgS7gVxghd1XYV.tar.zst",
isodate: "https://github.com/ageron/roc-isodate/releases/download/0.8.0/B2h6tefXQtEz9VG6QukLDBoGXhRtwGLj9sZHDEJaTHkS.tar.zst",
isodate: "https://github.com/ageron/roc-isodate/releases/download/0.8.1/DZNmAcoruJkepH2QNAzb6SAebPLKy8Nmru8oR4UZHAcr.tar.zst",
}

import Meetup exposing [meetup]
Expand Down
1 change: 1 addition & 0 deletions exercises/practice/ocr-numbers/.meta/Example.roc
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ get_digit_grids = |row_group, full_grid_width| {
chunked_rows = row_group.map(|row| row |> chunks_of(3))
num_horizontal_chunks = full_grid_width // 3
(0..<num_horizontal_chunks)
.iter()
.map(
|chunk_index| {
chunked_rows
Expand Down
1 change: 1 addition & 0 deletions exercises/practice/pangram/.meta/Example.roc
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Pangram :: {}.{

alphabet =
('A'..='Z')
.iter()
.fold(
Set.empty(),
|set, c| set.insert(c),
Expand Down
4 changes: 4 additions & 0 deletions exercises/practice/pascals-triangle/.meta/Example.roc
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ PascalsTriangle :: {}.{
pascals_triangle : U64 -> List(List(U64))
pascals_triangle = |count| {
(0..<count)
.iter()
.map(
|row| {
(0..=row)
.iter()
.map(
|column| binomial_coefficient(row, column),
)
Expand All @@ -22,12 +24,14 @@ binomial_coefficient = |n, k| {
} else {
numerator =
((n + 1 - k)..=n)
.iter()
.fold(
1,
|product, value| product * value,
)
denominator =
(1..=k)
.iter()
.fold(
1,
|product, value| product * value,
Expand Down
1 change: 1 addition & 0 deletions exercises/practice/perfect-numbers/.meta/Example.roc
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ aliquot_sum = |number| {
Ok(0)
} else {
(1..=(number // 2))
.iter()
.fold(
0,
|acc, d| if number % d == 0 {
Expand Down
3 changes: 2 additions & 1 deletion exercises/practice/rail-fence-cipher/.meta/Example.roc
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ RailFenceCipher :: {}.{

encoded_indices : U64, U64 -> List(U64)
encoded_indices = |len, rails| {
indices = (0..<len) |> List.from_iter
indices = (0..<len).iter() |> List.from_iter
(0..<rails)
.iter()
|> join_map(
|rail| {
period = 2 * (rails - 1)
Expand Down
8 changes: 4 additions & 4 deletions exercises/practice/rectangles/.meta/Example.roc
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ Rectangles :: {}.{
row
.map_with_index(
|_char, x1| {
y2s = ((y1 + 1)..<height).fold([], |acc, y| acc.append(y))
y2s = ((y1 + 1)..<height).iter().fold([], |acc, y| acc.append(y))
y2s
.map(
|y2| {
x2s = ((x1 + 1)..<row.len()).fold([], |acc, x| acc.append(x))
x2s = ((x1 + 1)..<row.len()).iter().fold([], |acc, x| acc.append(x))
x2s
.map(
|x2| {
Expand Down Expand Up @@ -58,12 +58,12 @@ is_rectangle = |{ grid, x1, y1, x2, y2 }| {
}

has_horizontal_border = |y| {
xs = (x1..=x2).fold([], |acc, x| acc.append(x))
xs = (x1..=x2).iter().fold([], |acc, x| acc.append(x))
xs.all(|x| is_horizontal((x, y)))
}

has_vertical_border = |x| {
ys = (y1..=y2).fold([], |acc, y| acc.append(y))
ys = (y1..=y2).iter().fold([], |acc, y| acc.append(y))
ys.all(|y| is_vertical((x, y)))
}

Expand Down
7 changes: 4 additions & 3 deletions exercises/practice/robot-name/robot-name-test.roc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
app [main!] {
pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.21.0/4rAQg8kUYZ3Vksr4qMQHpaFYNiHSn9GgS7gVxghd1XYV.tar.zst",
random: "https://github.com/kili-ilo/roc-random/releases/download/0.9.0/CwDEAmyUMCsqW6dh4pxYnp7suUZAj5b5gpZuh7udtyE7.tar.zst",
random: "https://github.com/kili-ilo/roc-random/releases/download/0.9.2/2ZXLX8WRqrosGu1V3VL5aXqgtfTRvJmjFPx8a26ecVmc.tar.zst",
}

import RobotName exposing [Factory, Robot]
Expand Down Expand Up @@ -83,6 +83,7 @@ generate_robot_names : { seed : U32, quantity : U64 } -> List(List(U8))
generate_robot_names = |{ seed, quantity }| {
factory = Factory.new({ seed: seed })
(0..<quantity)
.iter()
.fold(
{ names: [], factory },
|state, _| {
Expand Down Expand Up @@ -113,7 +114,7 @@ many_names_1 = generate_robot_names({ seed: 1, quantity: 1000 })

## The set of letters from 'A' to 'Z'
capital_letters : Set(U8)
capital_letters = ('A'..='Z') |> List.from_iter |> Set.from_list
capital_letters = ('A'..='Z').iter() |> List.from_iter |> Set.from_list

# The first character of a robot's name must range from 'A' to 'Z'
expect {
Expand All @@ -135,7 +136,7 @@ expect {

## The set of digits from '0' to '9'
digits : Set(U8)
digits = ('0'..='9') |> List.from_iter |> Set.from_list
digits = ('0'..='9').iter() |> List.from_iter |> Set.from_list

# The third character must range from '0' to '9'
expect {
Expand Down
1 change: 1 addition & 0 deletions exercises/practice/saddle-points/.meta/Example.roc
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ SaddlePoints :: {}.{
smallest_trees_north_south : Set(Position)
smallest_trees_north_south =
(0..<num_columns)
.iter()
|> join_map(
|column_index| {
column : List({ height : U8, row_index : U64 })
Expand Down
1 change: 1 addition & 0 deletions exercises/practice/series/.meta/Example.roc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Series :: {}.{
maybe_list =
(
(0..=(len - slice_length))
.iter()
|> List.from_iter
).map_try(
|start_index| {
Expand Down
4 changes: 2 additions & 2 deletions exercises/practice/sieve/.meta/Example.roc
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Sieve :: {}.{
help_sieve(rest, found_primes)
}
[prime, .. as rest] => {
((prime * 2)..=limit).step_by(prime)
((prime * 2)..=limit).step_by(prime).iter()
.fold(
rest,
|filtered_candidates, multiple_of_prime| {
Expand All @@ -28,7 +28,7 @@ Sieve :: {}.{
}
}

initial_candidates = List.from_iter(2..=limit)
initial_candidates = List.from_iter((2..=limit).iter())
help_sieve(initial_candidates, [])
}
}
Expand Down
1 change: 1 addition & 0 deletions exercises/practice/spiral-matrix/.meta/Example.roc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ SpiralMatrix :: {}.{
spiral_matrix = |size| {
zero_matrix = List.repeat(List.repeat(0, size), size)
(1..=(size * size))
.iter()
.fold(
{ x: -1, y: 0, dx: 1, dy: 0, matrix: zero_matrix },
|state, index| {
Expand Down
1 change: 1 addition & 0 deletions exercises/practice/sublist/.meta/Example.roc
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ Sublist :: {}.{
length_diff = list2.len() - list1.len()
maybe_equal_index =
(0..=length_diff)
.iter()
.fold([], |acc, x| acc.append(x))
.find_first(
|start| {
Expand Down
2 changes: 1 addition & 1 deletion exercises/practice/sum-of-multiples/.meta/Example.roc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ SumOfMultiples :: {}.{
(
factors
.keep_if(|factor| factor > 0)
|> join_map(|factor| (factor..<limit).step_by(factor) |> List.from_iter)
|> join_map(|factor| (factor..<limit).step_by(factor).iter() |> List.from_iter)
|> Set.from_list
).to_list()
.sum()
Expand Down
2 changes: 2 additions & 0 deletions exercises/practice/transpose/.meta/Example.roc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Transpose :: {}.{
}
max_width = chars.map(List.len).max() ?? 0
(0..<max_width)
.iter()
.map(
|col| {
max_row =
Expand All @@ -18,6 +19,7 @@ Transpose :: {}.{
?? 0

(0..=max_row)
.iter()
.map(
|row| get_char(row, col) ?? ' ',
)
Expand Down
3 changes: 3 additions & 0 deletions exercises/practice/word-search/.meta/Example.roc
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@ WordSearch :: {}.{

# for all possible starting positions:
(0..<width)
.iter()
|> join_map(
|column_index| {
(0..<height)
.iter()
|> join_map(
|row_index| {
# for all possible directions:
Expand All @@ -32,6 +34,7 @@ WordSearch :: {}.{
# for all possible lengths:
(
(0..<max_length)
.iter()
|> List.from_iter
).fold_until(
{ found_words: [], chars: [] },
Expand Down