# The Great Computer Language Shootout # http://shootout.alioth.debian.org/ # # contributed by Gabriele Renzi class PiDigitSpigot def initialize() @z = Transformation.new 1,0,0,1 @x = Transformation.new 0,0,0,0 @inverse = Transformation.new 0,0,0,0 end def next! @y = @z.extract(3) if safe? @y @z = produce(@y) @y else @z = consume @x.next!() next!() end end def safe?(digit) digit == @z.extract(4) end def produce(i) @inverse.qrst(10,-10*i,0,1).compose(@z) end def consume(a) @z.compose(a) end end class Transformation attr_reader :q, :r, :s, :t def initialize(q, r, s, t) @q,@r,@s,@t,@k = q,r,s,t,0 end def next!() @q = @k = @k + 1 @r = 4 * @k + 2 @s = 0 @t = 2 * @k + 1 self end def extract(j) (@q * j + @r) / (@s * j + @t) end def compose(a) self.class.new( @q * a.q, @q * a.r + r * a.t, @s * a.q + t * a.s, @s * a.r + t * a.t ) end def qrst *args initialize *args self end end WIDTH = 10 n = 2_500 # Integer(ARGV[0]) j = 0 digits = PiDigitSpigot.new while n > 0 if n >= WIDTH WIDTH.times {print digits.next!} j += WIDTH else n.times {print digits.next!} (WIDTH-n).times {print " "} j += n end puts "\t:"+j.to_s n -= WIDTH end ption> The Ruby Programming Language
summaryrefslogtreecommitdiff
path: root/lib/did_you_mean/spell_checkers
AgeCommit message (Collapse)Author
2022-12-05[ruby/did_you_mean] Do not suggest #name= for #name and vice versaMatthew Boeh
(https://github.com/ruby/did_you_mean/pull/180) * Do not suggest #name= for #name and vice versa * Avoid allocating unnecessary MatchData Co-authored-by: Jean byroot Boussier <jean.boussier+github@shopify.com> Co-authored-by: Jean byroot Boussier <jean.boussier+github@shopify.com>
2022-09-01[ruby/did_you_mean] Fixed correction duplicates in VariableNameCheckerImir Kiyamov
https://github.com/ruby/did_you_mean/commit/c3fc412f6f
2021-12-24Sync did_you_meanYuki Nishijima
2021-12-23Revert the commits for did_you_meanYuki Nishijima
This reverts commit feaf4fbc3fa16382fbd07158c448c7b5bdae78b5. This reverts commit 0d4bfbdbe1f880c712b3e60de5fce423e6096f8d. This reverts commit ac4e0978ee4358430396403065eabe1aca05784f.
2021-12-22* gems/default_gems: Sync did_you_meanYuki Nishijima
2021-12-21Revert commits for did_you_meanYuki Nishijima
This reverts commit 4560091b1c99ab33db0d653b9dd2d977fe4676d5. This reverts commit a6f76122a2395bd914daa0aa04fb5a6ce4e0c045. This reverts commit e59b18a6379c55f15ccda85c27d6997d44ef5293. This reverts commit 505dfae05d56d844ea150676edb87850a406d071.
2021-12-21* gems/default_gems: Sync did_you_meanYuki Nishijima
2021-10-22Sync did_you_mean againYuki Nishijima
2021-10-22Revert "Sync did_you_mean"Yuki Nishijima
This reverts commit e22d293e06966733e71a7fd9725eee06c03d0177.
2021-10-22Sync did_you_meanYuki Nishijima
2021-06-29Should require "rbconfig" to use RbConfigNobuyoshi Nakada
https://github.com/ruby/did_you_mean/commit/fbe5aaaae8
2020-06-06Sync did_you_meanYuki Nishijima
Notes: Merged: https://github.com/ruby/ruby/pull/3135
2020-05-12Revert "Sync did_you_mean"Nobuyoshi Nakada
This reverts commit 946dadd3f479198e87873a863d15c7660a8e2b56, which broke `TestGemRequire` and others.
2020-05-11Sync did_you_meanYuki Nishijima
2019-12-13Drop delegate dependencyYuki Nishijima
Original comment: https://github.com/ruby/did_you_mean/commit/2f26c9ee770f28da0942c42cbc9e5800535b75e1
2019-12-04Do not attempt to call methods on the receiver if it is a basic objectYuki Nishijima
2019-11-30Promote did_you_mean to default gemKevin Deisz
At the moment, there are some problems with regard to bundler + did_you_mean because of did_you_mean being a bundled gem. Since the vendored version of thor inside bundler and ruby itself explicitly requires did_you_mean, it can become difficult to load it when using Bundler.setup. See this issue: https://github.com/yuki24/did_you_mean/issues/117#issuecomment-482733159 for more details. Notes: Merged: https://github.com/ruby/ruby/pull/2689