login  home  contents  what's new  discussion  bug reports     help  links  subscribe  changes  refresh  edit

Edit detail for SandBoxChoose revision 1 of 6

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}

fricas
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
Type: Void

fricas
choose([1,2,3],1)
fricas
Compiling function choose with type (List(PositiveInteger),
      PositiveInteger) -> List(List(PositiveInteger))

\label{eq1}\left[{\left[ 1 \right]}, \:{\left[ 2 \right]}, \:{\left[ 3 \right]}\right](1)
Type: List(List(PositiveInteger?))
fricas
choose([1,2,3],2)

\label{eq2}\left[{\left[ 1, \: 2 \right]}, \:{\left[ 1, \: 3 \right]}, \:{\left[ 2, \: 3 \right]}\right](2)
Type: List(List(PositiveInteger?))
fricas
choose([1,2,3],3)

\label{eq3}\left[{\left[ 1, \: 2, \: 3 \right]}\right](3)
Type: List(List(PositiveInteger?))
fricas
choose([x,y,z,w],1)
fricas
Compiling function choose with type (List(OrderedVariableList([x,y,z
      ,w])),PositiveInteger) -> List(List(OrderedVariableList([x,y,z,w]
      )))

\label{eq4}\left[{\left[ x \right]}, \:{\left[ y \right]}, \:{\left[ z \right]}, \:{\left[ w \right]}\right](4)
Type: List(List(OrderedVariableList?([x,y,z,w])))
fricas
choose([x,y,z,w],2)

\label{eq5}\left[{\left[ x , \: y \right]}, \:{\left[ x , \: z \right]}, \:{\left[ x , \: w \right]}, \:{\left[ y , \: z \right]}, \:{\left[ y , \: w \right]}, \:{\left[ z , \: w \right]}\right](5)
Type: List(List(OrderedVariableList?([x,y,z,w])))
fricas
choose([x,y,z,w],3)

\label{eq6}\left[{\left[ x , \: y , \: z \right]}, \:{\left[ x , \: y , \: w \right]}, \:{\left[ x , \: z , \: w \right]}, \:{\left[ y , \: z , \: w \right]}\right](6)
Type: List(List(OrderedVariableList?([x,y,z,w])))
fricas
choose([x,y,z,w],4)

\label{eq7}\left[{\left[ x , \: y , \: z , \: w \right]}\right](7)
Type: List(List(OrderedVariableList?([x,y,z,w])))