【发布时间】:2021-10-02 21:27:57
【问题描述】:
-- | Days of week.
data Day = Sunday | Monday | Tuesday | Wednesday | Thursday | Friday | Saturday deriving (Eq, Show)
-- | Returns the next weekday (excluding weekend, namely Saturday and Sunday).
nextWeekday :: Day -> Day
nextWeekday day =
if x == Sunday
then let x = Monday
if x == Monday
then let x = Tuesday
if x == Tuesday
then let x = Wednesday
if x == Wednesday
then let x = Thursday
if x == Thursday
then let x = Friday
if x == Friday
then let x = Saturday
else
then let x = Sunday
这是我现在的代码...此代码有什么问题...?如何自动缩进 Haskell 代码?
【问题讨论】:
-
您的代码有什么问题是
let不是set。 Haskell 的变量无法更改。见stackoverflow.com/questions/11922134/…。
标签: haskell