44件ヒット [1-44件を表示] （0.186秒）
トップページ > > :to_a > > :max_by

## 検索結果

### Enumerable#max_by -> Enumerator (18167.0)

...erable#max と Enumerable#max_by

ブロックを省略した場合は Enumerator を返します。

@param n 取得する要素数。

//emlist[例][ruby]{
a = %w(albatross dog horse)
a.max_by # =>...
..."horse"]:max_by>
a.max_by { |x| x.length } # => "albatross"
//}

//emlist[例][ruby]{
a = %w[albatross dog horse]
a.max_by(2) # => #<Enumerator: ["albatross", "dog", "horse"]:max_by(2)>
a.max_by(2) {|x| x.length } # => ["albatross", "horse"]
//}

//emlist[例: enum.max_by（n）...
...ith a reservoir
# Information Processing Letters
# Volume 97, Issue 5 (16 March 2006)
def wsample(n)
self.max_by(n) {|v| rand ** (1.0/yield(v)) }
end
end
e = (-20..20).to_a*10000
a = e.wsample(20000) {|x|
Math.exp(-(x/5.0)**2) # normal distribution
}
# a is 20000 samples from e.
p a.le...

### Enumerable#max_by {|item| ... } -> object | nil (18167.0)

...erable#max と Enumerable#max_by

ブロックを省略した場合は Enumerator を返します。

@param n 取得する要素数。

//emlist[例][ruby]{
a = %w(albatross dog horse)
a.max_by # =>...
..."horse"]:max_by>
a.max_by { |x| x.length } # => "albatross"
//}

//emlist[例][ruby]{
a = %w[albatross dog horse]
a.max_by(2) # => #<Enumerator: ["albatross", "dog", "horse"]:max_by(2)>
a.max_by(2) {|x| x.length } # => ["albatross", "horse"]
//}

//emlist[例: enum.max_by（n）...
...ith a reservoir
# Information Processing Letters
# Volume 97, Issue 5 (16 March 2006)
def wsample(n)
self.max_by(n) {|v| rand ** (1.0/yield(v)) }
end
end
e = (-20..20).to_a*10000
a = e.wsample(20000) {|x|
Math.exp(-(x/5.0)**2) # normal distribution
}
# a is 20000 samples from e.
p a.le...

### Enumerable#max_by(n) -> Enumerator (18167.0)

...erable#max と Enumerable#max_by

ブロックを省略した場合は Enumerator を返します。

@param n 取得する要素数。

//emlist[例][ruby]{
a = %w(albatross dog horse)
a.max_by # =>...
..."horse"]:max_by>
a.max_by { |x| x.length } # => "albatross"
//}

//emlist[例][ruby]{
a = %w[albatross dog horse]
a.max_by(2) # => #<Enumerator: ["albatross", "dog", "horse"]:max_by(2)>
a.max_by(2) {|x| x.length } # => ["albatross", "horse"]
//}

//emlist[例: enum.max_by（n）...
...ith a reservoir
# Information Processing Letters
# Volume 97, Issue 5 (16 March 2006)
def wsample(n)
self.max_by(n) {|v| rand ** (1.0/yield(v)) }
end
end
e = (-20..20).to_a*10000
a = e.wsample(20000) {|x|
Math.exp(-(x/5.0)**2) # normal distribution
}
# a is 20000 samples from e.
p a.le...

### Enumerable#max_by(n) {|item| ... } -> Array (18167.0)

...erable#max と Enumerable#max_by

ブロックを省略した場合は Enumerator を返します。

@param n 取得する要素数。

//emlist[例][ruby]{
a = %w(albatross dog horse)
a.max_by # =>...
..."horse"]:max_by>
a.max_by { |x| x.length } # => "albatross"
//}

//emlist[例][ruby]{
a = %w[albatross dog horse]
a.max_by(2) # => #<Enumerator: ["albatross", "dog", "horse"]:max_by(2)>
a.max_by(2) {|x| x.length } # => ["albatross", "horse"]
//}

//emlist[例: enum.max_by（n）...
...ith a reservoir
# Information Processing Letters
# Volume 97, Issue 5 (16 March 2006)
def wsample(n)
self.max_by(n) {|v| rand ** (1.0/yield(v)) }
end
end
e = (-20..20).to_a*10000
a = e.wsample(20000) {|x|
Math.exp(-(x/5.0)**2) # normal distribution
}
# a is 20000 samples from e.
p a.le...