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.10 tracks/scala/exercises/allergies/example.scala
trackler-2.2.1.9 tracks/scala/exercises/allergies/example.scala
trackler-2.2.1.8 tracks/scala/exercises/allergies/example.scala
trackler-2.2.1.7 tracks/scala/exercises/allergies/example.scala
trackler-2.2.1.6 tracks/scala/exercises/allergies/example.scala
trackler-2.2.1.5 tracks/scala/exercises/allergies/example.scala
trackler-2.2.1.4 tracks/scala/exercises/allergies/example.scala
trackler-2.2.1.3 tracks/scala/exercises/allergies/example.scala
trackler-2.2.1.2 tracks/scala/exercises/allergies/example.scala
trackler-2.2.1.1 tracks/scala/exercises/allergies/example.scala
trackler-2.2.1.0 tracks/scala/exercises/allergies/example.scala
trackler-2.2.0.6 tracks/scala/exercises/allergies/example.scala
trackler-2.2.0.5 tracks/scala/exercises/allergies/example.scala
trackler-2.2.0.4 tracks/scala/exercises/allergies/example.scala
trackler-2.2.0.3 tracks/scala/exercises/allergies/example.scala
trackler-2.2.0.2 tracks/scala/exercises/allergies/example.scala
trackler-2.2.0.1 tracks/scala/exercises/allergies/example.scala
trackler-2.2.0.0 tracks/scala/exercises/allergies/example.scala
trackler-2.1.0.55 tracks/scala/exercises/allergies/example.scala
trackler-2.1.0.54 tracks/scala/exercises/allergies/example.scala