【发布时间】:2014-01-14 14:08:54
【问题描述】:
您好,我在运行 16B 和 WinXP 的 Windows 上遇到了一个奇怪的 Erlang 问题。
我有以下代码
-module(test).
-export([cost/1,total/1]).
cost(orange) ->
5;
cost(apple) ->
6.
total(L) ->
[cost(I) * Q || {I,Q} <- L].
我运行它
test:total([{orange,2}]).
它给了我 "\f"
改变 cost(I) * Q 使用 -,+ 或除法给我一个数字。
我不知道为什么乘法在列表理解中不起作用。运行
[test:cost(I) * Q || {I,Q} <- [{orange,2}]]
在 erlang 控制台和 emacs 模式下也不起作用,但是
test:cost(orange) * 2
确实给了我一个号码。
有什么想法吗?
【问题讨论】: