【发布时间】:2019-02-19 18:04:19
【问题描述】:
我正在努力学习 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,
# 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 $
我是不是运行不正确?
我在某处有语法错误吗?
【问题讨论】:
标签: elixir