The section syntax can be used to control entire rows / columns of a matrix:
// Create sample matrix
let m = Matrix.init 10 10 (fun x y -> float(x * 10 + y))
// Overwrite first row with the second row
m.[0..0, 0..9] <- m.[1..1, 0..9]
The slicing syntax allows you to select a part of the matrix - in this case, we select a matrix with a height of 1, but you can use this function as a whole (the part does not have to be a single column row). I do not think that there is any existing function for exchanging two strings, but you can use slices and implement it as follows:
let swap (m:matrix) a b =
let tmp = m.[a..a, 1..9]
m.[a..a, 1..9] <- m.[b..b, 1..9]
m.[b..b, 1..9] <- tmp
source
share