Jump to content

Sorting algorithms/Shell sort: Difference between revisions

(→‎{{header|Haskell}}: forgot trialing part of invColumnize)
Line 410:
4231; 1693; 673; 269; 107; 43; 17; 7; 3; 1 |] in
for k = 0 to pred(Array.lengthiter incSequence)(increment do->
if (increment * 2) <= len then
try
if (incSequence.(k) * 2) > len then raise Continue;
let increment = incSequence.(k) in
for i = increment to pred len do
let temp = a.(i) in
let rec loop j =
if j < 0 || a.(j) <= temp then (j)
else begin
if a.(j + increment) <= temp then- a.(j);
elseloop begin(j - increment)
a.(j + increment) <- a.(j);
loop (j - increment)
end
end
in
Line 429 ⟶ 424:
a.(j + increment) <- temp;
done;
) incSequence;
with Continue -> ()
done;
;;</lang>
and the main:
Line 440 ⟶ 434:
in
shellsort intArray;
Array.iter (funPrintf.printf v" ->%d") intArray;
Printf.printf " %d" v;
) intArray;
print_newline();
;;</lang>
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.