Skip to content

Commit 8f4f3a8

Browse files
committed
Replace [1,2,3]->find(2) with find([1,2,3], 2) to reduce surprise for newcomers
1 parent 6ec49aa commit 8f4f3a8

2 files changed

Lines changed: 13 additions & 13 deletions

File tree

exercises/practice/binary-search/.meta/template.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {{ exercise | to_pascal }} exposing [{{ cases[0]["property"] | to_snake }
77
{% for case in cases -%}
88
# {{ case["description"] }}
99
expect {
10-
result = {{ case["input"]["array"] | to_roc }} -> {{ case["property"] | to_snake }}({{ case["input"]["value"] }})
10+
result = {{ case["property"] | to_snake }}({{ case["input"]["array"] | to_roc }}, {{ case["input"]["value"] }})
1111
{%- if case["expected"]["error"] %}
1212
result.is_err()
1313
{%- else %}

exercises/practice/binary-search/binary-search-test.roc

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,72 @@
11
# These tests are auto-generated with test data from:
22
# https://github.com/exercism/problem-specifications/tree/main/exercises/binary-search/canonical-data.json
3-
# File last updated on 2026-06-13
3+
# File last updated on 2026-06-21
44

55
import BinarySearch exposing [find]
66

77
# finds a value in an array with one element
88
expect {
9-
result = [6]->find(6)
9+
result = find([6], 6)
1010
result == Ok(0)
1111
}
1212

1313
# finds a value in the middle of an array
1414
expect {
15-
result = [1, 3, 4, 6, 8, 9, 11]->find(6)
15+
result = find([1, 3, 4, 6, 8, 9, 11], 6)
1616
result == Ok(3)
1717
}
1818

1919
# finds a value at the beginning of an array
2020
expect {
21-
result = [1, 3, 4, 6, 8, 9, 11]->find(1)
21+
result = find([1, 3, 4, 6, 8, 9, 11], 1)
2222
result == Ok(0)
2323
}
2424

2525
# finds a value at the end of an array
2626
expect {
27-
result = [1, 3, 4, 6, 8, 9, 11]->find(11)
27+
result = find([1, 3, 4, 6, 8, 9, 11], 11)
2828
result == Ok(6)
2929
}
3030

3131
# finds a value in an array of odd length
3232
expect {
33-
result = [1, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 634]->find(144)
33+
result = find([1, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 634], 144)
3434
result == Ok(9)
3535
}
3636

3737
# finds a value in an array of even length
3838
expect {
39-
result = [1, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377]->find(21)
39+
result = find([1, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377], 21)
4040
result == Ok(5)
4141
}
4242

4343
# identifies that a value is not included in the array
4444
expect {
45-
result = [1, 3, 4, 6, 8, 9, 11]->find(7)
45+
result = find([1, 3, 4, 6, 8, 9, 11], 7)
4646
result.is_err()
4747
}
4848

4949
# a value smaller than the array's smallest value is not found
5050
expect {
51-
result = [1, 3, 4, 6, 8, 9, 11]->find(0)
51+
result = find([1, 3, 4, 6, 8, 9, 11], 0)
5252
result.is_err()
5353
}
5454

5555
# a value larger than the array's largest value is not found
5656
expect {
57-
result = [1, 3, 4, 6, 8, 9, 11]->find(13)
57+
result = find([1, 3, 4, 6, 8, 9, 11], 13)
5858
result.is_err()
5959
}
6060

6161
# nothing is found in an empty array
6262
expect {
63-
result = []->find(1)
63+
result = find([], 1)
6464
result.is_err()
6565
}
6666

6767
# nothing is found when the left and right bounds cross
6868
expect {
69-
result = [1, 2]->find(0)
69+
result = find([1, 2], 0)
7070
result.is_err()
7171
}
7272

0 commit comments

Comments
 (0)