Elm Exactly
Results / elm-core /

JsArrayInitializeRepeatTest

elm-0.19.1 passelm-0.19.2 passelm-0.19.3 passlamdera-1.5.0 pass
`Array.initialize` and `Array.repeat` build arrays of the requested length, including length zero.

`Array.initialize 5` with `\i -> i * i` gives the squares of 0 to 4, and `Array.repeat 3 7` gives three 7s. With a length of 0, each function gives an empty array.

Results

elm-0.19.1

passran in 57 ms
Output
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.1/optimize for better performance and smaller assets.
init1: [0,1,4,9,16]
repeat1: [7,7,7]
repeat_zero: []
init_zero: []

elm-0.19.2

passran in 59 ms
Output
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.2/optimize for better performance and smaller assets.
init1: [0,1,4,9,16]
repeat1: [7,7,7]
repeat_zero: []
init_zero: []

elm-0.19.3

passran in 64 ms
Output
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.3/optimize for better performance and smaller assets.
init1: [0,1,4,9,16]
repeat1: [7,7,7]
repeat_zero: []
init_zero: []

lamdera-1.5.0

passran in 71 ms
Output
init1: [0,1,4,9,16]
repeat1: [7,7,7]
repeat_zero: []
init_zero: []

Discussions

Discuss this test·Search the discussions on GitHub

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

Source

The -- CHECK: lines give the expected output.

module JsArrayInitializeRepeatTest exposing (main)
{-| `Array.initialize` and `Array.repeat` build arrays of the requested length, including length zero.
`Array.initialize 5` with `\i -> i * i` gives the squares of 0 to 4, and `Array.repeat 3 7` gives three 7s. With a length of 0, each function gives an empty array.
-}
-- CHECK: init1: [0,1,4,9,16]
-- CHECK: repeat1: [7,7,7]
-- CHECK: repeat_zero: []
-- CHECK: init_zero: []
import Array
import Html exposing (text)
main =
let
_ = Debug.log "init1" (Array.toList (Array.initialize 5 (\i -> i * i)))
_ = Debug.log "repeat1" (Array.toList (Array.repeat 3 7))
_ = Debug.log "repeat_zero" (Array.toList (Array.repeat 0 7))
_ = Debug.log "init_zero" (Array.toList (Array.initialize 0 (\i -> i)))
in
text "done"