ライブラリ
- ビルトイン (215)
- openssl (12)
- pp (12)
- prettyprint (24)
-
rubygems
/ requirement (12) - tsort (93)
クラス
-
Gem
:: Requirement (12) - Method (12)
-
OpenSSL
:: SSL :: SSLContext (12) - PP (12)
- PrettyPrint (24)
- Proc (108)
- Symbol (4)
- Thread (24)
キーワード
-
1
. 6 . 8から1 . 8 . 0への変更点(まとめ) (12) - === (12)
-
NEWS for Ruby 2
. 1 . 0 (12) -
NEWS for Ruby 2
. 2 . 0 (11) -
NEWS for Ruby 2
. 7 . 0 (6) -
NEWS for Ruby 3
. 0 . 0 (5) - OPS (12)
- Proc (12)
- Rubyで使われる記号の意味(正規表現の複雑な記号は除く) (12)
- [] (18)
-
add
_ trace _ func (12) - arity (12)
- call (12)
- curry (24)
-
each
_ strongly _ connected _ component (23) -
each
_ strongly _ connected _ component _ from (23) - format (12)
- irb (12)
- lambda? (12)
- parameters (12)
- proc (19)
-
rb
_ f _ lambda (12) -
renegotiation
_ cb= (12) -
ruby 1
. 9 feature (12) - seplist (12)
-
set
_ trace _ func (24) -
singleline
_ format (12) -
strongly
_ connected _ components (12) -
to
_ proc (16) - tsort (12)
-
tsort
_ each (23) - yield (12)
- オブジェクト指向スクリプト言語 Ruby リファレンスマニュアル (12)
- メソッド呼び出し(super・ブロック付き・yield) (12)
- 手続きオブジェクトの挙動の詳細 (12)
検索結果
先頭5件
-
Proc
# yield(*arg) -> () (24.0) -
手続きオブジェクトを実行してその結果を返します。
...て異なります。
詳しくは Proc#lambda? を参照してください。
「===」は when の所に手続きを渡せるようにするためのものです。
//emlist[例][ruby]{
def sign(n)
case n
when lambda{|n| n > 0} then 1
when lambda{|n| n < 0} then -1
else 0
end
end
p si......gn(-4) #=> -1
p sign(0) #=> 0
p sign(7) #=> 1
//}
また、以下のような syntactic sugar もあります。
//emlist[例][ruby]{
fib = lambda{|n|
case n
when 0 then 0
when 1 then 1
else
fib.(n - 2) + fib.(n - 1)
end
}
fib.(10) # => 55
//}
@param arg 手続きオブジェク... -
TSort
. each _ strongly _ connected _ component(each _ node , each _ child) -> Enumerator (24.0) -
TSort.strongly_connected_components メソッドのイテレータ版です。
...de = lambda {|&b| g.each_key(&b) }
each_child = lambda {|n, &b| g[n].each(&b) }
TSort.each_strongly_connected_component(each_node, each_child) {|scc| p scc }
# => [4]
# [2]
# [3]
# [1]
g = {1=>[2], 2=>[3, 4], 3=>[2], 4=>[]}
each_node = lambda {|&b| g.each_key(&b) }
each_child = lambda {|n... -
TSort
. each _ strongly _ connected _ component(each _ node , each _ child) {|nodes| . . . } -> nil (24.0) -
TSort.strongly_connected_components メソッドのイテレータ版です。
...de = lambda {|&b| g.each_key(&b) }
each_child = lambda {|n, &b| g[n].each(&b) }
TSort.each_strongly_connected_component(each_node, each_child) {|scc| p scc }
# => [4]
# [2]
# [3]
# [1]
g = {1=>[2], 2=>[3, 4], 3=>[2], 4=>[]}
each_node = lambda {|&b| g.each_key(&b) }
each_child = lambda {|n... -
TSort
. strongly _ connected _ components(each _ node , each _ child) -> Array (24.0) -
強連結成分の集まりを配列の配列として返します。 この配列は子から親に向かってソートされています。 各要素は強連結成分を表す配列です。
...4=>[]}
each_node = lambda {|&b| g.each_key(&b) }
each_child = lambda {|n, &b| g[n].each(&b) }
p TSort.strongly_connected_components(each_node, each_child)
# => [[4], [2], [3], [1]]
g = {1=>[2], 2=>[3, 4], 3=>[2], 4=>[]}
each_node = lambda {|&b| g.each_key(&b) }
each_child = lambda {|n, &b| g[n].eac... -
TSort
. tsort(each _ node , each _ child) -> Array (24.0) -
頂点をトポロジカルソートして得られる配列を返します。 この配列は子から親に向かってソートされています。 すなわち、最初の要素は子を持たず、最後の要素は親を持ちません。
...[4], 3=>[2, 4], 4=>[]}
each_node = lambda {|&b| g.each_key(&b) }
each_child = lambda {|n, &b| g[n].each(&b) }
p TSort.tsort(each_node, each_child) # => [4, 2, 3, 1]
g = {1=>[2], 2=>[3, 4], 3=>[2], 4=>[]}
each_node = lambda {|&b| g.each_key(&b) }
each_child = lambda {|n, &b| g[n].each(&b) }
p TSort.... -
NEWS for Ruby 2
. 1 . 0 (18.0) -
NEWS for Ruby 2.1.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。
...TypeError を発生させるようになりました。
* Proc
* Returning from lambda proc now always exits from the Proc, not from the
method where the lambda is created. Returning from non-lambda proc exits
from the method, same as the former behavior.
* String
* 以... -
NEWS for Ruby 2
. 7 . 0 (18.0) -
NEWS for Ruby 2.7.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。
...rning: `_1' is reserved for numbered parameter; consider another name
[1].each { p _1 } # prints 0 instead of 1
==== ブロックなしの proc/lambda が deprecated
* ブロック付きで呼び出されたメソッドの中で、ブロックなしでProc.newやKernel#procを
呼び出す......い。
* ブロック付きで呼び出されたメソッドの中で、Kernel#lambdaをブロックなしで呼び出すと
例外が発生するようになりました。
//emlist[][ruby]{
def bar
lambda
end
bar { puts "Hello" } #=> tried to create Proc object without a block (ArgumentE... -
NEWS for Ruby 3
. 0 . 0 (18.0) -
NEWS for Ruby 3.0.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。
...* Kernel#eval when called with two arguments will use `"(eval)"` for `__FILE__` and `1` for `__LINE__` in the evaluated code. 4352
* Kernel#lambda now warns if called without a literal block. 15973
* Kernel.sleep invokes the scheduler hook `#kernel_sleep(...)` in a non-blocking execution......ucc / String#next
* String#swapcase
* String#tr
* String#tr_s
* String#upcase
* Symbol
* Symbol#to_proc now returns a lambda Proc. 16260
* Symbol#name has been added, which returns the name of the symbol if it is named. The returned string is frozen. 16150
* Fi......}
* EXPERIMENTAL: Hash#each consistently yields a 2-element array. 12706
* Now `{ a: 1 }.each(&->(k, v) { })` raises an ArgumentError due to lambda's arity check.
* When writing to STDOUT redirected to a closed pipe, no broken pipe error message will be shown now. 14413
* `TRUE`/`FALSE`/... -
NEWS for Ruby 2
. 2 . 0 (12.0) -
NEWS for Ruby 2.2.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。
...or は発生しなくなりました。
* ArgumentError is no longer raised when lambda Proc is passed as a
block, and the number of yielded arguments does not match the formal
arguments of the lambda, if just an array is yielded and its length
matches.
* Process
* Proce... -
Proc
# curry -> Proc (12.0) -
Procをカリー化します
...p b.curry[1, 2][3, 4] #=> 10
p b.curry(5)[1][2][3][4][5] #=> 15
p b.curry(5)[1, 2][3, 4][5] #=> 15
p b.curry(1)[1] #=> 1
b = lambda {|x, y, z| (x||0) + (y||0) + (z||0) }
p b.curry[1][2][3] #=> 6
p b.curry[1, 2][3, 4] #=> wrong number of arguments (given 4, exp......#=> wrong number of arguments (given 5, expected 3)
p b.curry(1) #=> wrong number of arguments (given 1, expected 3)
b = lambda {|x, y, z, *w| (x||0) + (y||0) + (z||0) + w.sum }
p b.curry[1][2][3] #=> 6
p b.curry[1, 2][3, 4] #=> 10
p b.curry(5)[1][2][3][4]...