Windows List Comprehension上的Erlang乘以“ \f”。 [英] Erlang on Windows List Comprehension multiply gives "\f"

查看:70
本文介绍了Windows List Comprehension上的Erlang乘以“ \f”。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Windows上使用Erlang时遇到了一个奇怪的问题,我正在运行16B和WinXP。

Hi i have a weird problem with Erlang on Windows i am running 16B and WinXP.

我有以下代码

-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

改变成本(I)*使用-,+或除的Q给我一个数字。

changing cost(I) * Q to use -,+ or divide gives me a number.

我不知道为什么乘法在列表理解中不起作用。运行

I have no idea why multiply dosen't work in list comprehension. Running

[test:cost(I) * Q || {I,Q} <- [{orange,2}]]

在erlang控制台中emacs模式也不起作用,但

in an erlang console and emacs mode also dosen't work but

test:cost(orange) * 2

给我一​​个数字。

任何想法为什么?

推荐答案

请注意,cost / 1函数返回一个数字。但是total / 1会返回一个 list (由数字组成)。
该列表上的结果还可以,这就是erlang刚好显示小整数列表的方式。参见 http://www.erlang.org/faq/problems.html 9.3

Note your cost/1 function returns a number. But total/1 returns a list (of numbers). The results on that list are ok, this is just how erlang happens to display lists of small integers. See http://www.erlang.org/faq/problems.html 9.3

了解我的意思,尝试使用更大的数字

to see what I mean, try with larger numbers

test:total([{orange,2000}]).

同样,这只是一个显示问题,列表中的值就是您所期望的。尝试:

Again, this is just a display issue, the value in the lists are what you expect. Try it:

[Value] = test:total([{orange,2}]).
Value.

这篇关于Windows List Comprehension上的Erlang乘以“ \f”。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