参考:1.http://www.cnblogs.com/me-sa/archive/2012/03/20/erlang0047.html
2.http://www.erlang.org/doc/reference_manual/data_types.html
erlang中类型的转换,原因是在看编译并运行程序一章时,考虑到命令行给erl传值时的不识别问题。
a)命令行通过如下形式传参
$-s M F A
A传入的是一个参数列表,即若调用:$ -s M F 4 5 形式时,传入参数列表为['4', '5'],并且注意这里列表的元素是原子,在使用时不能直接应用其字面值。而需要将对应参数用atom_to_list(),然后再用list_to_integer()函数来得到字面数值。
注意:
integer_to_list(Integer, Base) -> string()
Types:
Integer = integer()
Base = 2..36
Returns a string which corresponds to the text representation of Integer in base Base.
list_to_integer(String, Base) -> integer()
Types:
String = string()
Base = 2..36
Returns an integer whose text representation in base Base is String.
本文详细介绍了Erlang编程语言中类型转换的过程及注意事项,包括如何通过命令行传参时解决不识别问题,使用atom_to_list()和list_to_integer()函数进行参数转换,并解释了integer_to_list()和list_to_integer()函数的使用方法。

被折叠的 条评论
为什么被折叠?



