Algorithm time...
Dick Kriesel
dick.kriesel at mail.com
Sun Dec 9 19:07:16 EST 2012
Hi, Glen. I've reread your replies. Here's a new version that returns the original values, as needed.
Please test and report again.
-- Dick
<postScript>
function digest @pLines
local tGroupSize, tLineNumber, tArray, tKeys, tMin, tMax, tResult
put number of lines in pLines div 1000 into tGroupSize
set the itemDelimiter to tab
repeat for each line tLine in pLines
add 1 to tLineNumber
if tArray[ item 2 of tLine ] is empty then
put item 1 of tLine into tArray[ item 2 of tLine ]
end if
if tLineNumber is tGroupSize then
put the keys of tArray into tKeys
replace cr with comma in tKeys
put min( tKeys ) into tMin
put max( tKeys ) into tMax
if tArray[ tMin ] < tArray[ tMax ] then
put tArray[ tMin ] & tab & tMin & cr after tResult
put tArray[ tMax ] & tab & tMax & cr after tResult
else
put tArray[ tMax ] & tab & tMax & cr after tResult
put tArray[ tMin ] & tab & tMin & cr after tResult
end if
put 0 into tLineNumber
put empty into tArray
end if
end repeat
return tResult
end digest
</postScript>
More information about the use-livecode
mailing list