StringConsDynamicTest
`String.cons` rebuilds a string from the `Char` and rest that `String.uncons` split it into. `String.uncons "ab"` gives `Just ( 'a', "b" )`, and `String.cons 'a' "b"` is `"ab"` again. The `Char` passed to `String.cons` is computed at run time, not written as a literal.
Results
elm-0.19.1
passran in 39 msOutput
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.1/optimize for better performance and smaller assets. out: "ab"
elm-0.19.2
passran in 36 msOutput
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.2/optimize for better performance and smaller assets. out: "ab"
elm-0.19.3
passran in 35 msOutput
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.3/optimize for better performance and smaller assets. out: "ab"
lamdera-1.5.0
passran in 38 msOutput
out: "ab"
Discussions
Discuss this test·Search the discussions on GitHub
Discussions are on GitHub; one about this test has [t:elm-core/StringConsDynamicTest] in its title.
Source
The -- CHECK: lines give the expected output.
module StringConsDynamicTest exposing (main)
{-| `String.cons` rebuilds a string from the `Char` and rest that `String.uncons` split it into.
`String.uncons "ab"` gives `Just ( 'a', "b" )`, and `String.cons 'a' "b"` is
`"ab"` again. The `Char` passed to `String.cons` is computed at run time, not
written as a literal.
-}
-- CHECK: out: "ab"
import Html exposing (text)
main =
let
src =
"ab"
rebuilt =
case String.uncons src of
Just ( c, rest ) ->
String.cons c rest
Nothing ->
""
_ =
Debug.log "out" rebuilt
in
text "done"