練習問題 2.3.1
与えられた曜日の前日の曜日を返す関数dayBeforeを定義せよ.
data Day = Sun | Mon | Tue | Wed | Thu | Fri | Sat
deriving (Eq,Ord,Enum)
dayBefore :: Day -> Day
dayBefore Sun = Sat
dayBefore d = toEnum ((fromEnum d + 6) `mod` 7)
dayBeforeを定義せよ.
data Day = Sun | Mon | Tue | Wed | Thu | Fri | Sat
deriving (Eq,Ord,Enum)
dayBefore :: Day -> Day
dayBefore Sun = Sat
dayBefore d = toEnum ((fromEnum d + 6) `mod` 7)