【发布时间】:2026-02-15 02:35:01
【问题描述】:
这是我的代码:
-module(test).
-export([seed_matrix2/0, take_row_and_column/4]).
seed_matrix2() ->
[0, 0, 1, 0,
4, 0, 0, 0,
0, 0, 0, 2,
0, 4, 0, 0].
take_row_and_column(R, C, AnsMatrix, SideLen) ->
RowVector = [ V || X <- lists:seq(0, SideLen-1), V <- lists:nth(R*SideLen+X, AnsMatrix) ],
ColVector = [ V || X <- lists:seq(0, SideLen-1), V <- lists:nth(X*SideLen+C, AnsMatrix) ],
{RowVector, ColVector}.
这是我调用函数test:take_row_and_column的错误信息:
74> test:take_row_and_column(1, 2, test:seed_matrix2(), 4).
** exception error: no function clause matching
test:'-take_row_and_column/4-lc$^1/1-1-'(0) (/private/tmp/test.erl, line 12)
in function test:take_row_and_column/4 (/private/tmp/test.erl, line 12)
当我传递错误数量的参数或未能满足类型保护时,我通常会得到这个。我不明白为什么这段代码会触发no function clause matching
这是erl的版本banner:
Erlang R16B03 (erts-5.10.4) [source] [64-bit] [smp:4:4] [async-threads:10] [hipe] [kernel-poll:false] [dtrace]
Eshell V5.10.4 (abort with ^G)
【问题讨论】:
标签: erlang