0

有人可以向我解释为什么下面这段代码用于解决 Erlang 中的 pangram 工作吗?

139> Sentence.
"abcdefghijklmnopqrstuvwxyz"
140> lists:all(lists:seq($a, $z), fun(X) -> lists:member(X, Sentence) end).
** exception error: no function clause matching lists:all("abcdefghijklmnopqrstuvwxyz",#Fun<erl_eval.6.99386804>) (lists.erl, line 1212)
4

1 回答 1

1

您的论点顺序错误。Erlang 中大多数需要函数和术语的函数首先需要函数参数。

1> Sentence = "abcdefghijklmnopqrstuvwxyz".
"abcdefghijklmnopqrstuvwxyz"
2> lists:all(fun(X) -> lists:member(X, Sentence) end, lists:seq($a, $z)).
true
于 2018-04-22T00:40:24.900 回答