99namespace Algorithms.Strings
1010
1111module MinCostStringConversion =
12-
12+
1313 [<RequireQualifiedAccess>]
1414 type Operation =
1515 | Copy of char
1616 | Replace of Source : char * Target : char
1717 | Delete of char
1818 | Insert of char
19-
19+
2020 let computeTransformTables
2121 (
2222 source : string ,
@@ -26,17 +26,17 @@ module MinCostStringConversion =
2626 deleteCost : int ,
2727 insertCost : int
2828 ): array < array < int >> * array < array < Operation >> =
29-
29+
3030 let costs =
3131 Array.init ( source.Length + 1 ) ( fun _ -> Array.init ( destination.Length + 1 ) ( fun _ -> None))
32-
32+
3333 let ops =
3434 Array.init ( source.Length + 1 ) ( fun _ -> Array.init ( destination.Length + 1 ) ( fun _ -> None))
35-
35+
3636 costs.[ 0 ].[ 0 ] <- Some 0
37- ops.[ 0 ].[ 0 ] <- Some ( Operation.Copy 'a' ) // There is no operation to perform, assigning dummy operation to satisfy compiler
38-
39-
37+ ops.[ 0 ].[ 0 ] <- Some ( Operation.Copy 'a' ) // There is no operation to perform, assigning dummy operation to satisfy compiler
38+
39+
4040 for i = 1 to source.Length do
4141 costs.[ i].[ 0 ] <- Some ( i * deleteCost)
4242 ops.[ i].[ 0 ] <- Some ( Operation.Delete source.[ i - 1 ])
@@ -73,11 +73,11 @@ module MinCostStringConversion =
7373 | Operation.Replace _
7474 | Operation.Copy _ ->
7575 let seq = assembleTransformation ( ops, i - 1 , j - 1 )
76- Array.append seq [| ops[ i][ j] |]
76+ Array.append seq [| ops[ i][ j] |]
7777 | Operation.Delete _ ->
7878 let seq = assembleTransformation ( ops, i - 1 , j)
79- Array.append seq [| ops[ i][ j] |]
79+ Array.append seq [| ops[ i][ j] |]
8080 | Operation.Insert _ ->
8181 let seq = assembleTransformation ( ops, i , j - 1 )
82- Array.append seq [| ops[ i][ j] |]
83-
82+ Array.append seq [| ops[ i][ j] |]
83+
0 commit comments