max

def setup
  background(220)
  numArray = [2, 1, 5, 4, 9, 8]
  fill(0)
  noStroke
  text('Array Elements', 0, 10)
  # Draw all numbers in the array
  spacing = 15;
  elemsY = 25;
  (0...numArray.length).each do |i|
    text(numArray[i], i * spacing, elemsY)
  end
  x = 33
  y = 80
  # Draw the Maximum value in the array.
  textSize(32);
  text(max(numArray), x, y);
end

p5.jsリファレンス(参考情報)

[p5.js] max

概要

一連の数値の最大値を求めます。

書式

max(n0, n1)
max(nums)

引数

引数名内容備考オプションデフォルト値
n0比較対象の数値
n1比較対象の数値
nums数値の配列

戻値

最大値

備考

関連