File: filt_multinomial

package info (click to toggle)
saml 970418-3
  • links: PTS
  • area: main
  • in suites: slink
  • size: 1,204 kB
  • ctags: 1,701
  • sloc: ansic: 17,182; sh: 2,583; yacc: 497; perl: 264; makefile: 250; python: 242
file content (13 lines) | stat: -rwxr-xr-x 381 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
#!/usr/bin/perl
# Computes multinomial coeeficients. If a line containing x1...xN is read,
# then (x1+...+xN)! / x1! / ... / xN! is returned.
open(STDOUT, "|samuel -bZ") || die;
select(STDIN); $|=1; select(STDOUT); $|=1;
while (<STDIN>) {
	chop; s/^\s+//;
	@args = split;
	print "fact(",join("+",@args),")";
	foreach $x (@args) { print "/fact($x)"; }
	print ";\n";
}
close STDOUT;