address compiler errors/warnings

This commit is contained in:
2024-06-29 23:40:39 +01:00
parent ffaaa8993e
commit 37653a7c85

View File

@@ -80,9 +80,9 @@ struct
if midVal = findNum then if midVal = findNum then
mid mid
else if midVal < findNum then else if midVal < findNum then
binSearch (findNum, lines, mid + 1, high) helpBinSearch (findNum, lines, mid + 1, high)
else else
binSearch (findNum, lines, low, mid - 1) helpBinSearch (findNum, lines, low, mid - 1)
end end
else else
mid mid
@@ -327,7 +327,7 @@ struct
, newLines , newLines
, curIdx , curIdx
, curLine , curLine
, leftStrings , leftStrings: string list
, leftLines , leftLines
, rightStrings , rightStrings
, rightLines , rightLines
@@ -375,7 +375,7 @@ struct
, prevLine , prevLine
, leftStringsTl , leftStringsTl
, leftLinesTl , leftLinesTl
, newRightLinesHd :: rightStringsTl , newRightStringsHd :: rightStringsTl
, newRightLinesHd :: rightLinesTl , newRightLinesHd :: rightLinesTl
) )
end end
@@ -447,18 +447,18 @@ struct
, nextIdx , nextIdx
, rightStringsHd , rightStringsHd
, rightStringsTl , rightStringsTl
, rightLinesHd , rightLinesHd: int vector
, rightLinesTl , rightLinesTl
) = ) : t =
if idx = nextIdx then if idx = nextIdx then
(* Need to put newString/newLines at the end of the right list's hd. *) (* Need to put newString/newLines at the end of the right list's hd. *)
if isInLimit (newString, rightStringsHd, newLines, rightLinesHd) then if isInLimit (newString, rightStringsHd, newLines, rightLinesHd) then
(* Allocate new string because we can do so while staying in limit. *) (* Allocate new string because we can do so while staying in limit. *)
let let
val newRightStringsHd = rightLinesHd ^ newString val newRightStringsHd = rightStringsHd ^ newString
val newRightLinesHd = val newRightLinesHd =
Vector.tabulate Vector.tabulate
( Vector.length newLines + Vector.line rightLinesHd ( Vector.length newLines + Vector.length rightLinesHd
, fn idx => , fn idx =>
if idx < Vector.length rightLinesHd then if idx < Vector.length rightLinesHd then
Vector.sub (rightLinesHd, idx) Vector.sub (rightLinesHd, idx)
@@ -489,13 +489,13 @@ struct
(* Have to split rightStringsHd and rightLinesHd in the middle. *) (* Have to split rightStringsHd and rightLinesHd in the middle. *)
let let
val strLength = idx - curIdx val strLength = idx - curIdx
val sub1 = String.substring (rightStringsHd, 0, strLength) val strSub1 = String.substring (rightStringsHd, 0, strLength)
val sub2 = String.substring val strSub2 = String.substring
(rightStringsHd, strLength, String.size rightStringsHd - strLength) (rightStringsHd, strLength, String.size rightStringsHd - strLength)
val midpoint = binSearch (String.size strSub1, rightStringsHd) val midpoint = binSearch (String.size strSub1, rightLinesHd)
in in
if if
isThreeInLimit (strSub1, newString, strSub2, leftLinesHd, newLines) isThreeInLimit (strSub1, newString, strSub2, rightLinesHd, newLines)
then then
(* Join three strings together. *) (* Join three strings together. *)
let let
@@ -533,7 +533,7 @@ struct
val newLeftStringsHd = strSub1 ^ newString val newLeftStringsHd = strSub1 ^ newString
val newLeftLinesHd = val newLeftLinesHd =
Vector.tabulate (Vector.length newLines + midpoint, fn idx => Vector.tabulate (Vector.length newLines + midpoint, fn idx =>
if idx < midpoint then Vector.sub (rightStringsHd, idx) if idx < midpoint then Vector.sub (rightLinesHd, idx)
else Vector.sub (newLines, idx - midpoint) + String.size strSub1) else Vector.sub (newLines, idx - midpoint) + String.size strSub1)
val newRightLinesHd = val newRightLinesHd =
@@ -552,33 +552,32 @@ struct
else if else if
String.size newString + String.size strSub2 <= stringLimit String.size newString + String.size strSub2 <= stringLimit
andalso andalso
(Vector.length leftLinesHd - midpoint) + Vector.length newLines (Vector.length rightLinesHd - midpoint) + Vector.length newLines
<= vecLimit <= vecLimit
then then
(* If we can join newString/line with sub2 while staying (* If we can join newString/line with sub2 while staying
* in limit. *) * in limit. *)
let let
val newRightStringsHd = newString ^ strSub2 val newRightStringsHd = newString ^ strSub2
val newRightLinesHd = Vector.tabulate val newRightLinesHd =
(Vector.length newLines Vector.tabulate
+ ( Vector.length newLines + Vector.length rightLinesHd - midpoint
( Vector.length rightLinesHd - midpoint , fn idx =>
, fn idx => if idx < Vector.length newLines then
if idx < Vector.length newLines then Vector.sub (newLines, idx)
Vector.sub (newLines, idx) else
else Vector.sub (rightLinesHd, idx - Vector.length newLines)
Vector.sub (rightLinesHd, idx - Vector.length newLines) + String.size newString
+ String.size newString )
))
val newLeftLinesHd = val newLeftLinesHd =
VectorSlice.slice (rightLinesHd, 0, SOME midpoint) VectorSlice.slice (rightLinesHd, 0, SOME midpoint)
val newLeftLinesHd = VectorSlice.vector newLeftLinesHd val newLeftLinesHd = VectorSlice.vector newLeftLinesHd
in in
{ idx = curIdx + String.size strSub1 { idx = curIdx + String.size strSub1
, line = curLine = Vector.length newLeftLinesHd , line = curLine + Vector.length newLeftLinesHd
, leftStrings = strSub1 :: leftStrings , leftStrings = strSub1 :: leftStrings
, leftLines = newLeftLinesHd :: leftLines , leftLines = newLeftLinesHd :: leftLines
, rightStrings = newRightLinesHd :: rightStringsTl , rightStrings = newRightStringsHd :: rightStringsTl
, rightLines = newRightLinesHd :: rightLinesTl , rightLines = newRightLinesHd :: rightLinesTl
} }
end end
@@ -661,10 +660,22 @@ struct
, nextIdx , nextIdx
, curLine + Vector.length rightLinesHd , curLine + Vector.length rightLinesHd
, rightStringsHd :: leftStrings , rightStringsHd :: leftStrings
, rightLinesHd :: leftStrings , rightLinesHd :: leftLines
, rightStringsTl , rightStringsTl
, rightLinesTl , rightLinesTl
)) )
| (_, _) =>
moveRightAndIns
( idx
, newString
, newLines
, nextIdx
, curLine + Vector.length rightLinesHd
, rightStringsHd :: leftStrings
, rightLinesHd :: leftLines
, rightStringsTl
, rightLinesTl
))
else else
(* Need to insert in the middle of the right string's hd. *) (* Need to insert in the middle of the right string's hd. *)
insInRightList insInRightList