Erlang新手請教錯誤問題

23 views
Skip to first unread message

Greg Lin

unread,
May 1, 2015, 12:13:56 AM5/1/15
to erlang...@googlegroups.com
各位好,
小弟初學Erlang,一開始就遇到一些問題,但自己卻看不出錯誤在哪,想請有點經驗的人幫小弟看看以下的code問題出在哪裏,感謝!
compile時錯誤碼為:
tut7.erl:8: syntax error before: ';'
tut7.erl:4: function convert_list_to_c/1 undefined

%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-module(tut7).
-export([format_temps/1]).
format_temps(City_list)->
        Convert_List = convert_list_to_c(City_list),
        print_list(Convert_List).
convert_list_to_c([{Name, {f, F}}| Rest])->
        Convert_City=[{Name, {c, (F -32)*5 / 9}},
        [Convert_City | convert_list_to_c(Rest)];
convert_list_to_c([City | Rest])->
        [City | convert_list_to_c(Rest)];
convert_list_to_c([])->
        [].
print_list([{Name, {c, Degree}}| Rest])->
        io:format("~-15w ~w c~n", [Name, Degree]),
        print_list(Rest);
print_list([])->
        ok.
%%%%%%%%%%%%%%%%%%%%%%%%%%%

Shian

unread,
May 27, 2015, 12:51:41 AM5/27/15
to erlang...@googlegroups.com

多了一個 "["


On Friday, May 1, 2015 at 12:13:56 PM UTC+8, Greg Lin wrote:
各位好,
小弟初學Erlang,一開始就遇到一些問題,但自己卻看不出錯誤在哪,想請有點經驗的人幫小弟看看以下的code問題出在哪裏,感謝!
compile時錯誤碼為:
tut7.erl:8: syntax error before: ';'
tut7.erl:4: function convert_list_to_c/1 undefined

%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-module(tut7).
-export([format_temps/1]).
format_temps(City_list)->
        Convert_List = convert_list_to_c(City_list),
        print_list(Convert_List).
convert_list_to_c([{Name, {f, F}}| Rest])->
        Convert_City=[{Name, {c, (F -32)*5 / 9}}, %多了一個 "["
Reply all
Reply to author
Forward
0 new messages