I would like to generate a sequence of sequences of sets of tuple
It's for generating coordinates of lines in board game (squares);horizontal lines,vertical lines, and the main 2 diagonal lines
The one I created using list (using the generateLines function) works well. It generates the coordinates of lines in a list of lists of tuples. However, after I convert it into sequence of sequences, I don't have any idea how to check whether it's correct
I've tried this : CoordinateLines 3 |> Seq.map (fun x ->Seq.toList) |> Seq.toList
But it doesn't work, with error : error FS0030: Value restriction. The value 'it' has been inferred to have generic type
val it : ('_a -> '_b list) list when '_a :> seq<'_b>
Either define 'it' as a simple data term, make it a function with explicit arguments or, if you do not intend for it to be generic, add a type annotation.
let CoordinateLines size : seq<seq<int*int>> =
let generateLines size =
[for a in 0..(size-1) do
yield [for b in 0..(size-1) do
yield(a,b)
]
]
@
[for a in 0..(size-1) do
yield [for b in 0..(size-1) do
yield(b,a)
]
]
@
[[for a = 0 to (size-1) do
yield (a,(size-1)-a)
]]
@
[[for a = 0 to (size-1) do
yield (a,a)
]]
generateLines size
|> List.toSeq
|> Seq.map (fun x -> List.toSeq x)