Elm Exactly
Results / elm-core /

JsArrayFloatFoldlTest

elm-0.19.1 passelm-0.19.2 passelm-0.19.3 passlamdera-1.5.0 pass
`Array.foldl` and `Array.foldr` over an `Array Float` pass the element values to the folding function.

`foldl` is checked with `(+)` (sum 7), `(*)` (product 24) and `max` (3.5). `foldr (::) []` rebuilds `[1.5, 2.5, 3.0]` in its original order.

Results

elm-0.19.1

passran in 75 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: 7
product: 24
maxViaFold: 3.5
foldrList: [1.5,2.5,3]

elm-0.19.2

passran in 44 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: 7
product: 24
maxViaFold: 3.5
foldrList: [1.5,2.5,3]

elm-0.19.3

passran in 73 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: 7
product: 24
maxViaFold: 3.5
foldrList: [1.5,2.5,3]

lamdera-1.5.0

passran in 82 ms
Output
sum: 7
product: 24
maxViaFold: 3.5
foldrList: [1.5,2.5,3]

Discussions

Discuss this test·Search the discussions on GitHub

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

Source

The -- CHECK: lines give the expected output.

module JsArrayFloatFoldlTest exposing (main)
{-| `Array.foldl` and `Array.foldr` over an `Array Float` pass the element values to the folding function.
`foldl` is checked with `(+)` (sum 7), `(*)` (product 24) and `max` (3.5). `foldr (::) []` rebuilds `[1.5, 2.5, 3.0]` in its original order.
-}
-- CHECK: sum: 7
-- CHECK: product: 24
-- CHECK: maxViaFold: 3.5
-- CHECK: foldrList: [1.5,2.5,3]
import Array
import Html exposing (text)
main =
let
_ = Debug.log "sum" (Array.foldl (+) 0.0 (Array.fromList [1.5, 2.5, 3.0]))
_ = Debug.log "product" (Array.foldl (*) 1.0 (Array.fromList [2.0, 3.0, 4.0]))
_ = Debug.log "maxViaFold" (Array.foldl max 0.0 (Array.fromList [1.5, 3.5, 2.5]))
_ = Debug.log "foldrList" (Array.foldr (::) [] (Array.fromList [1.5, 2.5, 3.0]))
in
text "done"