According to much of the documentation in Elm I should be able to use [1..5]
to get a list of numbers from 1 to 5. But when I try it in elm-repl
, I'm met with an error:
> [1..5]
-- NAMING ERROR ---------------------------------------------- repl-temp-000.elm
Cannot find variable `..`
3| [1..5]
^^^^
I tried importing the List
module as well:
> import List exposing (..)
> [1..5]
-- NAMING ERROR ---------------------------------------------- repl-temp-000.elm
Cannot find variable `..`
4| [1..5]
^^^^
I know I can use List
's range
function, but I'm curious to know what I'm doing wrong with the prettier ..
syntax or if that was removed without the documentation being updated?
Looks like that documentation is just out of date. The ..
range syntax was removed in v0.18 in favor of the List.range
function you mention. Here are the release notes.
The
[1..5]
syntax was removed in favor ofList.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!