home *** CD-ROM | disk | FTP | other *** search
- eos="eos";
- ch1=channel();
- ch2=channel();
- task sort(inp,out;x,y,succ) {
- inp?x;if (x==eos) {out!x;skip;}
- succ=channel(); start sort(succ,out);
- while (true)
- {inp?y;if(y==eos) {out!x;succ!y;skip;}
- if(x>y) {succ!x;x=y;} else succ!y;
- } };
- task source(out) {
- out!5;out!1;out!2;out!4;out!3;out!7;out!8;out!6;out!eos;};
- task sink(inp;x) {
- inp?x;while(x!=eos) {print x;inp?x;}};
- task main() {start source(ch1);start sort(ch1,ch2);start sink(ch2);};
- end
-