From 0ba56bf6d327e4859adbb8e8e1556ebe272739c1 Mon Sep 17 00:00:00 2001 From: Humza Shahid Date: Sat, 16 Nov 2024 04:55:02 +0000 Subject: [PATCH] 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 --- fcore/search-list.sml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/fcore/search-list.sml b/fcore/search-list.sml index c2f7fac..b60bf72 100644 --- a/fcore/search-list.sml +++ b/fcore/search-list.sml @@ -462,31 +462,31 @@ struct end | [] => {left = left, right = right} - fun moveRightAndMap (num, mapBy, left, right) = + fun moveRightAndMap (from, mapBy, left, right) = case right of hd :: tl => let val lastIdx = Vector.length hd - 1 val last = Vector.sub (hd, lastIdx) in - if num > last then - moveRightAndMap (num, mapBy, joinEndOfLeft (hd, left), tl) - else if num < last then + if from > last then + moveRightAndMap (from, mapBy, joinEndOfLeft (hd, left), tl) + else if from < last then (* need to map in middle *) let - val startIdx = BinSearch.equalOrMore (num, hd) + val startIdx = BinSearch.equalOrMore (from, hd) val mapEl = Vector.sub (hd, startIdx) 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 in mapRight (mapBy, joinEndOfLeft (newHd, left), tl) end else - (* num = last *) + (* from = last *) let 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 mapRight (mapBy, joinEndOfLeft (newHd, left), tl) end