什么是“头失配”编译器错误是什么意思? [英] What does the "head mismatch" compiler error mean?

查看:382
本文介绍了什么是“头失配”编译器错误是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试编写打印Z字符的代码。

I tries to write code to print Z character.

zzzzzzz
     z
    z
   z
  z
 z
zzzzzzz

但是当我编译这个代码throws

But when I compile this code, it throws

D:\erlang\graphics>erlc zeez2.erl
d:/erlang/graphics/zeez2.erl:19: head mismatch
d:/erlang/graphics/zeez2.erl:6: function zeez/3 undefined


b $ b

我无法修复此错误。我没有发现什么错在我的能。

请建议我。

谢谢。

I can't fixed this error. I didn't find what wrong in my could.
Does one please suggest me.
Thank you.

-module(zeez2).
-export([main/0]).

main() ->
    L = 8,
    zeez( false ,1, L). % line 6

zeez(true, M,M) ->
    init:stop();

zeez(false, M, N) ->
    io:format("~p~n", [zeez(z, N-M)] ),
    zeez(M rem N =:= 0, M + 1, N );

zeez(true, M, N) ->
    io:format("~p~n", [zeez(space, N-M)] ), % line 16
    zeez(M rem N =:= 0, M + 1 , N );

zeez(space, M) ->
    io:format("~p~n", ["-" ++ zeez(space, M-1)] );

zeez(space, 0) ->
    "Z";

zeez(z, M) ->
    io:format("~p~n", ["Z" ++ zeez(z, M-1)] );

zeez(z,0) ->
    "Z".


推荐答案

问题是你混淆了2个函数:

the problem is that you have mixed up 2 functions:

zeez / 2和zeez / 3

zeez/2 and zeez/3

如果您终止zeez / full stop not a semi-colon it should compile:

If you terminate the zeez/3 function by ending it with a full stop not a semi-colon it should compile:

zeez(true, M, N) ->
    io:format("~p~n", [zeez(space, N-M)] ), % line 16
    zeez(M rem N =:= 0, M + 1 , N );                      <-- should end with .

错误信息表示,'hey我在zeez / 3, -arity clause,wtf?'

The error message means, 'hey I'm in zeez/3 and you have thrown in a 2-arity clause, wtf?'

这篇关于什么是“头失配”编译器错误是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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