|
|
last edited 10 years ago by Bill Page |
1 2 3 4 5 6 | ||
Editor: Bill Page
Time: 2014/09/19 05:16:59 GMT+0 |
||
Note: |
changed: - \begin{axiom} choose(a,n) == j:=[i for i in 1..n] r:=[[a(j(i)) for i in 1..n]] while j(n)<=#a repeat --output j j(n):=j(n)+1 k:=n while j(n)>#a and k>1 repeat k:=k-1 j(k):=j(k)+1 for i in k..n-1 repeat j(i+1):=j(i)+1 if j(n)<=#a then r:=concat(r,[a(j(i)) for i in 1..n]) if binomial(#a,n)~=#r then error "error in choose" return r \end{axiom} \begin{axiom} choose([1,2,3],1) choose([1,2,3],2) choose([1,2,3],3) choose([x,y,z,w],1) choose([x,y,z,w],2) choose([x,y,z,w],3) choose([x,y,z,w],4) \end{axiom}
choose(a,n) == j:=[i for i in 1..n] r:=[[a(j(i)) for i in 1..n]] while j(n)<=#a repeat --output j j(n):=j(n)+1 k:=n while j(n)>#a and k>1 repeat k:=k-1 j(k):=j(k)+1 for i in k..n-1 repeat j(i+1):=j(i)+1 if j(n)<=#a then r:=concat(r, [a(j(i)) for i in 1..n]) if binomial(#a, n)~=#r then error "error in choose" return r
choose([1,2, 3], 1)
Compiling function choose with type (List(PositiveInteger),PositiveInteger) -> List(List(PositiveInteger))
(1) |
choose([1,2, 3], 2)
(2) |
choose([1,2, 3], 3)
(3) |
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] )))
(4) |
choose([x,y, z, w], 2)
(5) |
choose([x,y, z, w], 3)
(6) |
choose([x,y, z, w], 4)
(7) |