3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

口で言うより行うことがErlang習得への近道と信じています。

lists:flatten/1

入れ子になったリストを平坦化した新しいリストを返します。

> lists:flatten([1, [[2], 3]]).
[1,2,3]

> lists:flatten([[], [[], []]]).
[]

lists:flatten/2

入れ子になったリスト(第一引数)を平坦化したリストに別のリスト(第二引数)を末尾に追加することができます。追加されるリストは平坦化されません。平坦化されるのは第一引数のリストだけです。

> lists:flatten([1, [[2], 3]], [4, 5]).
[1,2,3,4,5]

> lists:flatten([1, [], 2], [3, [], 4]).
[1,2,3,[],4]

listsモジュールには他にもリスト処理のための関数がたくさんあります。

Elixirにも挑戦したい

闘魂ElixirシリーズとElixir Schoolがオススメです。

3
1
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
3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?