Robertson在Haskell的工作日功能

时间:2015-04-27 09:50:35

标签: function haskell

我需要为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

有人能帮助我吗?

1 个答案:

答案 0 :(得分:8)

1)无法以大写字母开头定义值。

2)中缀运营商应该用这样的单引号包围:

public class Mail {

private MailSender mailSender;

public void setMailSender(MailSender mailSender) {
    this.mailSender = mailSender;
}

public void sendMail(String from, String to, String subject, String msg) {

    SimpleMailMessage message = new SimpleMailMessage();
    String[] array = new String[];
    array[0]="from@gmail.com";
    array[1]="to@gmail.com";
    array[2]="subject";
    array[3]="text";

    message.setFrom(from);
    message.setTo(to);
    message.setSubject(subject);
    message.setText(msg);
    mailSender.sendMail(); // what should be here?

}
}