Elm Exactly
Results / elm-core /

ListFilterTest

elm-0.19.1 passelm-0.19.2 passelm-0.19.3 passlamdera-1.5.0 pass
`List.filter` keeps the elements that satisfy a named predicate or a partially
applied `(==)`, on Int and String lists and on the empty list.

Results

elm-0.19.1

passran in 84 ms
Output
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.1/optimize for better performance and smaller assets.
even: [2,4]
positive: [1,2,3]
empty: []
eq_ho: [3,3]
eq_ho_string: ["hello","hello"]

elm-0.19.2

passran in 52 ms
Output
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.2/optimize for better performance and smaller assets.
even: [2,4]
positive: [1,2,3]
empty: []
eq_ho: [3,3]
eq_ho_string: ["hello","hello"]

elm-0.19.3

passran in 50 ms
Output
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.3/optimize for better performance and smaller assets.
even: [2,4]
positive: [1,2,3]
empty: []
eq_ho: [3,3]
eq_ho_string: ["hello","hello"]

lamdera-1.5.0

passran in 55 ms
Output
even: [2,4]
positive: [1,2,3]
empty: []
eq_ho: [3,3]
eq_ho_string: ["hello","hello"]

Discussions

Discuss this test·Search the discussions on GitHub

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

Source

The -- CHECK: lines give the expected output.

module ListFilterTest exposing (main)
{-| `List.filter` keeps the elements that satisfy a named predicate or a partially
applied `(==)`, on Int and String lists and on the empty list.
-}
-- CHECK: even: [2,4]
-- CHECK: positive: [1,2,3]
-- CHECK: empty: []
-- CHECK: eq_ho: [3,3]
-- CHECK: eq_ho_string: ["hello","hello"]
import Html exposing (text)
isEven x = modBy 2 x == 0
isPositive x = x > 0
main =
let
_ = Debug.log "even" (List.filter isEven [1, 2, 3, 4, 5])
_ = Debug.log "positive" (List.filter isPositive [-1, 0, 1, 2, 3])
_ = Debug.log "empty" (List.filter isEven [])
_ = Debug.log "eq_ho" (List.filter ((==) 3) [1, 2, 3, 4, 3])
_ = Debug.log "eq_ho_string" (List.filter ((==) "hello") ["hello", "world", "hello"])
in
text "done"