LoginSignup
0
0

More than 5 years have passed since last update.

タプル・リスト_「すごいErlangゆかいに学ぼう!」_#05

Posted at

タプル

複数の値のセット
X = 5, Y = 6.
Point = {5, 6}.

{M, _} = Point. %% 片方だけ取り出すとき

{tokyo, {tokyo, 23}}. %% atom付き、入れ子でも可

リスト

[1,2,3].

[1, 2] ++ [3, 4]. %% [1,2,3,4]
[1,2,3,4,5,6,1,2,3] -- [1,2]. %% [3,4,5,6,1,2,3]。言語によっては、全ての1,2が削除される場合もある

[1, 2, 3] -- [1, 2] -- [3]. %% [3]。右から計算するから
[1, 2, 3] -- [1, 2] -- [2]. %% [2,3]。右から計算

hd([1,2,3]). %% [1]。関数。headのこと
tl([1,2,3]). %% [2,3]。関数。tailのこと

[1 | [1,2,3]]. %% [1,1,2,3]。
[[a,b] | [c,d]] %% [[a,b],c,d] 前はまとめられる。後ろはリストが展開されるので後ろはリストであることが原則。

0
0
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
0
0