Sha256: 8c7f3dac76410188962377698f194288e82ff947dd9fe809e66db11eb1f07f5e
Contents?: true
Size: 484 Bytes
Versions: 131
Compression:
Stored size: 484 Bytes
Contents
defmodule Allergies do import Bitwise @allergens [ "eggs", "peanuts", "shellfish", "strawberries", "tomatoes", "chocolate", "pollen", "cats" ] def list(flags) do Enum.with_index(@allergens) |> Enum.filter(&flagged?(flags, &1)) |> Enum.map(fn {item, _} -> item end) end def allergic_to?(flags, item) do Enum.member?(list(flags), item) end defp flagged?(flags, {_, index}) do (flags &&& 1 <<< index) > 0 end end
Version data entries
131 entries across 131 versions & 1 rubygems