% $Id: pst-tools.pro 490 2011-04-23 09:25:30Z herbert $ % %% PostScript tools prologue for pstricks.tex. %% Version 0.01, 2011/04/23 %% %% This program can be redistributed and/or modified under the terms %% of the LaTeX Project Public License Distributed from CTAN archives %% in directory macros/latex/base/lppl.txt. % % %%%%% ### bubblesort ### %% syntax : array bubblesort --> array2 trie par ordre croissant %% code de Bill Casselman %% http://www.math.ubc.ca/people/faculty/cass/graphics/text/www/ /bubblesort { 4 dict begin /a exch def /n a length 1 sub def n 0 gt { % at this point only the n+1 items in the bottom of a remain to % the sorted largest item in that blocks is to be moved up into % position n n { 0 1 n 1 sub { /i exch def a i get a i 1 add get gt { % if a[i] > a[i+1] swap a[i] and a[i+1] a i 1 add a i get a i a i 1 add get % set new a[i] = old a[i+1] put % set new a[i+1] = old a[i] put } if } for /n n 1 sub def } repeat } if a end } def % /concatstringarray{ % [(a) (b) ... (z)] --> (ab...z) 20100422 0 1 index { length add } forall string 0 3 2 roll { 3 copy putinterval length add }forall pop } bind def % /dot2comma {% on stack a string (...) 2 dict begin /Output exch def 0 1 Output length 1 sub { /Index exch def Output Index get 46 eq { Output Index 44 put } if } for Output end } def % %-----------------------------------------------------------------------------% % END pst-tools.pro