concept week in category scala
appears as: week

This is an excerpt from Manning's book Get Programming with Scala.
Suppose you have a list of events: each one has a number that represents the day of the week it occurs starting with one for Sunday and ending with seven for Saturday. You want to write a function that takes an integer representing a day of the week, and that returns either “weekday” or “weekend” accordingly. For example, you could come up with a solution similar to the following:
Listing 5.1: Categorize the day of the week
def categorizeDayOfWeek(n: Int) = { if (n == 1 || n == 7) { "weekend" } else if (n > 1 && n < 7 ) { "weekday" } else { "unknown" } }
Listing 5.1: Categorize the day of the week
def categorizeDayOfWeek(n: Int) = { if (n == 1 || n == 7) { "weekend" } else if (n > 1 && n < 7 ) { "weekday" } else { "unknown" } }