Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,31 @@
|
|||
fun lis cmp n =
|
||||
let
|
||||
val pile_tops = DynamicArray.array (length n, [])
|
||||
fun bsearch_piles x =
|
||||
let
|
||||
fun aux (lo, hi) =
|
||||
if lo > hi then
|
||||
lo
|
||||
else
|
||||
let
|
||||
val mid = (lo + hi) div 2
|
||||
in
|
||||
if cmp (hd (DynamicArray.sub (pile_tops, mid)), x) = LESS then
|
||||
aux (mid+1, hi)
|
||||
else
|
||||
aux (lo, mid-1)
|
||||
end
|
||||
in
|
||||
aux (0, DynamicArray.bound pile_tops)
|
||||
end
|
||||
fun f x =
|
||||
let
|
||||
val i = bsearch_piles x
|
||||
in
|
||||
DynamicArray.update (pile_tops, i,
|
||||
x :: (if i = 0 then [] else DynamicArray.sub (pile_tops, i-1)))
|
||||
end
|
||||
in
|
||||
app f n;
|
||||
rev (DynamicArray.sub (pile_tops, DynamicArray.bound pile_tops))
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue