Ascending sorting

Description

Sorting elements from the lowest to the greatest

Source: PROLOG str. 190 Wydawnictwo PLJ Warszawa 1991 ISBN 83-85190-63-5

Download

Program source code: ascending_sorting.pl

Listing

rosn([], []).
rosn([X|T], S1) :- rosn(T, St), wstaw(X, St, S1).
wstaw(X, [Y|S1], [Y|Sl1]) :- X>Y, !, wstaw(X, S1, Sl1).
wstaw(X, S1, [X|S1]).
 
test :- rosn([4, 7, 9, 5, 2], R).

Comments

pl/prolog/pllib/ascending_sorting.txt · ostatnio zmienione: 2023/01/23 11:10 przez ikaf
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0