# 2.11BSD#431 - /usr/src/new/OLD/apl/src/af.c

##### Functions

    ex_deal           X
    ex_rand           X

##### Macros

    MAXRAND           X

       1: static char Sccsid[] = "af.c @(#)af.c	1.1	10/1/82 Berkeley ";
       2: #include "apl.h"
       3:
       4: #ifdef vax
       5: #define MAXRAND 2147483648.
       6: #else
       7: #define MAXRAND 32768.
       8: #endif
       9:
      10: ex_deal()
      11: {
      12:     register struct item *p;
      13:     register m, n;
      14:     double f;
      15:     data d1, d2;
      16:
      17:     m = topfix();
      18:     n = topfix();
      19:     if(m < 0 || m > n)
      20:         error("deal D");
      21:     p = newdat(DA, 1, m);
      22:     datum = thread.iorg;
      23:     for(; n!=0; n--) {
      24:         f = m;
      25:         f /= n;
      26:         if(rand()/MAXRAND < f) {
      27:             putdat(p, datum);
      28:             m--;
      29:         }
      30:         datum += one;
      31:     }
      32:     m = p->size;
      33:     while(m > 0) {
      34:         f = rand()/MAXRAND;
      35:         n = m * f;
      36:         m--;
      37:         if(n != m) {
      38:             p->index = n;
      39:             d1 = getdat(p);
      40:             p->index = m;
      41:             d2 = getdat(p);
      42:             p->index = n;
      43:             putdat(p, d2);
      44:             p->index = m;
      45:             putdat(p, d1);
      46:         }
      47:     }
      48:     *sp++ = p;
      49: }
      50:
      51: data
      52: ex_rand(d)
      53: data d;
      54: {
      55:     double f;
      56:
      57:     f = (rand()/MAXRAND) * d;
      58:     d = floor(f) + thread.iorg;
      59:     return(d);
      60: }

#### Defined functions

ex_deal defined in line 10; used 2 times

- in /usr/src/new/OLD/apl/src/at.c line 32, 159

ex_rand defined in line 51; used 2 times

- in /usr/src/new/OLD/apl/src/at.c line 102, 160

#### Defined variables

Sccsid defined in line 1; never used

#### Defined macros

MAXRAND defined in line 7; used 3 times

- in line 26, 34, 57

Last modified: 1986-10-21 Generated: 2016-12-26 | Generated by src2html V0.67 page hit count: 492 |