amend lambdas in search-list.sml's 'moveRightAndMap' function, where wrong variable was used in lambda, and rename 'num' variable in that function to 'from' to make purpose and intent clearer
This commit is contained in:
@@ -462,31 +462,31 @@ struct
|
|||||||
end
|
end
|
||||||
| [] => {left = left, right = right}
|
| [] => {left = left, right = right}
|
||||||
|
|
||||||
fun moveRightAndMap (num, mapBy, left, right) =
|
fun moveRightAndMap (from, mapBy, left, right) =
|
||||||
case right of
|
case right of
|
||||||
hd :: tl =>
|
hd :: tl =>
|
||||||
let
|
let
|
||||||
val lastIdx = Vector.length hd - 1
|
val lastIdx = Vector.length hd - 1
|
||||||
val last = Vector.sub (hd, lastIdx)
|
val last = Vector.sub (hd, lastIdx)
|
||||||
in
|
in
|
||||||
if num > last then
|
if from > last then
|
||||||
moveRightAndMap (num, mapBy, joinEndOfLeft (hd, left), tl)
|
moveRightAndMap (from, mapBy, joinEndOfLeft (hd, left), tl)
|
||||||
else if num < last then
|
else if from < last then
|
||||||
(* need to map in middle *)
|
(* need to map in middle *)
|
||||||
let
|
let
|
||||||
val startIdx = BinSearch.equalOrMore (num, hd)
|
val startIdx = BinSearch.equalOrMore (from, hd)
|
||||||
val mapEl = Vector.sub (hd, startIdx)
|
val mapEl = Vector.sub (hd, startIdx)
|
||||||
val newHd =
|
val newHd =
|
||||||
Vector.map (fn el => if el < mapEl then el else mapEl + mapBy)
|
Vector.map (fn el => if el < from then el else el + mapBy)
|
||||||
hd
|
hd
|
||||||
in
|
in
|
||||||
mapRight (mapBy, joinEndOfLeft (newHd, left), tl)
|
mapRight (mapBy, joinEndOfLeft (newHd, left), tl)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
(* num = last *)
|
(* from = last *)
|
||||||
let
|
let
|
||||||
val newHd =
|
val newHd =
|
||||||
Vector.map (fn el => if el < num then num else num + mapBy) hd
|
Vector.map (fn el => if el < from then el else el + mapBy) hd
|
||||||
in
|
in
|
||||||
mapRight (mapBy, joinEndOfLeft (newHd, left), tl)
|
mapRight (mapBy, joinEndOfLeft (newHd, left), tl)
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user