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:nthtail/1

lists:nthtail/1はリストのN+1番目から始まりリストの末尾まで続くサブリストを返します。

要素の数え方は「1、2、3ぁっダー!」です。例えば最初の要素のインデックスは1となります。

> lists:nthtail(3, [a, b, c, d, e]).
[d,e]

lists:nthtail/1tlをN回実行するものという考え方もできそうです。

> tl(tl(tl([a, b, c, d, e]))).
[d,e]

パターンマッチでも同じ答えを求めることが可能です。

> [_, _, _ | Tail] = [a, b, c, d, e].
[a,b,c,d,e]

> Tail.
[d,e]

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?