我需要为Haskell中的工作日Robertson公式编写一个函数.目前我收到一条错误消息(每个变量(A,B,C,D,E)时"不在范围内".但是,我不知道错误是什么?它可能是"在哪里"?
wochentag :: Integer -> Integer -> Integer -> String
wochentag tag monat jahr = wochentage !! fromInteger (robertson tag monat jahr) where
wochentage :: [String]
wochentage = ["Sonntag","Montag","Dienstag","Mittwoch","Donnerstag","Freitag","Samstag"]
robertson :: Integer -> Integer -> Integer -> Integer
robertson tag monat jahr = D + tag +77 +E + (B quot 400) - 2 * (B quot 100) mod 77 where
A = monat + 10
B = ((monat - 14) quot 12) + jahr
C = A - 12 * (A quot 13)
D = (( 13 * C - 1) quot 5)
E = 5 * ( B mod 100) quot 4
Run Code Online (Sandbox Code Playgroud)
有人能帮我吗?
1)不能以大写字母开头定义值.
2)中缀运营商应该用这样的单引号包围:
robertson :: Integer -> Integer -> Integer -> Integer
robertson tag monat jahr = d + tag + 77 +e + (b `quot` 400) - 2 * (b `quot` 100) `mod` 77 where
a = monat + 10
b = ((monat - 14) `quot` 12) + jahr
c = a - 12 * (a `quot` 13)
d = (( 13 * c - 1) `quot` 5)
e = 5 * ( b `mod` 100) `quot` 4
Run Code Online (Sandbox Code Playgroud)