LoginSignup
19
11

More than 5 years have passed since last update.

関数は引数の個数に応じて「unary」「binary」「ternary」などと呼ばれるらしい

Last updated at Posted at 2018-08-08

関数の引数の個数に応じて呼び名があるらしいのでまとめる。

nullary function

  • 引数の数: 0個
  • 零項関数の中には、副作用があるため出力が一定でない性質がある。
    • グローバル変数によって変わる。
    • 時刻によって変わる。time()
    • 環境によって変わる。getcwd()
  • 和訳: 0変数関数
  • カタカナ発音: ナラリー・ファンクション
  • 語源: ラテン語 nullus (「無」) + 形容詞語尾 -ary(「…に関する」)
  • 別の表現
    • 0-ary function
    • niladic function (ニラディック・ファンクション)

unary function

  • 引数の数: 1個
  • 和訳: 1変数関数
  • カタカナ発音: アーナリー・ファンクション
  • 語源: ラテン語 ūnus (「ひとつ」) + -ary
  • 1つの項をとる演算子はunary operator(単項演算子)という。
  • 別の表現
    • monadic function (モナディック・ファンクション)

binary function

  • 引数の数: 2個
  • 和訳: 2変数関数
  • カタカナ発音: バイナリー・ファンクション
  • 語源: ラテン語 bīnārius (「二個からなる」) + -ary
  • 2つの項をとる演算子はbinary operator(二項演算子)という。
    • 代数演算子の加算: $x + $y
    • ビット演算子のビット積: $x & $y
    • 論理演算子の論理積: $x && $y
    • 型演算子: $x instanceof Class
    • Null合体演算子: $x ?? $y
    • エルビス演算子: $x ?: $y
  • 別の表現
    • dyadic function (ダイアディック・ファンクション)

ternary function

  • 引数の数: 3個
  • 和訳: 3変数関数
  • カタカナ発音: ターナリー・ファンクション
  • 語源: ラテン語 ternarius (「三個からなる」) + -ary
  • 2つの項をとる演算子はternary operator(三項演算子)という。
    • 条件演算子: $x ? $y : $z
  • 別の表現
    • triadic function (トライアディック・ファンクション)

2つ以上、可変長など

  • 2つ以上を総じて: n-ary, multiary, polyadic
  • 可変長引数: variable arity, variadic

所感

19
11
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
19
11