[#44014] Re: [ruby-core:37707] [Ruby 1.9 - Bug #3781] FIBER_USE_NATIVE が有効だと落ちるスクリプトがある — Narihiro Nakamura <authornari@...>

nariです。

14 messages 2011/07/02
[#44019] Re: [ruby-core:37707] [Ruby 1.9 - Bug #3781] FIBER_USE_NATIVE が有効だと落ちるスクリプトがある — KOSAKI Motohiro <kosaki.motohiro@...> 2011/07/02

> 本当はgc_mark()の際に毎回stack_check()するのがいいと思うのですが、

[#44027] [RubyKaigi] Next version of Ruby 1.8 and 1.9 — "Yuki Sonoda (Yugui)" <yugui@...>

-----BEGIN PGP SIGNED MESSAGE-----

16 messages 2011/07/03

[#44156] [Ruby 1.9 - Feature #5053][Open] ruby コマンドと libruby の食い違いチェック — Makoto Kishimoto <redmine@...>

20 messages 2011/07/19

[#44185] [Ruby 1.9 - Bug #5074][Open] "[BUG] cfp consistency error - send" on TestEnumerator#test_feed_yielder (test/ruby/test_enumerator.rb) — Shota Fukumori <sorah@...>

10 messages 2011/07/22

[#44189] [Ruby 1.9 - Bug #5075][Assigned] invalid *fdp in Mac OS X and FreeBSD over recvmsg with SCM_RIGHTS — Yui NARUSE <naruse@...>

12 messages 2011/07/22

[#44210] 1.9.3 (以降) の BigDecimal について — Tadayoshi Funaba <tadf@...>

BigDecimal() で整数、浮動小数点数、有理数などを受けとれるようになって、

14 messages 2011/07/23
[#44275] Re: 1.9.3 (以降) の BigDecimal について — Tadayoshi Funaba <tadf@...> 2011/07/30

変換には明示的なものとそうでないものがありますが、

[#44223] [Ruby 1.9 - Bug #5094][Assigned] Supported platforms of Ruby 1.9.3 — Yui NARUSE <naruse@...>

21 messages 2011/07/25
[#44229] Re: [Ruby 1.9 - Bug #5094][Assigned] Supported platforms of Ruby 1.9.3 — KOSAKI Motohiro <kosaki.motohiro@...> 2011/07/25

> == 成瀬の提案

[#44230] Re: [Ruby 1.9 - Bug #5094][Assigned] Supported platforms of Ruby 1.9.3 — Urabe Shyouhei <shyouhei@...> 2011/07/26

卜部です

[#44236] Re: [Ruby 1.9 - Bug #5094][Assigned] Supported platforms of Ruby 1.9.3 — Yusuke ENDOH <mame@...> 2011/07/26

遠藤です。

[#44254] [Ruby 1.8 - Bug #5105][Open] CGI::Session#session_id の生成方法について — Masahiro Tomita <tommy@...>

14 messages 2011/07/27
[#44256] [Ruby 1.8 - Bug #5105] CGI::Session#session_id の生成方法について — Yui NARUSE <naruse@...> 2011/07/27

[#44258] Re: [Ruby 1.8 - Bug #5105] CGI::Session#session_id の生成方法について — とみたまさひろ <tommy@...> 2011/07/27

とみたです。

[#44262] Re: [Ruby 1.8 - Bug #5105] CGI::Session#session_id の生成方法について — "NARUSE, Yui" <naruse@...> 2011/07/27

(2011/07/27 19:47), とみたまさひろ wrote:

[#44263] Re: [Ruby 1.8 - Bug #5105] CGI::Session#session_id の生成方法について — とみたまさひろ <tommy@...> 2011/07/27

とみたです。

[#44270] Re: [Ruby 1.8 - Bug #5105] CGI::Session#session_id の生成方法について — とみたまさひろ <tommy@...> 2011/07/29

とみたです。

[#44271] Re: [Ruby 1.8 - Bug #5105] CGI::Session#session_id の生成方法について — Tanaka Akira <akr@...> 2011/07/29

2011年7月29日20:04 とみたまさひろ <tommy@tmtm.org>:

[ruby-dev:44121] [Ruby 1.9 - Feature #4787] Integer#each_modulo(n)

From: Thomas Sawyer <transfire@...>
Date: 2011-07-16 23:42:46 UTC
List: ruby-dev #44121
Issue #4787 has been updated by Thomas Sawyer.


Why not just let #modulo/#divmod take a block, rather than define a new method?
----------------------------------------
Feature #4787: Integer#each_modulo(n)
http://redmine.ruby-lang.org/issues/4787

Author: Kenta Murata
Status: Open
Priority: Normal
Assignee: Yukihiro Matsumoto
Category: core
Target version: 1.9.x


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://redmine.ruby-lang.org

In This Thread