3
2

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:sum

sum([number]) -> number

数字のリストの総和を求めます。リストの要素が全て数字と時しか使えません。

練習してみます。

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

> lists:sum([1.0, 2, 3, 4]).
10.0

> lists:sum(["1", 2, 3, 4]).
** exception error: an error occurred when evaluating an arithmetic expression
     in operator  +/2
        called as 0 + "1"
     in call from lists:sum/2 (lists.erl, line 319)

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

Elixirにも挑戦したい

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

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?