[#46184] [ruby-trunk - Bug #7095][Open] Non-recursive marking — "authorNari (Narihiro Nakamura)" <authorNari@...>
6 messages
2012/10/01
[#46189] [ruby-trunk - Bug #7100][Open] WEBrick::HTTPServer.new で BindAddress を指定しない場合に必ず警告が記録される — "sho-h (Sho Hashimoto)" <sho-h@...>
5 messages
2012/10/02
[#46203] [ruby-trunk - Bug #7111][Open] New build option to enable/disable global method caching — "shugo (Shugo Maeda)" <redmine@...>
5 messages
2012/10/06
[#46258] [ANN] 2.0.0 feature freeze — Yusuke Endoh <mame@...>
Japanese later; 日本語は後で
5 messages
2012/10/24
[#46309] [ruby-trunk - Bug #2154][Assigned] filesystem encoding of UNIX — "usa (Usaku NAKAMURA)" <usa@...>
13 messages
2012/10/29
[#46310] Re: [ruby-trunk - Bug #2154][Assigned] filesystem encoding of UNIX
— Tanaka Akira <akr@...>
2012/10/29
2012年10月29日 10:31 usa (Usaku NAKAMURA) <usa@garbagecollect.jp>:
[#46366] Re: [ruby-trunk - Bug #2154][Assigned] filesystem encoding of UNIX
— "U.Nakamura" <usa@...>
2012/11/02
こんにちは、なかむら(う)です。
[#46375] Re: [ruby-trunk - Bug #2154][Assigned] filesystem encoding of UNIX
— KOSAKI Motohiro <kosaki.motohiro@...>
2012/11/02
>> とくに指定しなければ、default external は locale から設定されるので、
[#46376] Re: [ruby-trunk - Bug #2154][Assigned] filesystem encoding of UNIX
— Urabe Shyouhei <shyouhei@...>
2012/11/02
On 11/02/2012 01:56 PM, KOSAKI Motohiro wrote:
[#46396] Re: [ruby-trunk - Bug #2154][Assigned] filesystem encoding of UNIX
— "U.Nakamura" <usa@...>
2012/11/05
こんにちは、なかむら(う)です。
[ruby-dev:46268] [ruby-trunk - Feature #4787] Integer#each_modulo(n)
From:
"yhara (Yutaka HARA)" <redmine@...>
Date:
2012-10-25 11:16:54 UTC
List:
ruby-dev #46268
Issue #4787 has been updated by yhara (Yutaka HARA).
Target version changed from 2.0.0 to next minor
----------------------------------------
Feature #4787: Integer#each_modulo(n)
https://bugs.ruby-lang.org/issues/4787#change-31543
Author: mrkn (Kenta Murata)
Status: Assigned
Priority: Normal
Assignee: matz (Yukihiro Matsumoto)
Category: core
Target version: next minor
I suggest a new feature of Integer to enumerate by iterated Integer#modulo.
An example implementation in Ruby is the following code:
class Integer
def each_modulo(n)
raise ArgumentError, "argument must be an Integer" unless n.is_a? Integer
raise ArgumentError, "argument must be larger than 1" if n <= 1
return Enumerator.new(self, :each_modulo, n) unless block_given?
q = self
while q > 0
q, r = q.divmod(n)
yield(r)
end
end
end
p 133.each_modulo(3).to_a #=> [1, 2, 2, 1, 1]
The following code is an example use of the feature:
class Integer
def each_thousand_separation
each_modulo(1000)
end
def thousand_separated_string(sep=',')
each_thousand_separation.map(&'%03d'.method(:%)).inject{|s, n| n + sep + s }
end
end
p 100_000_000_200.thousand_separated_string #=> "100,000,000,200"
I make an implementation in C, and attach the patch for that.
--
http://bugs.ruby-lang.org/