mirror of
https://github.com/filebrowser/filebrowser.git
synced 2025-05-10 04:02:57 +00:00

Former-commit-id: bdede6ed1b6f578f2ef046c338caf02d0b29d453 [formerly 7187de361b53e9c8ec121df379b762f2db736ea2] Former-commit-id: 447d58460fbbfd05ffe08428a1288e392637561d
18 lines
498 B
Plaintext
18 lines
498 B
Plaintext
partition([], _, [], []).
|
|
partition([X|Xs], Pivot, Smalls, Bigs) :-
|
|
( X @< Pivot ->
|
|
Smalls = [X|Rest],
|
|
partition(Xs, Pivot, Rest, Bigs)
|
|
; Bigs = [X|Rest],
|
|
partition(Xs, Pivot, Smalls, Rest)
|
|
).
|
|
|
|
quicksort([]) --> [].
|
|
quicksort([X|Xs]) -->
|
|
{ partition(Xs, X, Smaller, Bigger) },
|
|
quicksort(Smaller), [X], quicksort(Bigger).
|
|
|
|
perfect(N) :-
|
|
between(1, inf, N), U is N // 2,
|
|
findall(D, (between(1,U,D), N mod D =:= 0), Ds),
|
|
sumlist(Ds, N). |