Skip to content

Commit

Permalink
making 10.1 prettier, fixing [#191 main issue - Input demo array is n…
Browse files Browse the repository at this point in the history
  • Loading branch information
moudrick committed Jan 30, 2020
1 parent e24033f commit 176161d
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions Ch 10. Sorting and Searching/Q10 01 Sorted Merge.fs
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ module Sln =
let (current, newIndices) =
let currentB = b |> Array.get <| indexB
let currentA = lazy (a |> Array.get <| indexA)
match (indexA >= 0) && (currentA.Force() > currentB) with // (* end of A is bigger than end of B *)
| true -> (currentA.Value, (indexMerged - 1, indexA - 1, indexB ))
| _ -> (currentB , (indexMerged - 1, indexA , indexB - 1))
if (indexA >= 0) && (currentA.Force() > currentB) (* end of A is bigger than end of B *)
then (currentA.Value, (indexMerged - 1, indexA - 1, indexB ))
else (currentB , (indexMerged - 1, indexA , indexB - 1))

a |> Array.set <| indexMerged <| current // copy element
mergeAtIndices a b newIndices // move indices
Expand All @@ -50,11 +50,11 @@ type Question() =

override this.DemoRun() =
let a = [| 2; 3; 4; 5; 6; 8; 10; 100; 0; 0; 0; 0; 0; 0 |]
let b = [| 1; 4; 7; 6; 7; 7 |];
let b = [| 1; 4; 6; 7; 7; 7 |];
Sln.merge a b 8 6
printfn "%A" a

let a1 = [| 2; 3; 4; 5; 6; 8; 10; 100; 0; 0; 0; 0; 0; 0 |]
let b1 = [| 1; 4; 7; 6; 7; 7 |];
let b1 = [| 1; 4; 6; 7; 7; 7 |];
Sln.NoMutable.merge a1 b1 8 6
printfn "%A" a1

0 comments on commit 176161d

Please sign in to comment.