Elm Exactly
Results / elm-core /

StringFoldlTest

elm-0.19.1 passelm-0.19.2 passelm-0.19.3 passlamdera-1.5.0 pass
Checks that `String.foldl` visits characters from the left and `String.foldr` from the right.

Both fold `String.cons` over `"hello"` starting from `""`. Consing from the left
reverses the string, giving `"olleh"`; consing from the right rebuilds it,
giving `"hello"`.

Results

elm-0.19.1

passran in 58 ms
Output
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.1/optimize for better performance and smaller assets.
foldl1: "olleh"
foldr1: "hello"

elm-0.19.2

passran in 38 ms
Output
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.2/optimize for better performance and smaller assets.
foldl1: "olleh"
foldr1: "hello"

elm-0.19.3

passran in 37 ms
Output
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.3/optimize for better performance and smaller assets.
foldl1: "olleh"
foldr1: "hello"

lamdera-1.5.0

passran in 41 ms
Output
foldl1: "olleh"
foldr1: "hello"

Discussions

Discuss this test·Search the discussions on GitHub

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

Source

The -- CHECK: lines give the expected output.

module StringFoldlTest exposing (main)
{-| Checks that `String.foldl` visits characters from the left and `String.foldr` from the right.
Both fold `String.cons` over `"hello"` starting from `""`. Consing from the left
reverses the string, giving `"olleh"`; consing from the right rebuilds it,
giving `"hello"`.
-}
-- CHECK: foldl1: "olleh"
-- CHECK: foldr1: "hello"
import Html exposing (text)
main =
let
_ = Debug.log "foldl1" (String.foldl (\c acc -> String.cons c acc) "" "hello")
_ = Debug.log "foldr1" (String.foldr (\c acc -> String.cons c acc) "" "hello")
in
text "done"