update
Former-commit-id: bdede6ed1b6f578f2ef046c338caf02d0b29d453 [formerly 7187de361b53e9c8ec121df379b762f2db736ea2] Former-commit-id: 447d58460fbbfd05ffe08428a1288e392637561d
This commit is contained in:
18
_embed/public/ace/demo/kitchen-sink/docs/prolog.plg
Normal file
18
_embed/public/ace/demo/kitchen-sink/docs/prolog.plg
Normal file
@@ -0,0 +1,18 @@
|
||||
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).
|
||||
Reference in New Issue
Block a user