|
1 | | -# (([List]index) |
2 | | -# !List |
3 | | -# \list:forEach Iterate over a given list and run a given function on every element. |
4 | | -# \list:forEach The original list is left unmodified. Example: |
5 | | -# ` |
| 1 | +### |
| 2 | +# @meta List |
| 3 | +# @brief Iterate over a given list and run a given function on every element. |
| 4 | +# @details The original list is left unmodified. Example: |
| 5 | +# --- |
6 | 6 | # (import "List.ark") |
7 | 7 | # (let collection [1 2 5 12]) |
8 | 8 | # (let new (list:forEach collection (fun (element) { |
9 | 9 | # (print element) |
10 | 10 | # }))) |
11 | | -# ` |
12 | | -# @_L the list to iterate over |
13 | | -# @_func the function to call on each element |
14 | | -# author: https://github.com/SuperFola |
15 | | -# ) |
| 11 | +# --- |
| 12 | +# @param _L the list to iterate over |
| 13 | +# @param _func the function to call on each element |
| 14 | +# @author https://github.com/SuperFola |
| 15 | +### |
16 | 16 | (let list:forEach (fun (_L _func) { |
17 | 17 | (mut _index 0) |
18 | 18 | (while (< _index (len _L)) { |
|
22 | 22 | }) |
23 | 23 | })) |
24 | 24 |
|
25 | | -# (([List]index) |
26 | | -# !List |
27 | | -# \list:product Iterate over a given list and multiply all the elements with the others. |
28 | | -# \list:product The original list is left unmodified. Example: |
29 | | -# ` |
| 25 | +### |
| 26 | +# @meta List |
| 27 | +# @brief Iterate over a given list and multiply all the elements with the others. |
| 28 | +# @details The original list is left unmodified. Example: |
| 29 | +# --- |
30 | 30 | # (import "List.ark") |
31 | 31 | # (let collection [1 2 5 12]) |
32 | 32 | # (let p (list:product collection)) # => 120 |
33 | | -# ` |
34 | | -# @_L the list to iterate over |
35 | | -# author: https://github.com/FrenchMasterSword |
36 | | -# ) |
| 33 | +# --- |
| 34 | +# @param _L the list to iterate over |
| 35 | +# @author https://github.com/FrenchMasterSword |
| 36 | +### |
37 | 37 | (let list:product (fun (_L) { |
38 | 38 | (mut _index 0) |
39 | 39 | (mut _output 1) |
|
44 | 44 | _output |
45 | 45 | })) |
46 | 46 |
|
47 | | -# (([List]index) |
48 | | -# !List |
49 | | -# \list:sum Iterate over a given list and sum all the elements. |
50 | | -# \list:sum The original list is left unmodified. Example: |
51 | | -# ` |
| 47 | +### |
| 48 | +# @meta List |
| 49 | +# @brief Iterate over a given list and sum all the elements. |
| 50 | +# @details The original list is left unmodified. Example: |
| 51 | +# --- |
52 | 52 | # (import "List.ark") |
53 | 53 | # (let collection [1 2 5 12]) |
54 | 54 | # (let p (list:sum collection)) # => 20 |
55 | | -# ` |
56 | | -# @_L the list to iterate over |
57 | | -# author: https://github.com/FrenchMasterSword |
58 | | -# ) |
| 55 | +# --- |
| 56 | +# @param _L the list to iterate over |
| 57 | +# @author https://github.com/FrenchMasterSword |
| 58 | +### |
59 | 59 | (let list:sum (fun (_L) { |
60 | 60 | (mut _index 0) |
61 | 61 | (mut _output 0) |
|
66 | 66 | _output |
67 | 67 | })) |
68 | 68 |
|
69 | | -# @author: https://github.com/rstefanic |
| 69 | +### |
| 70 | +# @meta List |
| 71 | +# @brief |
| 72 | +# @details |
| 73 | +# --- |
| 74 | +# --- |
| 75 | +# @param _L the list to work on |
| 76 | +# @author https://github.com/rstefanic |
| 77 | +### |
70 | 78 | (let list:drop (fun (_L _n) { |
71 | 79 | (mut _index _n) |
72 | 80 | (mut _output []) |
|
77 | 85 | _output |
78 | 86 | })) |
79 | 87 |
|
80 | | -# @author: https://github.com/rstefanic |
| 88 | +### |
| 89 | +# @meta List |
| 90 | +# @brief |
| 91 | +# @details |
| 92 | +# --- |
| 93 | +# --- |
| 94 | +# @param _L the list to work on |
| 95 | +# @author https://github.com/rstefanic |
| 96 | +### |
81 | 97 | (let list:dropWhile (fun (_L _f) { |
82 | 98 | (mut _index 0) |
83 | 99 | (mut _output []) |
|
93 | 109 | _output |
94 | 110 | })) |
95 | 111 |
|
96 | | -# @author: https://github.com/rstefanic |
| 112 | +### |
| 113 | +# @meta List |
| 114 | +# @brief |
| 115 | +# @details |
| 116 | +# --- |
| 117 | +# --- |
| 118 | +# @param _L the list to work on |
| 119 | +# @author https://github.com/rstefanic |
| 120 | +### |
97 | 121 | (let list:filter (fun (_L _f) { |
98 | 122 | (mut _index 0) |
99 | 123 | (mut _output []) |
|
105 | 129 | _output |
106 | 130 | })) |
107 | 131 |
|
108 | | -# @author: https://github.com/rstefanic |
| 132 | +### |
| 133 | +# @meta List |
| 134 | +# @brief |
| 135 | +# @details |
| 136 | +# --- |
| 137 | +# --- |
| 138 | +# @param _L the list to work on |
| 139 | +# @author https://github.com/rstefanic |
| 140 | +### |
109 | 141 | (let list:map (fun (_L _f) { |
110 | 142 | (mut _index 0) |
111 | 143 | (mut _output []) |
|
116 | 148 | _output |
117 | 149 | })) |
118 | 150 |
|
119 | | -# @author: https://github.com/FrenchMasterSword |
| 151 | +### |
| 152 | +# @meta List |
| 153 | +# @brief |
| 154 | +# @details |
| 155 | +# --- |
| 156 | +# --- |
| 157 | +# @param _L the list to work on |
| 158 | +# @author https://github.com/FrenchMasterSword |
| 159 | +### |
120 | 160 | (let list:reduce (fun (_L _f) { |
121 | 161 | (mut _index 1) |
122 | 162 | (mut _output (@ _L 0)) |
|
127 | 167 | _output |
128 | 168 | })) |
129 | 169 |
|
130 | | -# @author: https://github.com/rstefanic |
| 170 | +### |
| 171 | +# @meta List |
| 172 | +# @brief |
| 173 | +# @details |
| 174 | +# --- |
| 175 | +# --- |
| 176 | +# @param _L the list to work on |
| 177 | +# @author https://github.com/rstefanic |
| 178 | +### |
131 | 179 | (let list:take (fun (_L _n) { |
132 | 180 | (mut _index 0) |
133 | 181 | (mut _output []) |
|
138 | 186 | _output |
139 | 187 | })) |
140 | 188 |
|
141 | | -# @author: https://github.com/rstefanic |
| 189 | +### |
| 190 | +# @meta List |
| 191 | +# @brief |
| 192 | +# @details |
| 193 | +# --- |
| 194 | +# --- |
| 195 | +# @param _L the list to work on |
| 196 | +# @author https://github.com/rstefanic |
| 197 | +### |
142 | 198 | (let list:takeWhile (fun (_L _f) { |
143 | 199 | (mut _index 0) |
144 | 200 | (mut _output []) |
|
155 | 211 | _output |
156 | 212 | })) |
157 | 213 |
|
158 | | -# @author: https://github.com/FrenchMasterSword |
| 214 | +### |
| 215 | +# @meta List |
| 216 | +# @brief |
| 217 | +# @details |
| 218 | +# --- |
| 219 | +# --- |
| 220 | +# @param _L the list to work on |
| 221 | +# @author https://github.com/FrenchMasterSword |
| 222 | +### |
159 | 223 | (let list:unzip (fun (_L) { |
160 | 224 | (let _m (len _L)) |
161 | 225 | (mut _list1 []) |
|
172 | 236 |
|
173 | 237 | (import "Math.ark") # needed for (math:min a b) |
174 | 238 |
|
175 | | -# @author: https://github.com/FrenchMasterSword |
| 239 | +### |
| 240 | +# @meta List |
| 241 | +# @brief |
| 242 | +# @details |
| 243 | +# --- |
| 244 | +# --- |
| 245 | +# @param _L the list to work on |
| 246 | +# @author https://github.com/FrenchMasterSword |
| 247 | +### |
176 | 248 | (let list:zip (fun (_a _b) { |
177 | 249 | (let _m (math:min (len _a) (len _b))) |
178 | 250 | (mut _c []) |
|
0 commit comments