2
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 ── 17. lists:foreach

Last updated at Posted at 2023-01-09

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

lists:foreach

foreach(fun((term) -> term), [term]) -> ok
foreach(各要素に対して実行したい処理, リスト) -> ok

リストの各要素に対して一度ずつ同じ処理を実行することができます。

練習してみます。

> lists:foreach(fun(S) -> io:put_chars([S, $\n]) end, ["1", "2", "3", "ダー!"]).
1
2
3
ダー!
ok

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

他にもいくつか反復処理をする方法があります。

Elixirにも挑戦したい

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

2
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
2
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?