Search code examples
listelm

Where are the docs of the [a..b] syntax for creating Lists in Elm?


Where could I find the definition/documentation of the [a..b] syntax for creating Lists in Elm?


Solution

  • This syntax was removed in Elm 0.18. Use List.range instead. Some examples from elm-repl:

    > List.range 1 5
    [1,2,3,4,5] : List Int
    > List.range 1 1
    [1] : List Int
    > List.range 1 0
    [] : List Int
    > List.range 1 5 |> List.map (\x -> x*2)
    [2,4,6,8,10] : List Int
    > List.range 1 5 |> List.map (\x -> x*2 - 1)
    [1,3,5,7,9] : List Int
    > let b = 5 in b |> List.range 1
    [1,2,3,4,5] : List Int
    

    Note: I have completely removed my previous answer because it was made obsolete by Elm 0.18.