Elm Exactly
Results / elm-core /

CharToCodeFoldStringTest

elm-0.19.1 passelm-0.19.2 passelm-0.19.3 passlamdera-1.5.0 pass
`String.foldl` hands each character of a string to a function that sums their
`Char.toCode` values.

The codes of `"abc"` are 97, 98 and 99, so the logged sum is 294.

Results

elm-0.19.1

passran in 48 ms
Output
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.1/optimize for better performance and smaller assets.
sum: 294

elm-0.19.2

passran in 73 ms
Output
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.2/optimize for better performance and smaller assets.
sum: 294

elm-0.19.3

passran in 70 ms
Output
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.3/optimize for better performance and smaller assets.
sum: 294

lamdera-1.5.0

passran in 68 ms
Output
sum: 294

Discussions

Discuss this test·Search the discussions on GitHub

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

Source

The -- CHECK: lines give the expected output.

module CharToCodeFoldStringTest exposing (main)
{-| `String.foldl` hands each character of a string to a function that sums their
`Char.toCode` values.
The codes of `"abc"` are 97, 98 and 99, so the logged sum is 294.
-}
-- CHECK: sum: 294
import Char
import Html exposing (text)
main =
let
sum =
String.foldl (\c acc -> acc + Char.toCode c) 0 "abc"
_ =
Debug.log "sum" sum
in
text "done"