问问题
75 次
1 回答
2
module BirthdayLibrary =
type Birthday =
{ day :int
month :int }
module DataGen =
let birthdayGenerator (months:option<list<int>>) =
let monthGen = match months with
| Some m -> Gen.elements m
| None -> FsCheck.Gen.choose(1,12)
(fun m d -> { day = d
month = m}:BirthdayLibrary.Birthday)
<!> monthGen
<*> FsCheck.Gen.choose(1,28)
//I want this to have the signature Gen<BirthdayLibrary.Birthday list>
let oneForEveryMonthGen =
[ for m in [1 .. 12] -> birthdayGenerator (Some [m])]
|> Gen.sequence
let sample = DataGen.oneForEveryMonthGen |> Gen.sample 10 1
给我:
val 示例:BirthdayLibrary.Birthday 列表列表 = [[{day = 7; 月 = 1;}; {天 = 15; 月 = 2;}; {天 = 13; 月 = 3;}; {天 = 14; 月 = 4;}; {天 = 28; 月 = 5;}; {天 = 9; 月 = 6;}; {天 = 28; 月 = 7;}; {天 = 15; 月 = 8;}; {天 = 6; 月 = 9;}; {天 = 21; 月 = 10;}; {天 = 12; 月 = 11;}; {天 = 27; 月 = 12;}]]
于 2015-01-21T09:46:27.937 回答