File:  [CSRG BSD Unix] / 41BSD / cmd / apl / af.c
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Tue Apr 24 16:12:53 2018 UTC (8 years, 1 month ago) by root
Branches: MAIN, BSD
CVS tags: HEAD, BSD41
BSD 4.1

#include "apl.h"

ex_deal()
{
	register struct item *p;
	register m, n;
	double f;
	data d1, d2;

	m = topfix();
	n = topfix();
	if(m < 0 || m > n)
		error("deal D");
	p = newdat(DA, 1, m);
	datum = thread.iorg;
	for(; n!=0; n--) {
		f = m;
		f /= n;
		if(rand()/(32768.*32768.*2.) < f) {
			putdat(p, datum);
			m--;
		}
		datum += one;
	}
	m = p->size;
	while(m > 0) {
		f = rand()/(32768.*32768.*2.);
		n = m * f;
		m--;
		if(n != m) {
			p->index = n;
			d1 = getdat(p);
			p->index = m;
			d2 = getdat(p);
			p->index = n;
			putdat(p, d2);
			p->index = m;
			putdat(p, d1);
		}
	}
	push(p);
}

unix.superglobalmegacorp.com

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