home *** CD-ROM | disk | FTP | other *** search
/ HomeWare 14 / HOMEWARE14.bin / prog / proxy14.arj / SORT.PRX < prev    next >
Text File  |  1994-03-03  |  533b  |  17 lines

  1. eos="eos";
  2. ch1=channel();
  3. ch2=channel();
  4. task sort(inp,out;x,y,succ) {
  5.                              inp?x;if (x==eos) {out!x;skip;}
  6.  succ=channel(); start sort(succ,out);
  7.  while (true)
  8.   {inp?y;if(y==eos) {out!x;succ!y;skip;}
  9.    if(x>y) {succ!x;x=y;} else succ!y;
  10.   } };
  11. task source(out) {
  12.                   out!5;out!1;out!2;out!4;out!3;out!7;out!8;out!6;out!eos;};
  13. task sink(inp;x) {
  14.                   inp?x;while(x!=eos) {print x;inp?x;}};
  15. task main() {start source(ch1);start sort(ch1,ch2);start sink(ch2);};
  16. end
  17.