[q-lang-users] Float * Big Integers
Brought to you by:
agraef
From: Eddie R. <ed...@bm...> - 2006-10-19 14:03:05
|
Im' curious to what is the correct way to format equations in Q. Is the following proper? On a line wrap, should || come at the end of the current line or the beginning of the next line? Should I mix styles or should I always be consistent (I would think always consistent but see below)? Eddie fac 0 = 1; fac N:Int = assert (N >= 0) || N * fac (N-1); /* or if the line is short should I freely mix styles fac 0 = 1; fac N:Int = assert (N >= 0) || N * fac (N-1); */ partialFac 0 R:Int = 1; partialFac R:Int R:Int = assert (R >= 0) || 1; partialFac N:Int R:Int = assert ((N >= 0) and (R >= 0)) || N * partialFac (N-1) R; comb N:Int R:Int = 0 if N < R; = (partialFac N R) div (fac (N-R)) if R >= (N-R); = (partialFac N (N-R)) div (fac R) otherwise; binomial X:Int N:Int P:Float = assert ((X >= 0) and (0<=P) and (P<=1)) || (comb N X) * (P^X) * (1-P)^(N-X); |