るりまサーチ

最速Rubyリファレンスマニュアル検索!
82件ヒット [1-82件を表示] (0.087秒)
トップページ > クエリ:p[x] > クエリ:<[x] > クエリ:lazy[x]

別のキーワード

  1. openssl p
  2. openssl p=
  3. fileutils mkdir_p
  4. dsa p
  5. rsa p

ライブラリ

クラス

モジュール

検索結果

Enumerable#lazy -> Enumerator::Lazy (18272.0)

自身を lazy な Enumerator に変換したものを返します。

...自身を lazy な Enumerator に変換したものを返します。

この Enumerator は、以下のメソッドが遅延評価を行う (つまり、配列ではな
くEnumeratorを返す) ように再定義されています。

* map/collect
* flat_map/collect_concat
* select/find_all
*...
...reject
* grep
* take, take_while
* drop, drop_while
* zip (※一貫性のため、ブロックを渡さないケースのみlazy)
* cycle (※一貫性のため、ブロックを渡さないケースのみlazy)

以下はピタゴラス数 (a**2 + b**2 = c**2 を満たす自然数 a, b, c の...
...数を表示する
p
pythagorean_triples.take(10).force # takeはlazyなので、forceが必要です
p
pythagorean_triples.first(10) # firstはeagerです
# 100より小さいピタゴラス数を表示する
p
pythagorean_triples.take_while { |*, z| z < 100 }.force
//}

@see Enumerator::Lazy...

Enumerator::Lazy#drop_while {|item| ... } -> Enumerator::Lazy (9253.0)

Enumerable#drop_while と同じですが、配列ではなくEnumerator::Lazy を返します。

...Enumerable#drop_while と同じですが、配列ではなくEnumerator::Lazy を返します。

//emlist[例][ruby]{
1.step.lazy.drop_while { |i| i < 42 }
# => #<Enumerator::Lazy: #<Enumerator::Lazy: #<Enumerator: 1:step>>:drop_while>

1.step.lazy.drop_while { |i| i < 42 }.take(10).force
# => [42...
..., 43, 44, 45, 46, 47, 48, 49, 50, 51]
//}

@see Enumerable#drop_while...

Enumerator::Lazy#enum_for(method = :each, *args) -> Enumerator::Lazy (3180.0)

Object#to_enum と同じですが、Enumerator::Lazy を返します。

...or::Lazy を返します。

to_enum は「ブロック付きで呼ぶとループを実行し、ブロックを省略した場合は
Enumerator を返す」ようなメソッドを定義するときによく使われます。
このときに lazy 性が正しく引き継がれるように、Lazy#to...
...Enumerator ではなく Enumerator::Lazy を返すようになっています。

//emlist[例][ruby]{
module Enumerable
# 要素をn回ずつ繰り返すメソッド
# 例:[1,2,3].repeat(2) #=> [1,1,2,2,3,3]
def repeat(n)
raise ArgumentError if n < 0
if block_given?
each do |...
...al }
end
else
to_enum(:repeat, n)
end
end
end

r = 1..10
p
r.map{|n| n**2}.repeat(2).first(5)
#=> [1, 1, 4, 4, 9]

r = 1..Float::INFINITY
p
r.lazy.map{|n| n**2}.repeat(2).first(5)
#=> [1, 1, 4, 4, 9]

# Lazy#to_enum のおかげで、repeat の返り値は
# もとが Enumerato...

Enumerator::Lazy#enum_for(method = :each, *args) {|*args| block} -> Enumerator::Lazy (3180.0)

Object#to_enum と同じですが、Enumerator::Lazy を返します。

...or::Lazy を返します。

to_enum は「ブロック付きで呼ぶとループを実行し、ブロックを省略した場合は
Enumerator を返す」ようなメソッドを定義するときによく使われます。
このときに lazy 性が正しく引き継がれるように、Lazy#to...
...Enumerator ではなく Enumerator::Lazy を返すようになっています。

//emlist[例][ruby]{
module Enumerable
# 要素をn回ずつ繰り返すメソッド
# 例:[1,2,3].repeat(2) #=> [1,1,2,2,3,3]
def repeat(n)
raise ArgumentError if n < 0
if block_given?
each do |...
...al }
end
else
to_enum(:repeat, n)
end
end
end

r = 1..10
p
r.map{|n| n**2}.repeat(2).first(5)
#=> [1, 1, 4, 4, 9]

r = 1..Float::INFINITY
p
r.lazy.map{|n| n**2}.repeat(2).first(5)
#=> [1, 1, 4, 4, 9]

# Lazy#to_enum のおかげで、repeat の返り値は
# もとが Enumerato...

Enumerator::Lazy#to_enum(method = :each, *args) -> Enumerator::Lazy (3180.0)

Object#to_enum と同じですが、Enumerator::Lazy を返します。

...or::Lazy を返します。

to_enum は「ブロック付きで呼ぶとループを実行し、ブロックを省略した場合は
Enumerator を返す」ようなメソッドを定義するときによく使われます。
このときに lazy 性が正しく引き継がれるように、Lazy#to...
...Enumerator ではなく Enumerator::Lazy を返すようになっています。

