|
72 | 72 | # @param _func the function to call on each element |
73 | 73 | # @details The original list is not modified. |
74 | 74 | # =begin |
75 | | -# (import std.List) |
76 | 75 | # (let collection [1 2 5 12]) |
77 | | -# (forEach collection (fun (element) { |
| 76 | +# (list:forEach collection (fun (element) { |
78 | 77 | # (print element) })) |
79 | 78 | # =end |
80 | 79 | # @author https://github.com/SuperFola |
|
91 | 90 | # @param _func a binary function to call on each element with (index, element) |
92 | 91 | # @details The original list is not modified. |
93 | 92 | # =begin |
94 | | -# (import std.List) |
95 | 93 | # (let collection [1 2 5 12]) |
96 | | -# (enumerate collection (fun (idx element) { |
| 94 | +# (list:enumerate collection (fun (idx element) { |
97 | 95 | # (print idx " " element) })) |
98 | 96 | # =end |
99 | 97 | # @author https://github.com/SuperFola |
|
109 | 107 | # @param _L the list to iterate over |
110 | 108 | # @details The original list is not modified. |
111 | 109 | # =begin |
112 | | -# (import std.List) |
113 | 110 | # (let collection [1 2 5 12]) |
114 | | -# (let p (product collection)) # => 120 |
| 111 | +# (let p (list:product collection)) # => 120 |
115 | 112 | # =end |
116 | 113 | # @author https://github.com/Unactived |
117 | 114 | (let product (fun (_L) { |
|
127 | 124 | # @param _L the list to iterate over |
128 | 125 | # @details The original list is not modified. |
129 | 126 | # =begin |
130 | | -# (import std.List) |
131 | 127 | # (let collection [1 2 5 12]) |
132 | | -# (let p (sum collection)) # => 20 |
| 128 | +# (let p (list:sum collection)) # => 20 |
133 | 129 | # =end |
134 | 130 | # @author https://github.com/Unactived |
135 | 131 | (let sum (fun (_L) { |
|
162 | 158 | # @param _L list of numbers |
163 | 159 | # @details The original list is not modified. |
164 | 160 | # =begin |
165 | | -# (let value (list:min [0 1 2 3 5 8])) # 8 |
| 161 | +# (let value (list:max [0 1 2 3 5 8])) # 8 |
166 | 162 | # =end |
167 | 163 | # @author https://github.com/SuperFola |
168 | 164 | (let max (fun (_L) { |
|
183 | 179 | # @details The original list is not modified. |
184 | 180 | # =begin |
185 | 181 | # (let cool-stuff [1 2 3 4 5 6 7 8 9]) |
186 | | -# (print (drop cool-stuff 4)) # [5 6 7 8 9] |
| 182 | +# (print (list:drop cool-stuff 4)) # [5 6 7 8 9] |
187 | 183 | # =end |
188 | 184 | # @author https://github.com/rstefanic, https://github.com/SuperFola |
189 | 185 | (let drop (fun (_L _n) |
|
206 | 202 | # @details The original list is not modified. |
207 | 203 | # =begin |
208 | 204 | # (let cool-stuff [1 2 3 4 5 6 7 8 9]) |
209 | | -# (print (dropWhile cool-stuff (fun (a) (< a 4)))) # [4 5 6 7 8 9] |
| 205 | +# (print (list:dropWhile cool-stuff (fun (a) (< a 4)))) # [4 5 6 7 8 9] |
210 | 206 | # =end |
211 | 207 | # @author https://github.com/SuperFola |
212 | 208 | (let dropWhile (fun (_L _f) { |
|
227 | 223 | # @details The original list is not modified. |
228 | 224 | # =begin |
229 | 225 | # (import std.Math) |
230 | | -# (print (filter [1 2 3 4 5 6 7 8 9] math:even)) # [2 4 6 8] |
| 226 | +# (print (list:filter [1 2 3 4 5 6 7 8 9] math:even)) # [2 4 6 8] |
231 | 227 | # =end |
232 | 228 | # @author https://github.com/rstefanic |
233 | 229 | (let filter (fun (_L _f) { |
|
244 | 240 | # @param _f the function to apply to each element |
245 | 241 | # @details The original list is not modified. |
246 | 242 | # =begin |
247 | | -# (print (map [1 2 3 4 5 6 7 8 9] (fun (e) (* e e)))) # [1 4 9 25 36 49 64 81] |
| 243 | +# (print (list:map [1 2 3 4 5 6 7 8 9] (fun (e) (* e e)))) # [1 4 9 25 36 49 64 81] |
248 | 244 | # =end |
249 | 245 | # @author https://github.com/rstefanic |
250 | 246 | (let map (fun (_L _f) { |
|
262 | 258 | # @details The original list is not modified. |
263 | 259 | # =begin |
264 | 260 | # (let cool [1 2 3 4 5 6 7 8 9]) |
265 | | -# (print (reduce cool (fun (a b) (+ a b)))) # 45 |
| 261 | +# (print (list:reduce cool (fun (a b) (+ a b)))) # 45 |
266 | 262 | # =end |
267 | 263 | # @author https://github.com/Unactived |
268 | 264 | (let reduce (fun (_L _f) { |
|
279 | 275 | # @details The original list is not modified. |
280 | 276 | # =begin |
281 | 277 | # (let cool [[1 2 3] [4] 5 6 [7 8] 9]) |
282 | | -# (print (flatten cool)) # [1 2 3 4 5 6 7 8 9] |
| 278 | +# (print (list:flatten cool)) # [1 2 3 4 5 6 7 8 9] |
283 | 279 | # =end |
284 | 280 | # @author https://github.com/SuperFola |
285 | 281 | (let flatten (fun (_L) { |
|
301 | 297 | # @details The original list is not modified. |
302 | 298 | # =begin |
303 | 299 | # (let cool [1 2 3 4]) |
304 | | -# (print (flatMap cool (fun (a) [a a]))) # [1 1 2 2 3 3 4 4] |
| 300 | +# (print (list:flatMap cool (fun (a) [a a]))) # [1 1 2 2 3 3 4 4] |
305 | 301 | # =end |
306 | 302 | # @author https://github.com/SuperFola |
307 | 303 | (let flatMap (fun (_L _f) { |
|
322 | 318 | # @param _n the number of elements to take |
323 | 319 | # @details The original list is not modified. |
324 | 320 | # =begin |
325 | | -# (print (take [1 2 3 4 5 6 7 8 9] 4)) # [1 2 3 4] |
| 321 | +# (print (list:take [1 2 3 4 5 6 7 8 9] 4)) # [1 2 3 4] |
326 | 322 | # =end |
327 | 323 | # @author https://github.com/rstefanic |
328 | 324 | (let take (fun (_L _n) { |
|
340 | 336 | # @param _f the predicate |
341 | 337 | # @details The original list is not modified. |
342 | 338 | # =begin |
343 | | -# (print (takeWhile [1 2 3 4 5 6 7 8 9 10] (fun (a) (< a 4)))) # [1 2 3] |
| 339 | +# (print (list:takeWhile [1 2 3 4 5 6 7 8 9 10] (fun (a) (< a 4)))) # [1 2 3] |
344 | 340 | # =end |
345 | 341 | # @author https://github.com/rakista112 |
346 | 342 | (let takeWhile (fun (_L _f) { |
|
384 | 380 | # @details The original list is not modified. |
385 | 381 | # =begin |
386 | 382 | # (let zipped [[1 5] [2 6] [3 7] [4 8]]) |
387 | | -# (print (unzip zipped)) # [[1 2 3 4] [5 6 7 8]] |
| 383 | +# (print (list:unzip zipped)) # [[1 2 3 4] [5 6 7 8]] |
388 | 384 | # =end |
389 | 385 | # @author https://github.com/Unactived |
390 | 386 | (let unzip (fun (_L) { |
|
407 | 403 | # =begin |
408 | 404 | # (let a [1 2 3 4]) |
409 | 405 | # (let b [5 6 7 8]) |
410 | | -# (print (zip a b)) # [[1 5] [2 6] [3 7] [4 8]] |
| 406 | +# (print (list:zip a b)) # [[1 5] [2 6] [3 7] [4 8]] |
411 | 407 | # =end |
412 | 408 | # @author https://github.com/Unactived |
413 | 409 | (let zip (fun (_a _b) { |
|
425 | 421 | # @details The original list is not modified. |
426 | 422 | # =begin |
427 | 423 | # (let a [5 6 7 8]) |
428 | | -# (print (zipWithIndex a)) # [[0 5] [1 6] [2 7] [3 8]] |
| 424 | +# (print (list:zipWithIndex a)) # [[0 5] [1 6] [2 7] [3 8]] |
429 | 425 | # =end |
430 | 426 | # @author https://github.com/SuperFola |
431 | 427 | (let zipWithIndex (fun (_L) { |
|
444 | 440 | # @details The original list is not modified. |
445 | 441 | # =begin |
446 | 442 | # (let a [1 2 3 4]) |
447 | | -# (print (foldLeft a 0 (fun (a b) (+ a b)))) # 10 |
| 443 | +# (print (list:foldLeft a 0 (fun (a b) (+ a b)))) # 10 |
448 | 444 | # =end |
449 | 445 | # @author https://github.com/SuperFola |
450 | 446 | (let foldLeft (fun (_L _init _f) { |
|
462 | 458 | # =begin |
463 | 459 | # (let a [1 2 3 4]) |
464 | 460 | # (let f (fun (e) (< e 5))) |
465 | | -# (print (forAll a f)) # true |
| 461 | +# (print (list:forAll a f)) # true |
466 | 462 | # =end |
467 | 463 | # @author https://github.com/Gryfenfer97 |
468 | 464 | (let forAll (fun (_L _f) { |
|
481 | 477 | # =begin |
482 | 478 | # (let a [1 2 3 4]) |
483 | 479 | # (let f (fun (e) (< e 3))) |
484 | | -# (print (any a f)) # true |
| 480 | +# (print (list:any a f)) # true |
485 | 481 | # =end |
486 | 482 | # @author https://github.com/Gryfenfer97 |
487 | 483 | (let any (fun (_L _f) { |
|
500 | 496 | # =begin |
501 | 497 | # (let a [1 2 3 4]) |
502 | 498 | # (let f (fun (e) (< e 3))) |
503 | | -# (print (none a f)) # false |
504 | | -# (print (none [4 5 6] f)) # true |
| 499 | +# (print (list:none a f)) # false |
| 500 | +# (print (list:none [4 5 6] f)) # true |
505 | 501 | # =end |
506 | 502 | # @author https://github.com/SuperFola |
507 | 503 | (let none (fun (_L _f) |
|
513 | 509 | # =begin |
514 | 510 | # (let lst [1 2 3 4 5 6 7 8 9]) |
515 | 511 | # (let is_even (fun (e) (= 0 (mod e 2)))) |
516 | | -# (print (countIf lst is_even)) # 4 |
| 512 | +# (print (list:countIf lst is_even)) # 4 |
517 | 513 | # =end |
518 | 514 | # @author https://github.com/SuperFola |
519 | 515 | (let countIf (fun (_L _f) { |
|
534 | 530 | # @param _length the sequence length |
535 | 531 | # =begin |
536 | 532 | # (let f (fun (x) (+ 7 x))) |
537 | | -# (print (iterate 0 f 10)) # [0 7 14 21 28 35 42 49 56 63] |
| 533 | +# (print (list:iterate 0 f 10)) # [0 7 14 21 28 35 42 49 56 63] |
538 | 534 | # =end |
539 | 535 | # @author https://github.com/SuperFola |
540 | 536 | (let iterate (fun (_init _f _length) { |
|
553 | 549 | # @param _init initial value of the sequence |
554 | 550 | # @param _length the sequence length |
555 | 551 | # =begin |
556 | | -# (print (iota 0 10)) # [0 1 2 3 4 5 6 7 8 9] |
| 552 | +# (print (list:iota 0 10)) # [0 1 2 3 4 5 6 7 8 9] |
557 | 553 | # =end |
558 | 554 | # @author https://github.com/SuperFola |
559 | 555 | (let iota (fun (_init _length) (iterate _init (fun (x) (+ 1 x)) _length))) |
|
0 commit comments