Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/elixir/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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/81.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
Elixir 我不明白为什么我的第一个长生不老药剧本失败了_Elixir - Fatal编程技术网

Elixir 我不明白为什么我的第一个长生不老药剧本失败了

Elixir 我不明白为什么我的第一个长生不老药剧本失败了,elixir,Elixir,我正在努力学习长生不老药 我发现这个演示语法: #--- # http://media.pragprog.com/titles/elixir16/code/spawn/pmap1.exs # Excerpted from "Programming Elixir # published by The Pragmatic Bookshelf. # Copyrights apply to this code. It may not be used to create training material

我正在努力学习长生不老药

我发现这个演示语法:

#---
# http://media.pragprog.com/titles/elixir16/code/spawn/pmap1.exs
# Excerpted from "Programming Elixir
# published by The Pragmatic Bookshelf.
# Copyrights apply to this code. It may not be used to create training material,
# courses, books, articles, and the like. Contact us if you are in doubt.
# We make no guarantees that this code is fit for any purpose.
# Visit http://www.pragmaticprogrammer.com/titles/elixir16 for more book information.
#---
defmodule Parallel do
  def pmap(collection, func) do
    collection
    |> Enum.map(&(Task.async(fn -> func.(&1) end)))
    |> Enum.map(&Task.await/1)
  end
end

result = Parallel.pmap 1..1000, &(&1 ​*​ &1)
我将上述语法放在一个文件中:pmap1.exs

接下来,我尝试使用一个简单的shell命令运行它:

dan@h78:~/elxr/public/notes $ elixir pmap1.exs
** (SyntaxError) pmap1.exs:18: unexpected token: "​" (column 38, codepoint U+200B)
    (elixir) lib/code.ex:767: Code.require_file/2
dan@h78:~/elxr/public/notes $ 
我运行得不对吗


我是否有语法错误?

由于某种原因,在您的代码示例中有两个“零宽度空格”(Unicode codepoint 200B),一个位于
*
字符的每一侧。删除两个零宽度空格后,您的代码对我来说运行良好

(您正在为
result
指定一个值,但没有打印该值或对其执行其他操作,因此它表示
警告:变量“result”未使用
,但这是下一步。
IO.inspect(result)
是一种快速执行此操作的方法。)