summaryrefslogtreecommitdiffhomepage
path: root/mrbgems/mruby-array-ext/mrblib/array.rb
AgeCommit message (Collapse)Author
2021-12-12Add `Array#{repeated_combination,repeated_permutation}` methodsdearblue
Ruby 1.9.2 feature. ref: https://docs.ruby-lang.org/ja/3.1.0/method/Array/i/repeated_combination.html ref: https://docs.ruby-lang.org/ja/3.1.0/method/Array/i/repeated_permutation.html
2021-11-28Align "wrong number of arguments" messagesdearblue
Make "N for M" into the form "given N, expected M". As I worked, I noticed that the `argnum_error()` function had a part to include the method name in the message. I think this part is no longer needed by https://github.com/mruby/mruby/pull/5394. - Before this patch ```console % bin/mruby -e '[1, 2, 3].each 0' trace (most recent call last): [1] -e:1 -e:1:in each: 'each': wrong number of arguments (1 for 0) (ArgumentError) ``` - After this patch ```console % bin/mruby -e '[1, 2, 3].each 0' trace (most recent call last): [1] -e:1 -e:1:in each: wrong number of arguments (given 1, expected 0) (ArgumentError) ```
2021-10-31Added `Array#product` methoddearblue
Ruby-1.9.0 feature. ref: https://docs.ruby-lang.org/ja/3.0.0/method/Array/i/product.html
2021-06-28Avoid warnings with `ruby -cw`dearblue
```console % for rb in `git ls-files '*/mrblib/*.rb' 'mrblib'`; do ruby30 -cw $rb > /dev/null; done mrbgems/mruby-array-ext/mrblib/array.rb:389: warning: assigned but unused variable - ary mrbgems/mruby-array-ext/mrblib/array.rb:663: warning: assigned but unused variable - len mrbgems/mruby-hash-ext/mrblib/hash.rb:119: warning: possibly useless use of a variable in void context mrbgems/mruby-hash-ext/mrblib/hash.rb:259: warning: assigned but unused variable - keys mrbgems/mruby-io/mrblib/io.rb:229: warning: literal in condition mrbgems/mruby-io/mrblib/io.rb:280: warning: literal in condition mrbgems/mruby-string-ext/mrblib/string.rb:347: warning: assigned but unused variable - len mrbgems/mruby-toplevel-ext/mrblib/toplevel.rb:2: warning: parentheses after method name is interpreted as an argument list, not a decomposed argument ```
2021-06-16Run pre-commit with GitHub ActionsJohn Bampton
Running pre-commit with GitHub Actions now gives us more tests and coverage Remove duplicate GitHub Actions for merge conflicts and trailing whitespace Remove duplicate checks for markdownlint and yamllint from the GitHub Super-Linter Add new custom pre-commit hook running with a shell script to sort alphabetically and uniquify codespell.txt Add new pre-commit hook to check spelling with codespell https://github.com/codespell-project/codespell Fix spelling
2021-05-15mruby-array-ext/array.c: implement `Array#rotate` in C.Yukihiro "Matz" Matsumoto
The Ruby version of `Array#rotate!` generated a rotated array and replaced the receiver, but the C version rotates the receiver array in-place. So the performance is improved a lot both in speed and memory consumption. Look for the comments in `array.c` for the in-place rotating algorithm, if you are interested.
2021-05-14mruby-array-ext/array.c: implement `Array#compact` in C.Yukihiro "Matz" Matsumoto
2021-05-14array.rb: replace `can't` with `cannot`.Yukihiro "Matz" Matsumoto
To avoid editor coloring failures.
2021-04-28array.rb: `Array#uniq` to return always `Array`.Yukihiro "Matz" Matsumoto
Even called for subclass of `Array`, according to new Ruby3.0 behavior. Other methods of `Array` behave as Ruby3.0 from the first hand.
2021-04-17array.rb: add `Array#intersect?` from Ruby3.0.1.Yukihiro "Matz" Matsumoto
2021-02-20Comment out `warn` used in the `Array#fetch` methoddearblue
I get an error because the current mruby does not have a `Kernel#warn` method. But the warning itself is useful and I'll just comment it out in case it's implemented in the future.
2020-11-05Fix `A.new([[1,2],3]).flatten` to return `Array`.Yukihiro "Matz" Matsumoto
2020-01-21Delete duplicated `Array#delete_if`.Hiroshi Mimaki
2019-10-14Fix the example of `Array#intersection` in the document [ci skip]KOBAYASHI Shuji
2019-10-14Add `Array#intersection` which is new in Ruby2.7.Yukihiro "Matz" Matsumoto
2019-10-14Move `Array#difference` just after `Array#-`.Yukihiro "Matz" Matsumoto
2019-10-14Fixed a bug in `Array#difference`.Yukihiro "Matz" Matsumoto
2019-09-20Fix typo in `Array#difference` document [ci skip]KOBAYASHI Shuji
2019-09-16Add `filter` aliases for `Enumerable` and `Hash`.Yukihiro "Matz" Matsumoto
2019-09-16Add `Array#difference` method from Ruby2.6.Yukihiro "Matz" Matsumoto
2019-09-01`Array#permutation` with a negative argument should not yieldKOBAYASHI Shuji
Before this patch: $ bin/mruby -e '[1].permutation(-1){|v| p v}' #=> [1] After this patch (same as Ruby): $ bin/mruby -e '[1].permutation(-1){|v| p v}' #=> no output
2019-08-30`Array#(permutation|combination)` without block should return `self`KOBAYASHI Shuji
2019-07-26Drop dependency from `mruby-array-ext` to `mruby-enum-ext`KOBAYASHI Shuji
2019-04-06Move `Array#(append|prepend)` from core to `mruby-ary-ext`KOBAYASHI Shuji
They are not included in ISO standard.
2019-02-01Move `NONE` to `mrblib/enum.rb`KOBAYASHI Shuji
2018-11-25Fix wrong number of arguments in `Array#fetch`; fix #4170Yukihiro "Matz" Matsumoto
2018-11-19Removed `to_ary` conversion method.Yukihiro "Matz" Matsumoto
2018-11-19Removed `try_convert` method from Array and Hash.Yukihiro "Matz" Matsumoto
2018-11-19fix non-ASCII comment.Yukihiro "Matz" Matsumoto
2018-10-12Call `uniq!` for each union processing in `Array#union`.Yukihiro "Matz" Matsumoto
2018-09-26Add index to larger segment lists for performanceYukihiro "Matz" Matsumoto
2018-09-21Implement `Array#union` which is introduced in Ruby2.6.Yukihiro "Matz" Matsumoto
2018-09-20Improve performance of `Array#uniq!`.Yukihiro "Matz" Matsumoto
2018-09-20Make `#to_h` to take a block; [ruby-core:89088]Yukihiro "Matz" Matsumoto
2017-11-17implement Array.transposeTomasz Dąbrowski
2017-10-20Add `Array#{permutation,combination}.Yukihiro "Matz" Matsumoto
2017-08-26Replaced Array#each with while loop for performance reasonsChristopher Aue
Example benchmark: $ time build/bench/bin/mruby -e "Array.new(2_000_000){ |i| i }.index{ |i| i == 1_999_999 }" Before: real 0m0.934s user 0m0.922s sys 0m0.003s After: real 0m0.590s user 0m0.583s sys 0m0.007s
2017-08-26Removed unneeded block check in Array#uniqChristopher Aue
2017-08-26Reimplemented Array#flatten with #flatten!Christopher Aue
2017-07-30Improved speed of enumeration methodsChristopher Aue
2017-07-28Added Array#bsearch_indexChristopher Aue
2017-07-28Refactored Array#bsearchChristopher Aue
2016-11-02Update documentation of fetchLukas Elmer
The sentence `Negative values of +index+ count from the end of the array.` can be interpreted that it only holds if a block is given. Clarify it.
2016-03-23add #dig to Array,Hash and StructYukihiro "Matz" Matsumoto
2015-11-24add {Array|Hash|String}.try_converttakahashim
2015-10-01Array#index to take block; fix #2968 close #2970Yukihiro "Matz" Matsumoto
2015-08-22Use #nil? instead of == nil.INOUE Yasuyuki
2014-05-03Delete unused variable in Array#delete_ifJun Hiroe
2014-04-30remove trailing spacesNobuyoshi Nakada
2014-04-28Speed up Array#select! from O(n^2) to O(n).Utkarsh Kukreti