//emlist[例][ruby]{
module Enumerable
# 要素をn回ずつ繰り返すメソッド
# 例:[1,2,3].repeat(2) #=> [1,1,2,2,3,3]
def repeat(n)
raise ArgumentError if n < 0
if block_given?
each do |...
...al }
end
else
to_enum(:repeat, n)
end
end
end

r = 1..10
p
r.map{|n| n**2}.repeat(2).first(5)
#=> [1, 1, 4, 4, 9]

r = 1..Float::INFINITY
p
r.lazy.map{|n| n**2}.repeat(2).first(5)
#=> [1, 1, 4, 4, 9]

# Lazy#to_enum のおかげで、repeat の返り値は
# もとが Enumerato...

絞り込み条件を変える

Enumerator::Lazy#to_enum(method = :each, *args) {|*args| block} -> Enumerator::Lazy (3180.0)

Object#to_enum と同じですが、Enumerator::Lazy を返します。

...or::Lazy を返します。

to_enum は「ブロック付きで呼ぶとループを実行し、ブロックを省略した場合は
Enumerator を返す」ようなメソッドを定義するときによく使われます。
このときに lazy 性が正しく引き継がれるように、Lazy#to...
...Enumerator ではなく Enumerator::Lazy を返すようになっています。

//emlist[例][ruby]{
module Enumerable
# 要素をn回ずつ繰り返すメソッド
# 例:[1,2,3].repeat(2) #=> [1,1,2,2,3,3]
def repeat(n)
raise ArgumentError if n < 0
if block_given?
each do |...
...al }
end
else
to_enum(:repeat, n)
end
end
end

r = 1..10
p
r.map{|n| n**2}.repeat(2).first(5)
#=> [1, 1, 4, 4, 9]

r = 1..Float::INFINITY
p
r.lazy.map{|n| n**2}.repeat(2).first(5)
#=> [1, 1, 4, 4, 9]

# Lazy#to_enum のおかげで、repeat の返り値は
# もとが Enumerato...

NEWS for Ruby 2.7.0 (150.0)

NEWS for Ruby 2.7.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。

...b, *c]]
p
a #=> 0
p
b #=> 1
p
c #=> [2, 3]
end
//}

//emlist[][ruby]{
case {a: 0, b: 1}
in {a: 0, x: 1}
:unreachable
in {a: 0, b: var}
p
var #=> 1
end
//}

//emlist[][ruby]{
case -1
in 0 then :unreachable
in 1 then :unreachable
end #=> NoMatchingPatternError
//}

//emlist{
json = <<END
{...
....parse(json, symbolize_names: true) in {name: "Alice", children: [{name: name, age: age}]}

p
name #=> "Bob"
p
age #=> 2

JSON.parse(json, symbolize_names: true) in {name: "Alice", children: [{name: "Charlie", age: age}]}
#=> NoMatchingPatternError
//}

* 詳細は https://speakerdeck.com/k_tsj/p...
...るための
Enumerator.produceメソッドが追加されました。 14781
* lazy enumerator から lazy ではない enumerator を生成する
Enumerator::Lazy#eagerメソッドが追加されました。 15901
* Enumerator::Yielder#to_procメソッドが追加され...

NEWS for Ruby 3.1.0 (54.0)

NEWS for Ruby 3.1.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。

...7411

//emlist{
P
rime.each_cons(2).lazy.find_all{_1 in [n, ^(n + 2)]}.take(3).to_a
#=> [[3, 5], [5, 7], [11, 13]]
//}

* ピン演算子がインスタンス変数、クラス変数、グローバル変数をサポートしました。 17724

//emlist{
@n = 5
P
rime.each_cons(2).lazy.find{_1 in [n,...
...7592

* 1行のメソッド定義が括弧なしで書けるようになりました。例として def foo = puts "Hello" と記述できるようになりました。 private def foo = puts "Hello" はパースされないことに注意してください。 17398

== コマンドラインオプ...
...//emlist[Class#subclasses][ruby]{
class A; end
class B < A; end
class C < B; end
class D < A; end
A.subclasses #=> [D, B]
B.subclasses #=> [C]
C.subclasses #=> []
//}

* Enumerable
* 新規メソッド
* Enumerable#compactが追加されました。 17312
* Enumerable#ta...

NEWS for Ruby 2.4.0 (42.0)

NEWS for Ruby 2.4.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。

...い。

== 2.3.0 以降の変更

=== 言語仕様の変更

* 条件式での多重代入ができるようになりました 10617
* Symbol#to_proc でメソッド呼び出し元での Refinements が有効になりました 9451
* Object#send や BasicObject#__send__ でメソッドを呼...
...Comparable#clamp を追加 10594

* Dir
* Dir.empty? を追加 10121

* Enumerable
* Enumerable#chunk ブロックを省略した場合 Enumerator を返すようになりました。2172
* Enumerable#sum を追加 12217
* Enumerable#uniq を追加 11090

* Enumerator::Lazy...
...* liberal_parsing オプションを追加 11839

* ipaddr
* IPAddr#==, IPAddr#<=> で引数のオブジェクトを IPAddr に変換する処理に失敗しても例外が発生しなくなりました
12799

* irb
* Binding#irb binding.pryと同じようにREPLのセッシ...