StringFoldlTest
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 msOutput
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 msOutput
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 msOutput
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 msOutput
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"