aboutsummaryrefslogtreecommitdiff
path: root/api/lists.yaml
diff options
context:
space:
mode:
Diffstat (limited to 'api/lists.yaml')
-rw-r--r--api/lists.yaml76
1 files changed, 38 insertions, 38 deletions
diff --git a/api/lists.yaml b/api/lists.yaml
index d729fd66..6648fe94 100644
--- a/api/lists.yaml
+++ b/api/lists.yaml
@@ -23,13 +23,13 @@ List.binary_search:
example: |
>> [1, 3, 5, 7, 9].binary_search(5)
= 3
-
+
>> [1, 3, 5, 7, 9].binary_search(-999)
= 1
-
+
>> [1, 3, 5, 7, 9].binary_search(999)
= 6
-
+
List.by:
short: slice by a step value
description: >
@@ -50,7 +50,7 @@ List.by:
example: |
>> [1, 2, 3, 4, 5, 6].by(2)
= [1, 3, 5]
-
+
List.clear:
short: clear a list
description: >
@@ -66,7 +66,7 @@ List.clear:
The mutable reference to the list to be cleared.
example: |
>> my_list.clear()
-
+
List.counts:
short: count occurrences
description: >
@@ -83,7 +83,7 @@ List.counts:
example: |
>> [10, 20, 30, 30, 30].counts()
= {10=1, 20=1, 30=3}
-
+
List.find:
short: find an element's index
description: >
@@ -104,10 +104,10 @@ List.find:
example: |
>> [10, 20, 30, 40, 50].find(20)
= 2 : Int?
-
+
>> [10, 20, 30, 40, 50].find(9999)
= none : Int?
-
+
List.from:
short: slice an array from a start index
description: >
@@ -128,7 +128,7 @@ List.from:
example: |
>> [10, 20, 30, 40, 50].from(3)
= [30, 40, 50]
-
+
List.has:
short: check for member
description: >
@@ -149,7 +149,7 @@ List.has:
example: |
>> [10, 20, 30].has(20)
= yes
-
+
List.heap_pop:
short: heap pop
description: >
@@ -175,7 +175,7 @@ List.heap_pop:
>> my_heap.heapify()
>> my_heap.heap_pop()
= 10
-
+
List.heap_push:
short: heap push
description: >
@@ -201,7 +201,7 @@ List.heap_push:
default comparison function for the item type will be used.
example: |
>> my_heap.heap_push(10)
-
+
List.heapify:
short: convert a list into a heap
description: >
@@ -224,7 +224,7 @@ List.heapify:
example: |
>> my_heap := [30, 10, 20]
>> my_heap.heapify()
-
+
List.insert:
short: add an item to a list
description: >
@@ -255,11 +255,11 @@ List.insert:
>> list.insert(30)
>> list
= [10, 20, 30]
-
+
>> list.insert(999, at=2)
>> list
= [10, 999, 20, 30]
-
+
List.insert_all:
short: add multiple items to a list
description: >
@@ -290,11 +290,11 @@ List.insert_all:
list.insert_all([30, 40])
>> list
= [10, 20, 30, 40]
-
+
list.insert_all([99, 100], at=2)
>> list
= [10, 99, 100, 20, 30, 40]
-
+
List.pop:
short: pop an item from a list
description: >
@@ -321,17 +321,17 @@ List.pop:
to pop the last value.
example: |
>> list := [10, 20, 30, 40]
-
+
>> list.pop()
= 40
>> list
= &[10, 20, 30]
-
+
>> list.pop(index=2)
= 20
>> list
= &[10, 30]
-
+
List.random:
short: pick a random element
description: >
@@ -355,7 +355,7 @@ List.random:
example: |
>> [10, 20, 30].random()
= 20
-
+
List.remove_at:
short: remove an item by index
description: >
@@ -387,11 +387,11 @@ List.remove_at:
list.remove_at(2)
>> list
= [10, 30, 40, 50]
-
+
list.remove_at(2, count=2)
>> list
= [10, 50]
-
+
List.remove_item:
short: remove an item by value
description: >
@@ -421,11 +421,11 @@ List.remove_item:
list.remove_item(10)
>> list
= [20, 20, 30]
-
+
list.remove_item(20, max_count=1)
>> list
= [20, 30]
-
+
List.reversed:
short: get a reversed list
description: >
@@ -442,7 +442,7 @@ List.reversed:
example: |
>> [10, 20, 30].reversed()
= [30, 20, 10]
-
+
List.sample:
short: weighted random choices
description: >
@@ -487,7 +487,7 @@ List.sample:
example: |
>> [10, 20, 30].sample(2, weights=[90%, 5%, 5%])
= [10, 10]
-
+
List.shuffle:
short: shuffle a list in place
description: >
@@ -510,7 +510,7 @@ List.shuffle:
generation)
example: |
>> list.shuffle()
-
+
List.shuffled:
short: return a shuffled list
description: >
@@ -534,7 +534,7 @@ List.shuffled:
example: |
>> [10, 20, 30, 40].shuffled()
= [40, 10, 30, 20]
-
+
List.slice:
short: get a slice of a list
description: >
@@ -561,10 +561,10 @@ List.slice:
example: |
>> [10, 20, 30, 40, 50].slice(2, 4)
= [20, 30, 40]
-
+
>> [10, 20, 30, 40, 50].slice(-3, -2)
= [30, 40]
-
+
List.sort:
short: sort a list
description: >
@@ -588,11 +588,11 @@ List.sort:
list.sort()
>> list
= [-30, 10, 20, 40]
-
+
list.sort(func(a,b:&Int): a.abs() <> b.abs())
>> list
= [10, 20, -30, 40]
-
+
List.sorted:
short: sorted copy of a list
description: >
@@ -614,10 +614,10 @@ List.sorted:
example: |
>> [40, 10, -30, 20].sorted()
= [-30, 10, 20, 40]
-
+
>> [40, 10, -30, 20].sorted(func(a,b:&Int): a.abs() <> b.abs())
= [10, 20, -30, 40]
-
+
List.to:
short: slice a list to an end index
description: >
@@ -638,10 +638,10 @@ List.to:
example: |
>> [10, 20, 30, 40, 50].to(3)
= [10, 20, 30]
-
+
>> [10, 20, 30, 40, 50].to(-2)
= [10, 20, 30, 40]
-
+
List.unique:
short: convert a list to a set
description: >
@@ -658,7 +658,7 @@ List.unique:
example: |
>> [10, 20, 10, 10, 30].unique()
= {10, 20, 30}
-
+
List.where:
short: find an index where a predicate matches
description: >