Elm Exactly
Results / elm-core /

ListMapTemplateOrderTest

elm-0.19.1 passelm-0.19.2 passelm-0.19.3 passlamdera-1.5.0 pass
Checks that `List.map` with a callback that calls `Debug.log` logs the elements
from last to first.

elm/core defines `List.map` with `List.foldr`, which, on a list this short,
applies the callback to the last element first. Mapping
`\x -> Debug.log "m" x` over `["a", "b", "c", "d", "e"]` therefore logs `"e"`
through `"a"` in that order, and the mapped list keeps all five elements.

Results

elm-0.19.1

passran in 76 ms
Output
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.1/optimize for better performance and smaller assets.
m: "e"
m: "d"
m: "c"
m: "b"
m: "a"
len: 5

elm-0.19.2

passran in 76 ms
Output
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.2/optimize for better performance and smaller assets.
m: "e"
m: "d"
m: "c"
m: "b"
m: "a"
len: 5

elm-0.19.3

passran in 76 ms
Output
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.3/optimize for better performance and smaller assets.
m: "e"
m: "d"
m: "c"
m: "b"
m: "a"
len: 5

lamdera-1.5.0

passran in 90 ms
Output
m: "e"
m: "d"
m: "c"
m: "b"
m: "a"
len: 5

Discussions

Discuss this test·Search the discussions on GitHub

Discussions are on GitHub; one about this test has [t:elm-core/ListMapTemplateOrderTest] in its title.

Source

The -- CHECK: lines give the expected output.

module ListMapTemplateOrderTest exposing (main)
{-| Checks that `List.map` with a callback that calls `Debug.log` logs the elements
from last to first.
elm/core defines `List.map` with `List.foldr`, which, on a list this short,
applies the callback to the last element first. Mapping
`\x -> Debug.log "m" x` over `["a", "b", "c", "d", "e"]` therefore logs `"e"`
through `"a"` in that order, and the mapped list keeps all five elements.
-}
-- CHECK: m: "e"
-- CHECK-NEXT: m: "d"
-- CHECK-NEXT: m: "c"
-- CHECK-NEXT: m: "b"
-- CHECK-NEXT: m: "a"
-- CHECK: len: 5
import Html exposing (text)
{-| Maps `Debug.log "m"` over `xs`, logging each element.
-}
logged : List String -> List String
logged xs =
List.map (\x -> Debug.log "m" x) xs
main : Html.Html msg
main =
let
mapped =
logged [ "a", "b", "c", "d", "e" ]
_ =
Debug.log "len" (List.length mapped)
in
text "done"