ListFoldlTest
`List.foldl` folds from the left, shown by sum, product and `(++)` on strings, where `"cba"` reveals the order.
Results
elm-0.19.1
passran in 64 msOutput
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.1/optimize for better performance and smaller assets. sum: 10 product: 24 concat: "cba"
elm-0.19.2
passran in 77 msOutput
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.2/optimize for better performance and smaller assets. sum: 10 product: 24 concat: "cba"
elm-0.19.3
passran in 77 msOutput
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.3/optimize for better performance and smaller assets. sum: 10 product: 24 concat: "cba"
lamdera-1.5.0
passran in 58 msOutput
sum: 10 product: 24 concat: "cba"
Discussions
Discuss this test·Search the discussions on GitHub
Discussions are on GitHub; one about this test has [t:elm-core/ListFoldlTest] in its title.
Source
The -- CHECK: lines give the expected output.
module ListFoldlTest exposing (main)
{-| `List.foldl` folds from the left, shown by sum, product and `(++)` on strings,
where `"cba"` reveals the order.
-}
-- CHECK: sum: 10
-- CHECK: product: 24
-- CHECK: concat: "cba"
import Html exposing (text)
main =
let
_ = Debug.log "sum" (List.foldl (+) 0 [1, 2, 3, 4])
_ = Debug.log "product" (List.foldl (*) 1 [1, 2, 3, 4])
_ = Debug.log "concat" (List.foldl (++) "" ["a", "b", "c"])
in
text "done"