Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,24 @@
-module(quickselect).
-export([test/0]).
test() ->
V = [9, 8, 7, 6, 5, 0, 1, 2, 3, 4],
lists:map(
fun(I) -> quickselect(I,V) end,
lists:seq(0, length(V) - 1)
).
quickselect(K, [X | Xs]) ->
{Ys, Zs} =
lists:partition(fun(E) -> E < X end, Xs),
L = length(Ys),
if
K < L ->
quickselect(K, Ys);
K > L ->
quickselect(K - L - 1, Zs);
true ->
X
end.