In this article, rewrite with using Seq.unfold . It becomes quite simple architecture.
open System(continue to phosphorescence: Calculate the firefox year with using Seq.unfold #2)
let firefoxRollingReleaseDate n =
let firefox5ReleaseDate = new DateTime(2011, 6, 21)
let firefox6ReleaseDate = firefox5ReleaseDate.AddDays(7.0 * 8.0)
let isBetweenDate(targetDate:DateTime, currentDate:DateTime, nextDate:DateTime) =
match (DateTime.Compare(targetDate, currentDate)>0, DateTime.Compare(targetDate, nextDate)>0) with
| (true, false) -> true
| (_, _) -> false
let firefoxRollingRelease (currentDate:DateTime, nextDate:DateTime) =
match isBetweenDate(new DateTime(2012, 12, 25), nextDate, nextDate.AddDays(7.0 * 6.0)) with
| true -> Some(currentDate, (nextDate, nextDate.AddDays(7.0 * 7.0)))
| _ -> Some(currentDate, (nextDate, nextDate.AddDays(7.0 * 6.0)))
match n < 5 with
| true -> failwith "The version was not yet in rolling release."
| _ -> Seq.nth (n - 5) <| Seq.unfold firefoxRollingRelease (firefox5ReleaseDate, firefox6ReleaseDate)
No comments:
Post a Comment