Sha256: e01cf294591b2728620f5721c3b47e190b4fcd1041b476aa1b95ade16ee9d4bd

Contents?: true

Size: 662 Bytes

Versions: 211

Compression:

Stored size: 662 Bytes

Contents

import Allergen.Allergen

object Allergies {
  private lazy val allergenList = Allergen.values

  def isAllergicTo(allergen: Allergen, score: Int): Boolean =
    (allergen.id & score) != 0

  def allergies(score: Int): List[Allergen] =
    allergenList.filter(a => isAllergicTo(a, score)).toList
}

object Allergen extends Enumeration {
  type Allergen = Value

  val Eggs = Value(1, "Eggs")
  val Peanuts = Value(2, "Peanuts")
  val Shellfish = Value(4, "Shellfish")
  val Strawberries = Value(8, "Strawberries")
  val Tomatoes = Value(16, "Tomatoes")
  val Chocolate = Value(32, "Chocolate")
  val Pollen = Value(64, "Pollen")
  val Cats = Value(128, "Cats")
}

Version data entries

211 entries across 211 versions & 1 rubygems

Version Path
trackler-2.2.1.30 tracks/scala/exercises/allergies/example.scala
trackler-2.2.1.29 tracks/scala/exercises/allergies/example.scala
trackler-2.2.1.28 tracks/scala/exercises/allergies/example.scala
trackler-2.2.1.27 tracks/scala/exercises/allergies/example.scala
trackler-2.2.1.26 tracks/scala/exercises/allergies/example.scala
trackler-2.2.1.25 tracks/scala/exercises/allergies/example.scala
trackler-2.2.1.24 tracks/scala/exercises/allergies/example.scala
trackler-2.2.1.23 tracks/scala/exercises/allergies/example.scala
trackler-2.2.1.22 tracks/scala/exercises/allergies/example.scala
trackler-2.2.1.21 tracks/scala/exercises/allergies/example.scala
trackler-2.2.1.20 tracks/scala/exercises/allergies/example.scala
trackler-2.2.1.19 tracks/scala/exercises/allergies/example.scala
trackler-2.2.1.18 tracks/scala/exercises/allergies/example.scala
trackler-2.2.1.17 tracks/scala/exercises/allergies/example.scala
trackler-2.2.1.16 tracks/scala/exercises/allergies/example.scala
trackler-2.2.1.15 tracks/scala/exercises/allergies/example.scala
trackler-2.2.1.14 tracks/scala/exercises/allergies/example.scala
trackler-2.2.1.13 tracks/scala/exercises/allergies/example.scala
trackler-2.2.1.12 tracks/scala/exercises/allergies/example.scala
trackler-2.2.1.11 tracks/scala/exercises/allergies/example.scala