Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typo3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Erlang 异常错误:无函数子句_Erlang - Fatal编程技术网

Erlang 异常错误:无函数子句

Erlang 异常错误:无函数子句,erlang,Erlang,我已经添加了现有的代码。它可以用于任何文本,我在Erlang中做了一些工作,我得到了一条错误消息,我已经包括在下面 exception error: no function clause matching string:to_lower({error,[80,75,3,4,20,0,6,0,8,0,0,0,33,0,2020], <<210,108,

我已经添加了现有的代码。它可以用于任何文本,我在Erlang中做了一些工作,我得到了一条错误消息,我已经包括在下面

exception error: no function clause matching string:to_lower({error,[80,75,3,4,20,0,6,0,8,0,0,0,33,0,2020],                                                                     <<210,108,90,1,0,0,32,5,0,0,19,0,8,2,91,67,111,110,116,
                                                                        101,110,116,95,84,121,...>>}) (string.erl, line 2084)
     in function  word_sort:readlines/1 (word_sort.erl, line 17).

unicode:字符列表返回了一些错误

变量“Content”包含错误消息而不是数据

And string:to_lower()将错误消息作为参数而不是字符串

您只需检查列表中返回的字符

readlines(FileName) ->
   io:format("~nLoading File : ~p~n", [FileName]),
   {ok, File} = file:read_file(FileName),
   case  unicode:characters_to_list(File) of
       Content when is_list(Content) ->
              LCcontent = string:to_lower(Content),
              TokenList = string:tokens(LCcontent, 
                              " .,;:!?~/>'<{}£$%^&()@-=+_[]*#\\\n\r\"0123456789"),
              main(TokenList);
       Err ->
           io:format("Cannot read file, got some unicode error ~p~n", [Err])
   end.
readlines(文件名)->
io:格式(~n加载文件:~p~n),[FileName]),
{ok,File}=File:read_File(文件名),
大小写unicode:
内容何时为列表(内容)->
LCcontent=字符串:到较低的(内容),
令牌列表=字符串:令牌(LCcontent,
" .,;:!?~/>'
io:format(“无法读取文件,出现了一些unicode错误~p~n”,[Err])
终止

tokenList
是一个atom,不是一个变量,所以用
tokenList
替换它。您使用的是哪个版本的Erlang?我使用的是Eshell V9.2,从tokenList更改为tokenList会产生相同的错误。文件的内容是什么?它是一个文本文件我使用的是Eshell V9.2,从tokenList更改为tokenList会产生相同的错误关于如何改进这些方面的建议3@RustHinges,是否记得重新编译模块?仅更改源代码是不够的。
readlines(FileName) ->
   io:format("~nLoading File : ~p~n", [FileName]),
   {ok, File} = file:read_file(FileName),
   case  unicode:characters_to_list(File) of
       Content when is_list(Content) ->
              LCcontent = string:to_lower(Content),
              TokenList = string:tokens(LCcontent, 
                              " .,;:!?~/>'<{}£$%^&()@-=+_[]*#\\\n\r\"0123456789"),
              main(TokenList);
       Err ->
           io:format("Cannot read file, got some unicode error ~p~n", [Err])
   end.