Sha256: 780a0a5be9662053b911802f6a0be67ab0d09e1ed9deb726b3a1cbf09d8f23ae

Contents?: true

Size: 575 Bytes

Versions: 66

Compression:

Stored size: 575 Bytes

Contents

module Allergies exposing (isAllergicTo, toList)

import Bitwise
import List


isAllergicTo : String -> Int -> Bool
isAllergicTo name score =
    List.member name (toList score)


toList : Int -> List String
toList score =
    allergies
        |> List.indexedMap (\i n -> ( Bitwise.shiftLeftBy i 1, n ))
        |> List.filter (\( s, n ) -> Bitwise.and s score > 0)
        |> List.map Tuple.second


allergies : List String
allergies =
    [ "eggs"
    , "peanuts"
    , "shellfish"
    , "strawberries"
    , "tomatoes"
    , "chocolate"
    , "pollen"
    , "cats"
    ]

Version data entries

66 entries across 66 versions & 1 rubygems

Version Path
trackler-2.2.1.180 tracks/elm/exercises/allergies/Allergies.example.elm
trackler-2.2.1.179 tracks/elm/exercises/allergies/Allergies.example.elm
trackler-2.2.1.178 tracks/elm/exercises/allergies/Allergies.example.elm
trackler-2.2.1.177 tracks/elm/exercises/allergies/Allergies.example.elm
trackler-2.2.1.176 tracks/elm/exercises/allergies/Allergies.example.elm
trackler-2.2.1.175 tracks/elm/exercises/allergies/Allergies.example.elm
trackler-2.2.1.174 tracks/elm/exercises/allergies/Allergies.example.elm
trackler-2.2.1.173 tracks/elm/exercises/allergies/Allergies.example.elm
trackler-2.2.1.172 tracks/elm/exercises/allergies/Allergies.example.elm
trackler-2.2.1.171 tracks/elm/exercises/allergies/Allergies.example.elm
trackler-2.2.1.170 tracks/elm/exercises/allergies/Allergies.example.elm
trackler-2.2.1.169 tracks/elm/exercises/allergies/Allergies.example.elm
trackler-2.2.1.167 tracks/elm/exercises/allergies/Allergies.example.elm
trackler-2.2.1.166 tracks/elm/exercises/allergies/Allergies.example.elm
trackler-2.2.1.165 tracks/elm/exercises/allergies/Allergies.example.elm
trackler-2.2.1.164 tracks/elm/exercises/allergies/Allergies.example.elm
trackler-2.2.1.163 tracks/elm/exercises/allergies/Allergies.example.elm
trackler-2.2.1.162 tracks/elm/exercises/allergies/Allergies.example.elm
trackler-2.2.1.161 tracks/elm/exercises/allergies/Allergies.example.elm
trackler-2.2.1.160 tracks/elm/exercises/allergies/Allergies.example.elm