Compiler errors Elixir-无法在匹配内调用远程函数

Compiler errors Elixir-无法在匹配内调用远程函数,compiler-errors,pattern-matching,elixir,Compiler Errors,Pattern Matching,Elixir,我正在做一个关于exercism的练习,但我不明白为什么会出现以下错误: (CompileError) anagram.exs:19: cannot invoke remote function String.codepoints/1 inside match (stdlib) lists.erl:1353: :lists.mapfoldl/3 (stdlib) lists.erl:1353: :lists.mapfoldl/3 我想我并没有像我想的那样理解模式匹配,因为我不太理解如何在匹配中

我正在做一个关于exercism的练习,但我不明白为什么会出现以下错误:

(CompileError) anagram.exs:19: cannot invoke remote function String.codepoints/1 inside match
(stdlib) lists.erl:1353: :lists.mapfoldl/3
(stdlib) lists.erl:1353: :lists.mapfoldl/3
我想我并没有像我想的那样理解模式匹配,因为我不太理解如何在匹配中调用远程函数。以下是上下文测试套件的几个示例:

defmodule AnagramTest do
  use ExUnit.Case

test "no matches" do
  matches = Anagram.match "diaper", ["hello", "world", "zombies", "pants"]
  assert matches == []
end

test "detect simple anagram" do
  matches = Anagram.match "ant", ["tan", "stand", "at"]
  assert matches == ["tan"]
end
这是我的密码:

defmodule Anagram do
  @doc """
  Returns all candidates that are anagrams of, but not equal to, 'base'.
  """
  @spec match(String.t, [String.t]) :: [String.t]
  def match(base, candidates) do
    base
    |> String.codepoints
    |> Enum.sort
    |> scan_for_matches(candidates)
  end

  defp scan_for_matches(base, candidates) do
    Enum.scan candidates, [], &(if analyze(&1, base), do: &2 ++ &1)
  end

  defp analyze(candidate, base) do
    candidate
    |> String.codepoints
    |> Enum.sort
    |> match?(base)
  end

  defp match?(candidate, base) do
    candidate == base
  end
end

我不是只是将变量传递给
analyze/2
函数,以便它最终返回
布尔值吗?我很欣赏你的见解

这确实需要一个答案,所以我想我会把它加进去<代码>匹配?/2
是默认情况下从
内核导出的函数。您可以通过
import内核覆盖默认导入,除了:[match?:2]

我认为问题出在
match?/2
函数中,我没有试图在代码中找到任何其他错误,但是如果我将该函数更改为其他函数,它会被编译。“一定是有什么保留,”迈克尔,就是这样。谢谢你的帮助。如果你想把它作为一个答案,我会给你的信用。