Chapter 9 Lists

「Chapter 9 Lists」の編集履歴(バックアップ)一覧に戻る

Chapter 9 Lists - (2010/10/22 (金) 20:54:55) のソース

#co(){
Chapter 9 Lists

Lists are an important data structure in many Scala programs. A list containing the elements x1 , . . . , xn is written List(x1 , ..., xn ). Examples are: 
}

* 第 9 章 リスト (Lists)

リストは多くの Scala プログラムで重要なデータ構造です。要素 x1,...,xn を含むリストは List(x1,...,xn) と書きます。例は

 val fruit = List("apples", "oranges", "pears") 
 val nums = List(1, 2, 3, 4) 
 val diag3 = List(List(1, 0, 0), List(0, 1, 0), List(0, 0, 1)) 
 val empty = List() 

#co(){
Lists are similar to arrays in languages such as C or Java, but there are also three important differences. First, lists are immutable. That is, elements of a list cannot be changed by assignment. Second, lists have a recursive structure, whereas arrays are flat. Third, lists support a much richer set of operations than arrays usually do. 
}

リストは C や Java 言語などの配列と似ていますが、3つの重要な違いがあります。第一に、リストはイミュータブル(変更不能)です。つまりリストの要素は代入によって変更できません。第二に、リストは再帰的な構造を持っていますが、配列はフラットです。第三に、リストは配列がふつう持っているよりずっと豊富な操作をサポートしています。

- [[9.1 リストの使用 >Example9.1]]
- [[9.2 リストクラスの定義1:一階メソッド >Example9.2]]
- [[9.3 例 : マージソート >Example9.3]]
- [[9.4 リストクラスの定義2:高階メソッド >Example9.4]]
- [[9.5 まとめ >Example9.5]]

#center(){[[前ページ>Example8.6]] [[ 9 章>Chapter 9 Lists]] [[目次>ScalaByExample和訳]] [[次ページ>Example9.1]]}

----
#comment
ツールボックス

下から選んでください:

新しいページを作成する
ヘルプ / FAQ もご覧ください。