Annotation of 40BSD/cmd/apl/af.c, revision 1.1.1.1

1.1       root        1: #include "apl.h"
                      2: 
                      3: ex_deal()
                      4: {
                      5:        register struct item *p;
                      6:        register m, n;
                      7:        double f;
                      8:        data d1, d2;
                      9: 
                     10:        m = topfix();
                     11:        n = topfix();
                     12:        if(m < 0 || m > n)
                     13:                error("deal D");
                     14:        p = newdat(DA, 1, m);
                     15:        datum = thread.iorg;
                     16:        for(; n!=0; n--) {
                     17:                f = m;
                     18:                f /= n;
                     19:                if(rand()/(32768.*32768.*2.) < f) {
                     20:                        putdat(p, datum);
                     21:                        m--;
                     22:                }
                     23:                datum += one;
                     24:        }
                     25:        m = p->size;
                     26:        while(m > 0) {
                     27:                f = rand()/(32768.*32768.*2.);
                     28:                n = m * f;
                     29:                m--;
                     30:                if(n != m) {
                     31:                        p->index = n;
                     32:                        d1 = getdat(p);
                     33:                        p->index = m;
                     34:                        d2 = getdat(p);
                     35:                        p->index = n;
                     36:                        putdat(p, d2);
                     37:                        p->index = m;
                     38:                        putdat(p, d1);
                     39:                }
                     40:        }
                     41:        push(p);
                     42: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.