list - 错误 "Cannot find variable `。 .`"尝试使用范围运算符时

标签 list elm

根据大部分 documentation in Elm我应该能够使用 [1..5] 获取从 1 到 5 的数字列表。但是当我在 elm-repl 中尝试时,我遇到错误:

> [1..5]
-- NAMING ERROR ---------------------------------------------- repl-temp-000.elm

Cannot find variable `..`

3|   [1..5]
      ^^^^

我也尝试导入 List 模块:

> import List exposing (..)
> [1..5]
-- NAMING ERROR ---------------------------------------------- repl-temp-000.elm

Cannot find variable `..`

4|   [1..5]
      ^^^^

我知道我可以使用 List's range function ,但我很想知道我在使用更漂亮的 .. 语法时做错了什么,或者是否在没有更新文档的情况下删除了它?

最佳答案

看起来该文档刚刚过时。 .. 范围语法在 v0.18 中被删除,以支持您提到的 List.range 功能。 Here are the release notes .

The [1..5] syntax was removed in favor of List.range. The syntax was kind of nice, but not very discoverable or commonly used. Whenever I used [1..5] in a talk, someone quite experienced would comment that they wanted something like that but could not find it in the standard libraries!

关于list - 错误 "Cannot find variable `。 .`"尝试使用范围运算符时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41754040/

相关文章:

python - 列表索引必须是整数或切片,而不是2D数组python的列表

elm - 在 Elm 中没有消息的 Cmd

list - 使用 Racket 情节线

python - 如何提取扩展名并保存而不重复?

Elm 递归类型定义

Elm:两个键盘键一起发出信号?

elm - 如何让 Elm-UI 元素响应按下 "Enter"

elm IDE(编辑器和 elm-reactor 浏览器)

c# - 寻找LINQ语法,以获取以特定内容开头的列表中的第二项

json - 将Json信息转换成F#列表