Is there a better code that does not need to transform the sequence into a list ?
let rec addentry map keys =
match keys with
| ((i,j) :: tail) -> Map.add (i,j) ((inputd.[i]).[j]) (addentry map tail)
| ([]) -> map
addentry Map.empty (Cartesian keys1 keys2 |> Seq.toList)
This is a great place to use Seq.fold
. It collapses a collection down into a single value.
Cartesian keys1 keys2
|> Seq.fold (fun map (i, j) ->
let value = (inputd.[i]).[j]
Map.add (i, j) value map) Map.empty
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With