Skip to content

Commit 18a6305

Browse files
committed
Fix documentation examples on pairs.
1 parent b83d3c3 commit 18a6305

File tree

2 files changed

+54
-54
lines changed

2 files changed

+54
-54
lines changed

.github/workflows/continuous-integration.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ jobs:
5252
path: "docs/"
5353

5454
deploy:
55-
if: ${{ startsWith(github.ref, 'refs/tags') }}
55+
# if: ${{ startsWith(github.ref, 'refs/tags') }}
5656
needs: build
5757
runs-on: ubuntu-latest
5858
environment:

lib/aiken/pairs.ak

Lines changed: 53 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616
/// Duplicate keys are not removed. Only the **first** key found is removed.
1717
///
1818
/// ```aiken
19-
/// alist.remove_first([], "a") == []
20-
/// alist.remove_first([Pair("a", 1)], "a") == []
21-
/// alist.remove_first([Pair("a", 1), Pair("b", 2)], "a") == [Pair("b", 2)]
22-
/// alist.remove_first([Pair("a", 1), Pair("b", 2), Pair("a", 3)], "a") == [Pair("b", 2), Pair("a", 3)]
19+
/// pairs.remove_first([], "a") == []
20+
/// pairs.remove_first([Pair("a", 1)], "a") == []
21+
/// pairs.remove_first([Pair("a", 1), Pair("b", 2)], "a") == [Pair("b", 2)]
22+
/// pairs.remove_first([Pair("a", 1), Pair("b", 2), Pair("a", 3)], "a") == [Pair("b", 2), Pair("a", 3)]
2323
/// ```
2424
pub fn remove_first(self: Pairs<key, value>, key k: key) -> Pairs<key, value> {
2525
when self is {
@@ -58,10 +58,10 @@ test remove_first_4() {
5858
/// Duplicate keys are not removed. Only the **last** key found is removed.
5959
///
6060
/// ```aiken
61-
/// alist.remove_last([], "a") == []
62-
/// alist.remove_last([Pair("a", 1)], "a") == []
63-
/// alist.remove_last([Pair("a", 1), Pair("b", 2)], "a") == [Pair("b", 2)]
64-
/// alist.remove_last([Pair("a", 1), Pair("b", 2), Pair("a", 3)], "a") == [Pair("a", 1), Pair("b", 2)]
61+
/// pairs.remove_last([], "a") == []
62+
/// pairs.remove_last([Pair("a", 1)], "a") == []
63+
/// pairs.remove_last([Pair("a", 1), Pair("b", 2)], "a") == [Pair("b", 2)]
64+
/// pairs.remove_last([Pair("a", 1), Pair("b", 2), Pair("a", 3)], "a") == [Pair("a", 1), Pair("b", 2)]
6565
/// ```
6666
pub fn remove_last(self: Pairs<key, value>, key k: key) -> Pairs<key, value> {
6767
when self is {
@@ -104,10 +104,10 @@ test remove_last_4() {
104104
/// Remove all key-value pairs matching the key from the Pairs. If the key is not found, no changes are made.
105105
///
106106
/// ```aiken
107-
/// alist.remove_all([], "a") == []
108-
/// alist.remove_all([Pair("a", 1)], "a") == []
109-
/// alist.remove_all([Pair("a", 1), Pair("b", 2)], "a") == [Pair("b", 2)]
110-
/// alist.remove_all([Pair("a", 1), Pair("b", 2), Pair("a", 3)], "a") == [Pair("b", 2)]
107+
/// pairs.remove_all([], "a") == []
108+
/// pairs.remove_all([Pair("a", 1)], "a") == []
109+
/// pairs.remove_all([Pair("a", 1), Pair("b", 2)], "a") == [Pair("b", 2)]
110+
/// pairs.remove_all([Pair("a", 1), Pair("b", 2), Pair("a", 3)], "a") == [Pair("b", 2)]
111111
/// ```
112112
pub fn remove_all(self: Pairs<key, value>, key k: key) -> Pairs<key, value> {
113113
when self is {
@@ -145,10 +145,10 @@ test remove_all_4() {
145145
/// Finds the first key in the alist associated with a given value, if any.
146146
///
147147
/// ```aiken
148-
/// alist.find_first([], 1) == None
149-
/// alist.find_first([Pair("a", 1)], 1) == Some("a")
150-
/// alist.find_first([Pair("a", 1), Pair("b", 2)], 1) == Some("a")
151-
/// alist.find_first([Pair("a", 1), Pair("b", 2), Pair("c", 1)], 1) == Some("a")
148+
/// pairs.find_first([], 1) == None
149+
/// pairs.find_first([Pair("a", 1)], 1) == Some("a")
150+
/// pairs.find_first([Pair("a", 1), Pair("b", 2)], 1) == Some("a")
151+
/// pairs.find_first([Pair("a", 1), Pair("b", 2), Pair("c", 1)], 1) == Some("a")
152152
/// ```
153153
pub fn find_first(self: Pairs<key, value>, v: value) -> Option<key> {
154154
when self is {
@@ -181,10 +181,10 @@ test find_first_4() {
181181
/// Finds the last key in the alist associated with a given value, if any.
182182
///
183183
/// ```aiken
184-
/// alist.find_last([], 1) == None
185-
/// alist.find_last([Pair("a", 1)], 1) == Some("a")
186-
/// alist.find_last([Pair("a", 1), Pair("b", 2)], 1) == Some("a")
187-
/// alist.find_last([Pair("a", 1), Pair("b", 2), Pair("c", 1)], 1) == Some("c")
184+
/// pairs.find_last([], 1) == None
185+
/// pairs.find_last([Pair("a", 1)], 1) == Some("a")
186+
/// pairs.find_last([Pair("a", 1), Pair("b", 2)], 1) == Some("a")
187+
/// pairs.find_last([Pair("a", 1), Pair("b", 2), Pair("c", 1)], 1) == Some("c")
188188
/// ```
189189
pub fn find_last(self: Pairs<key, value>, v: value) -> Option<key> {
190190
when self is {
@@ -220,10 +220,10 @@ test find_last_4() {
220220
/// Finds all keys in the alist associated with a given value.
221221
///
222222
/// ```aiken
223-
/// alist.find_all([], 1) == []
224-
/// alist.find_all([Pair("a", 1)], 1) == ["a"]
225-
/// alist.find_all([Pair("a", 1), Pair("b", 2)], 1) == ["a"]
226-
/// alist.find_all([Pair("a", 1), Pair("b", 2), Pair("c", 1)], 1) == ["a", "c"]
223+
/// pairs.find_all([], 1) == []
224+
/// pairs.find_all([Pair("a", 1)], 1) == ["a"]
225+
/// pairs.find_all([Pair("a", 1), Pair("b", 2)], 1) == ["a"]
226+
/// pairs.find_all([Pair("a", 1), Pair("b", 2), Pair("c", 1)], 1) == ["a", "c"]
227227
/// ```
228228
pub fn find_all(self: Pairs<key, value>, v: value) -> List<key> {
229229
when self is {
@@ -264,7 +264,7 @@ test find_all_4() {
264264
/// Pair(3, 300),
265265
/// ]
266266
///
267-
/// alist.foldr(fixture, 0, fn(k, v, result) { k * v + result }) == 1400
267+
/// pairs.foldr(fixture, 0, fn(k, v, result) { k * v + result }) == 1400
268268
/// ```
269269
pub fn foldr(
270270
self: Pairs<key, value>,
@@ -296,7 +296,7 @@ test foldr_3() {
296296
foldr(fixture, 0, fn(k, v, result) { k * v + result }) == 1400
297297
}
298298

299-
/// Fold over the key-value pairs in a alist. The fold direction follows keys
299+
/// Fold over the key-value pairs in a pairs. The fold direction follows keys
300300
/// in ascending order and is done from left-to-right.
301301
///
302302
/// ```aiken
@@ -306,7 +306,7 @@ test foldr_3() {
306306
/// Pair(3, 300),
307307
/// ]
308308
///
309-
/// alist.foldl(fixture, 0, fn(k, v, result) { k * v + result }) == 1400
309+
/// pairs.foldl(fixture, 0, fn(k, v, result) { k * v + result }) == 1400
310310
/// ```
311311
pub fn foldl(
312312
self: Pairs<key, value>,
@@ -335,10 +335,10 @@ test foldl_2() {
335335
/// If multiple values with the same key exist, only the first one is returned.
336336
///
337337
/// ```aiken
338-
/// alist.get_first([], "a") == None
339-
/// alist.get_first([Pair("a", 1)], "a") == Some(1)
340-
/// alist.get_first([Pair("a", 1), Pair("b", 2)], "a") == Some(1)
341-
/// alist.get_first([Pair("a", 1), Pair("b", 2), Pair("a", 3)], "a") == Some(1)
338+
/// pairs.get_first([], "a") == None
339+
/// pairs.get_first([Pair("a", 1)], "a") == Some(1)
340+
/// pairs.get_first([Pair("a", 1), Pair("b", 2)], "a") == Some(1)
341+
/// pairs.get_first([Pair("a", 1), Pair("b", 2), Pair("a", 3)], "a") == Some(1)
342342
/// ```
343343
pub fn get_first(self: Pairs<key, value>, key k: key) -> Option<value> {
344344
when self is {
@@ -376,10 +376,10 @@ test get_first_5() {
376376
/// If multiple values with the same key exist, only the last one is returned.
377377
///
378378
/// ```aiken
379-
/// alist.get_last([], "a") == None
380-
/// alist.get_last([Pair("a", 1)], "a") == Some(1)
381-
/// alist.get_last([Pair("a", 1), Pair("b", 2)], "a") == Some(1)
382-
/// alist.get_last([Pair("a", 1), Pair("b", 2), Pair("a", 3)], "a") == Some(3)
379+
/// pairs.get_last([], "a") == None
380+
/// pairs.get_last([Pair("a", 1)], "a") == Some(1)
381+
/// pairs.get_last([Pair("a", 1), Pair("b", 2)], "a") == Some(1)
382+
/// pairs.get_last([Pair("a", 1), Pair("b", 2), Pair("a", 3)], "a") == Some(3)
383383
/// ```
384384
pub fn get_last(self: Pairs<key, value>, key k: key) -> Option<value> {
385385
when self is {
@@ -419,10 +419,10 @@ test get_last_5() {
419419
/// Get all values in the alist associated with a given key.
420420
///
421421
/// ```aiken
422-
/// alist.get_all([], "a") == []
423-
/// alist.get_all([Pair("a", 1)], "a") == [1]
424-
/// alist.get_all([Pair("a", 1), Pair("b", 2)], "a") == [1]
425-
/// alist.get_all([Pair("a", 1), Pair("b", 2), Pair("a", 3)], "a") == [1, 3]
422+
/// pairs.get_all([], "a") == []
423+
/// pairs.get_all([Pair("a", 1)], "a") == [1]
424+
/// pairs.get_all([Pair("a", 1), Pair("b", 2)], "a") == [1]
425+
/// pairs.get_all([Pair("a", 1), Pair("b", 2), Pair("a", 3)], "a") == [1, 3]
426426
/// ```
427427
pub fn get_all(self: Pairs<key, value>, key k: key) -> List<value> {
428428
when self is {
@@ -457,13 +457,13 @@ test get_all_5() {
457457
get_all([Pair("a", 1), Pair("b", 2), Pair("c", 3)], "d") == []
458458
}
459459

460-
/// Check if a key exists in the alist.
460+
/// Check if a key exists in the pairs.
461461
///
462462
/// ```aiken
463-
/// alist.has_key([], "a") == False
464-
/// alist.has_key([Pair("a", 1)], "a") == True
465-
/// alist.has_key([Pair("a", 1), Pair("b", 2)], "a") == True
466-
/// alist.has_key([Pair("a", 1), Pair("b", 2), Pair("a", 3)], "a") == True
463+
/// pairs.has_key([], "a") == False
464+
/// pairs.has_key([Pair("a", 1)], "a") == True
465+
/// pairs.has_key([Pair("a", 1), Pair("b", 2)], "a") == True
466+
/// pairs.has_key([Pair("a", 1), Pair("b", 2), Pair("a", 3)], "a") == True
467467
/// ```
468468
pub fn has_key(self: Pairs<key, value>, k: key) -> Bool {
469469
when self is {
@@ -496,10 +496,10 @@ test has_key_5() {
496496
/// Extract all the keys present in a given `Pairs`.
497497
///
498498
/// ```aiken
499-
/// alist.keys([]) == []
500-
/// alist.keys([Pair("a", 1)]) == ["a"]
501-
/// alist.keys([Pair("a", 1), Pair("b", 2)]) == ["a", "b"]
502-
/// alist.keys([Pair("a", 1), Pair("b", 2), Pair("a", 3)]) == ["a", "b", "a"]
499+
/// pairs.keys([]) == []
500+
/// pairs.keys([Pair("a", 1)]) == ["a"]
501+
/// pairs.keys([Pair("a", 1), Pair("b", 2)]) == ["a", "b"]
502+
/// pairs.keys([Pair("a", 1), Pair("b", 2), Pair("a", 3)]) == ["a", "b", "a"]
503503
/// ```
504504
pub fn keys(self: Pairs<key, value>) -> List<key> {
505505
when self is {
@@ -527,7 +527,7 @@ test keys_3() {
527527
/// ```aiken
528528
/// let fixture = [Pair("a", 100), Pair("b", 200)]
529529
///
530-
/// alist.map(fixture, fn(_k, v) { v * 2 }) == [Pair("a", 200), Pair("b", 400)]
530+
/// pairs.map(fixture, fn(_k, v) { v * 2 }) == [Pair("a", 200), Pair("b", 400)]
531531
/// ```
532532
pub fn map(
533533
self: Pairs<key, value>,
@@ -558,10 +558,10 @@ test map_2() {
558558
/// Extract all the values present in a given `Pairs`.
559559
///
560560
/// ```aiken
561-
/// alist.values([]) == []
562-
/// alist.values([Pair("a", 1)]) == [1]
563-
/// alist.values([Pair("a", 1), Pair("b", 2)]) == [1, 2]
564-
/// alist.values([Pair("a", 1), Pair("b", 2), Pair("a", 3)]) == [1, 2, 3]
561+
/// pairs.values([]) == []
562+
/// pairs.values([Pair("a", 1)]) == [1]
563+
/// pairs.values([Pair("a", 1), Pair("b", 2)]) == [1, 2]
564+
/// pairs.values([Pair("a", 1), Pair("b", 2), Pair("a", 3)]) == [1, 2, 3]
565565
/// ```
566566
pub fn values(self: Pairs<key, value>) -> List<value> {
567567
when self is {

0 commit comments

Comments
 (0)