Elm Exactly
Results / elm-core /

JsArrayFloatMapTest

elm-0.19.1 passelm-0.19.2 passelm-0.19.3 passlamdera-1.5.0 pass
`Array.map` over an `Array Float` passes the element values to the mapping function.

Three arrays are mapped, doubling, adding 1.0 and negating each element, and the results are read back with `Array.toList`.

Results

elm-0.19.1

passran in 67 ms
Output
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.1/optimize for better performance and smaller assets.
doubled: [2,4,6]
incr: [2.5,3.5,4.5]
negate: [-1,-2,-3]

elm-0.19.2

passran in 56 ms
Output
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.2/optimize for better performance and smaller assets.
doubled: [2,4,6]
incr: [2.5,3.5,4.5]
negate: [-1,-2,-3]

elm-0.19.3

passran in 66 ms
Output
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.3/optimize for better performance and smaller assets.
doubled: [2,4,6]
incr: [2.5,3.5,4.5]
negate: [-1,-2,-3]

lamdera-1.5.0

passran in 64 ms
Output
doubled: [2,4,6]
incr: [2.5,3.5,4.5]
negate: [-1,-2,-3]

Discussions

Discuss this test·Search the discussions on GitHub

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

Source

The -- CHECK: lines give the expected output.

module JsArrayFloatMapTest exposing (main)
{-| `Array.map` over an `Array Float` passes the element values to the mapping function.
Three arrays are mapped, doubling, adding 1.0 and negating each element, and the results are read back with `Array.toList`.
-}
-- CHECK: doubled: [2,4,6]
-- CHECK: incr: [2.5,3.5,4.5]
-- CHECK: negate: [-1,-2,-3]
import Array
import Html exposing (text)
main =
let
arr = Array.fromList [1.0, 2.0, 3.0]
_ = Debug.log "doubled" (Array.toList (Array.map (\x -> x * 2.0) arr))
_ = Debug.log "incr" (Array.toList (Array.map (\x -> x + 1.0) (Array.fromList [1.5, 2.5, 3.5])))
_ = Debug.log "negate" (Array.toList (Array.map (\x -> -x) (Array.fromList [1.0, 2.0, 3.0])))
in
text "done"