74件ヒット
[1-74件を表示]
(0.041秒)
検索結果
先頭5件
-
Enumerator
:: Lazy # collect {|item| . . . } -> Enumerator :: Lazy (18115.0) -
Enumerable#map と同じですが、配列ではなくEnumerator::Lazy を返します。
...クを指定しなかった場合に発生します。
//emlist[例][ruby]{
1.step.lazy.map{ |n| n % 3 == 0 }
# => #<Enumerator::Lazy: #<Enumerator::Lazy: #<Enumerator: 1:step>>:map>
1.step.lazy.collect{ |n| n.succ }.take(10).force
# => [2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
//}
@see Enumerable#map... -
Enumerator
:: Lazy # map {|item| . . . } -> Enumerator :: Lazy (3015.0) -
Enumerable#map と同じですが、配列ではなくEnumerator::Lazy を返します。
...クを指定しなかった場合に発生します。
//emlist[例][ruby]{
1.step.lazy.map{ |n| n % 3 == 0 }
# => #<Enumerator::Lazy: #<Enumerator::Lazy: #<Enumerator: 1:step>>:map>
1.step.lazy.collect{ |n| n.succ }.take(10).force
# => [2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
//}
@see Enumerable#map... -
Array
# pack(template) -> String (92.0) -
配列の内容を template で指定された文字列にしたがって、 バイナリとしてパックした文字列を返します。
...されます。
また、`#' から改行あるいはテンプレート文字列の最後まではコメントとみな
され無視されます。
=== 整数のテンプレート文字のシステム依存性
各テンプレート文字の説明の中で、
short や long はシステムによら......nsigned 16bit(nと同じ)
s>: big endian int16_t
s!>: big endian signed short
l<: little endian int32_t
l!<: little endian signed long
//}
=== 各テンプレート文字の説明
説明中、Array#pack と String#unpack で違いのあるものは `/' で区切って
「Array#pack の......//emlist[][ruby]{
[""].pack("m") # => ""
["\0"].pack("m") # => "AA==\n"
["\0\0"].pack("m") # => "AAA=\n"
["\0\0\0"].pack("m") # => "AAAA\n"
["\xFF"].pack("m") # => "/w==\n"
["\xFF\xFF"].pack("m") # => "//8=\n"
["\xFF\xFF\xFF"].pack("m") # => "////\n"... -
Array
# pack(template , buffer: String . new) -> String (92.0) -
配列の内容を template で指定された文字列にしたがって、 バイナリとしてパックした文字列を返します。
...されます。
また、`#' から改行あるいはテンプレート文字列の最後まではコメントとみな
され無視されます。
=== 整数のテンプレート文字のシステム依存性
各テンプレート文字の説明の中で、
short や long はシステムによら......nsigned 16bit(nと同じ)
s>: big endian int16_t
s!>: big endian signed short
l<: little endian int32_t
l!<: little endian signed long
//}
=== 各テンプレート文字の説明
説明中、Array#pack と String#unpack で違いのあるものは `/' で区切って
「Array#pack の......//emlist[][ruby]{
[""].pack("m") # => ""
["\0"].pack("m") # => "AA==\n"
["\0\0"].pack("m") # => "AAA=\n"
["\0\0\0"].pack("m") # => "AAAA\n"
["\xFF"].pack("m") # => "/w==\n"
["\xFF\xFF"].pack("m") # => "//8=\n"
["\xFF\xFF\xFF"].pack("m") # => "////\n"... -
String
# unpack(template) -> Array (92.0) -
Array#pack で生成された文字列を テンプレート文字列 template にしたがってアンパックし、 それらの要素を含む配列を返します。
...されます。
また、`#' から改行あるいはテンプレート文字列の最後まではコメントとみな
され無視されます。
=== 整数のテンプレート文字のシステム依存性
各テンプレート文字の説明の中で、
short や long はシステムによら......nsigned 16bit(nと同じ)
s>: big endian int16_t
s!>: big endian signed short
l<: little endian int32_t
l!<: little endian signed long
//}
=== 各テンプレート文字の説明
説明中、Array#pack と String#unpack で違いのあるものは `/' で区切って
「Array#pack の......//emlist[][ruby]{
[""].pack("m") # => ""
["\0"].pack("m") # => "AA==\n"
["\0\0"].pack("m") # => "AAA=\n"
["\0\0\0"].pack("m") # => "AAAA\n"
["\xFF"].pack("m") # => "/w==\n"
["\xFF\xFF"].pack("m") # => "//8=\n"
["\xFF\xFF\xFF"].pack("m") # => "////\n"... -
Enumerable
# lazy -> Enumerator :: Lazy (20.0) -
自身を lazy な Enumerator に変換したものを返します。
...ソッドが遅延評価を行う (つまり、配列ではな
くEnumeratorを返す) ように再定義されています。
* map/collect
* flat_map/collect_concat
* select/find_all
* reject
* grep
* take, take_while
* drop, drop_while
* zip (※一貫性のため、ブロックを渡さ......t[例][ruby]{
def pythagorean_triples
(1..Float::INFINITY).lazy.flat_map {|z|
(1..z).flat_map {|x|
(x..z).select {|y|
x**2 + y**2 == z**2
}.map {|y|
[x, y, z]
}
}
}
end
# 最初の10個のピタゴラス数を表示する
p pythagorean_triples.take(10).f... -
Enumerator
:: Lazy (20.0) -
map や select などのメソッドの遅延評価版を提供するためのクラス。
...ソッドが遅延評価を行う
(つまり、配列ではなく Enumerator を返す) ように再定義されています。
* map/collect
* flat_map/collect_concat
* select/find_all
* reject
* grep
* take, take_while
* drop, drop_while
* slice_before, slice_after, slice_when
* chunk
*......、
# 巨大な配列を確保しようとしてメモリを使い切ったりはしない
open("log.txt"){|f|
f.each_line.lazy.map{|line|
Hash[line.split(/\t/).map{|s| s.split(/:/, 2)}]
}.select{|hash|
hash["req"] =~ /GET/ && hash["status"] == "200"
}.each{|hash|
p hash
}
}
//}......ソッドが遅延評価を行う
(つまり、配列ではなく Enumerator を返す) ように再定義されています。
* map/collect
* flat_map/collect_concat
* select/find_all
* reject
* grep, grep_v
* take, take_while
* drop, drop_while
* slice_before, slice_after, slice_when
*......ソッドが遅延評価を行う
(つまり、配列ではなく Enumerator を返す) ように再定義されています。
* map/collect
* flat_map/collect_concat
* filter_map
* select/find_all
* reject
* grep, grep_v
* take, take_while
* drop, drop_while
* slice_before, slice_after,...