|
|
last edited 10 years ago by Bill Page |
1 2 3 4 5 6 | ||
Editor: Bill page
Time: 2014/09/25 16:08:18 GMT+0 |
||
Note: |
added: \begin{equation} \left( {\begin{array}{*{20}c} S \\ k \\ \end{array}} \right) \end{equation} changed: -choose(a,n) == - j:=[i for i in 1..n] - r:=[[a(j(i)) for i in 1..n]] - k:=n - while k>0 and j(k)+n-k<#a repeat - j(k):=j(k)+1 - for i in k..n-1 repeat j(i+1):=j(i)+1 - r:=concat(r,[a(j(i)) for i in 1..n]) - k:=n; while j(k)+n-k>=#a and k>1 repeat k:=k-1 - if binomial(#a,n)~=#r then error "error in choose" - return r choose(S,k) == j:=[i for i in 1..k] R:=[[S(j(i)) for i in 1..k]] n:=k while n>0 and j(n)+k-n<#S repeat j(n):=j(n)+1 for i in n..k-1 repeat j(i+1):=j(i)+1 R:=concat(R,[S(j(i)) for i in 1..k]) n:=k; while j(n)+k-n>=#S and n>1 repeat n:=n-1 if binomial(#S,k)~=#R then error "error in choose" return R added: \begin{equation} \left( {\begin{array}{*{20}c} \{r_1,r_2,r_4 \} \\ 2 \\ \end{array}} \right) = \{ \{r_1,r_2 \} \{r_1,r_4 \} \{r_2,r_4 \} \} \end{equation} \begin{axiom} choose([r[q] for q in 1..4|q~=3],2) \end{axiom} \begin{equation} \left( {\begin{array}{*{20}c} \{r_1,r_2,r_4 \} \\ 2 \\ \end{array}} \right)_2 = \{r_1,r_4 \} \end{equation} \begin{axiom} choose([r[q] for q in 1..4|q~=3],2).2 \end{axiom} added:
(1) |
choose(S,k) == j:=[i for i in 1..k] R:=[[S(j(i)) for i in 1..k]] n:=k while n>0 and j(n)+k-n<#S repeat j(n):=j(n)+1 for i in n..k-1 repeat j(i+1):=j(i)+1 R:=concat(R, [S(j(i)) for i in 1..k]) n:=k; while j(n)+k-n>=#S and n>1 repeat n:=n-1 if binomial(#S, k)~=#R then error "error in choose" return R
(2) |
choose([r[q] for q in 1..4|q~=3],2)
Compiling function choose with type (List(Symbol),PositiveInteger) -> List(List(Symbol))
(3) |
(4) |
choose([r[q] for q in 1..4|q~=3],2).2
(5) |
choose([1],1)
Compiling function choose with type (List(PositiveInteger),PositiveInteger) -> List(List(PositiveInteger))
(6) |
choose([1,2], 1)
(7) |
choose([1,2], 2)
(8) |
choose([1,2, 3], 1)
(9) |
choose([1,2, 3], 2)
(10) |
choose([1,2, 3], 3)
(11) |
choose([x,y, z, w], 1)
Compiling function choose with type (List(OrderedVariableList([x,y, z , w])), PositiveInteger) -> List(List(OrderedVariableList([x, y, z, w] )))
(12) |
choose([x,y, z, w], 2)
(13) |
choose([x,y, z, w], 3)
(14) |
choose([x,y, z, w], 4)
(15) |