Sponsored links: Algebra eBooks
 

Related

sort

a:[2,3,5,1,6,7];

sort(a,"<");

b:a;

Calculate

sort

b:sort([7, 0, 6, 0, 3...

b[1];

Calculate

sort

sort([N*j + i - 1, N*...

Calculate

sort

a:[2,3,5,1,6,7];

sort(a,">");

Calculate

sort

l: [2,1,4,3];

o: sort(l);

Calculate

sort

sort([2, -2]);

Calculate

sort

sort([2, -2]);

Calculate

sort

b:sort([7, 0, 6, 0, 3...

b[1]*10^0;

Calculate

sort

b:sort([7, 0, 6, 0, 3...

b[1]*10^0;

+b[2]*10^1;

Calculate

sort

a = sort([1, 7, 3, 56...

a;

Calculate

sort

Run Example
(%i1)P [s1,s2,s3,s4,s5] := block ( [tot: s1+s2+s3+s4+s5] , s1/tot*(if (s1>
1) then P [s1-1,s2,s3,s4,s5] else 1)+(if s2<
=1 then 0 else P [s1,s2-1,s3,s4,s5]*s2/tot)+(if s3<
=1 then 0 else P [s1,s2,s3-1,s4,s5]*s3/tot)+(if s4<
=1 then 0 else P [s1,s2,s3,s4-1,s5]*s4/tot)+(if s5<
=1 then 0 else P [s1,s2,s3,s4,s5-1]*s5/tot) );
(%o1) P                   := block([tot : s1 + s2 + s3 + s4 + s5], 
       s1, s2, s3, s4, s5
s1
--- (if s1 > 1 then P                       else 1)
tot                  s1 - 1, s2, s3, s4, s5
                           P                       s2
                            s1, s2 - 1, s3, s4, s5
 + (if s2 <= 1 then 0 else --------------------------)
                                      tot
                           P                       s3
                            s1, s2, s3 - 1, s4, s5
 + (if s3 <= 1 then 0 else --------------------------)
                                      tot
                           P                       s4
                            s1, s2, s3, s4 - 1, s5
 + (if s4 <= 1 then 0 else --------------------------)
                                      tot
                           P                       s5
                            s1, s2, s3, s4, s5 - 1
 + (if s5 <= 1 then 0 else --------------------------))
                                      tot
(%i2) srt[s1,s2,s3,s4,s5] := cons(s1, sort([s2,s3,s4,s5]));
(%o2)      srt                   := cons(s1, sort([s2, s3, s4, s5]))
              s1, s2, s3, s4, s5
(%i3) P [s1,s2,s3,s4,s5] := block ( [tot: s1+s2+s3+s4+s5] , s1/tot*(if (s1>
1) then arrayapply(P, srt[s1-1,s2,s3,s4,s5]) else 1)+(if s2<
=1 then 0 else arrayapply(P, srt[s1,s2-1,s3,s4,s5])*s2/tot)+(if s3<
=1 then 0 else arrayapply(P, srt[s1,s2,s3-1,s4,s5])*s3/tot)+(if s4<
=1 then 0 else arrayapply(P, srt[s1,s2,s3,s4-1,s5])*s4/tot)+(if s5<
=1 then 0 else arrayapply(P, srt[s1,s2,s3,s4,s5-1])*s5/tot) );
(%o3) P                   := block([tot : s1 + s2 + s3 + s4 + s5], 
       s1, s2, s3, s4, s5
s1
--- (if s1 > 1 then arrayapply(P, srt                      ) else 1)
tot                                  s1 - 1, s2, s3, s4, s5
                           arrayapply(P, srt                      ) s2
                                            s1, s2 - 1, s3, s4, s5
 + (if s2 <= 1 then 0 else -------------------------------------------)
                                               tot
                           arrayapply(P, srt                      ) s3
                                            s1, s2, s3 - 1, s4, s5
 + (if s3 <= 1 then 0 else -------------------------------------------)
                                               tot
                           arrayapply(P, srt                      ) s4
                                            s1, s2, s3, s4 - 1, s5
 + (if s4 <= 1 then 0 else -------------------------------------------)
                                               tot
                           arrayapply(P, srt                      ) s5
                                            s1, s2, s3, s4, s5 - 1
 + (if s5 <= 1 then 0 else -------------------------------------------))
                                               tot
(%i4) P[11,12,12,12,12];
                                    497664
(%o4)                               -------
                                    2232265
(%i5) 
Run Example
srt[s1,s2,s3,s4,s5] := cons(s1, sort([s2,s3,s4,s5]));
(%o1)      srt                   := cons(s1, sort([s2, s3, s4, s5]))
              s1, s2, s3, s4, s5
(%i2) P [s1,s2,s3,s4,s5] := block ( [tot: s1+s2+s3+s4+s5] , s1/tot*(if (s1>
1) then arrayapply(P, srt[s1-1,s2,s3,s4,s5]) else 1)+(if s2<
=1 then 0 else arrayapply(P, srt[s1,s2-1,s3,s4,s5])*s2/tot)+(if s3<
=1 then 0 else arrayapply(P, srt[s1,s2,s3-1,s4,s5])*s3/tot)+(if s4<
=1 then 0 else arrayapply(P, srt[s1,s2,s3,s4-1,s5])*s4/tot)+(if s5<
=1 then 0 else arrayapply(P, srt[s1,s2,s3,s4,s5-1])*s5/tot) );
(%o2) P                   := block([tot : s1 + s2 + s3 + s4 + s5], 
       s1, s2, s3, s4, s5
s1
--- (if s1 > 1 then arrayapply(P, srt                      ) else 1)
tot                                  s1 - 1, s2, s3, s4, s5
                           arrayapply(P, srt                      ) s2
                                            s1, s2 - 1, s3, s4, s5
 + (if s2 <= 1 then 0 else -------------------------------------------)
                                               tot
                           arrayapply(P, srt                      ) s3
                                            s1, s2, s3 - 1, s4, s5
 + (if s3 <= 1 then 0 else -------------------------------------------)
                                               tot
                           arrayapply(P, srt                      ) s4
                                            s1, s2, s3, s4 - 1, s5
 + (if s4 <= 1 then 0 else -------------------------------------------)
                                               tot
                           arrayapply(P, srt                      ) s5
                                            s1, s2, s3, s4, s5 - 1
 + (if s5 <= 1 then 0 else -------------------------------------------))
                                               tot
(%i3) udskriv (n) := [n,n*100.0];
(%o3)                     udskriv(n) := [n, n 100.0]
(%i4) udskriv(P[1,3,3,3,3]);
                            243
(%o4)                      [---, 53.40659340659341]
                            455
(%i5) 
Run Example
srt[s1,s2,s3,s4,s5] := cons(s1, sort([s2,s3,s4,s5]));
(%o1)      srt                   := cons(s1, sort([s2, s3, s4, s5]))
              s1, s2, s3, s4, s5
(%i2) P [s1,s2,s3,s4,s5] := block ( [tot: s1+s2+s3+s4+s5] , s1/tot*(if (s1>
1) then arrayapply(P, srt[s1-1,s2,s3,s4,s5]) else 1)+(if s2<
=1 then 0 else arrayapply(P, srt[s1,s2-1,s3,s4,s5])*s2/tot)+(if s3<
=1 then 0 else arrayapply(P, srt[s1,s2,s3-1,s4,s5])*s3/tot)+(if s4<
=1 then 0 else arrayapply(P, srt[s1,s2,s3,s4-1,s5])*s4/tot)+(if s5<
=1 then 0 else arrayapply(P, srt[s1,s2,s3,s4,s5-1])*s5/tot) );
(%o2) P                   := block([tot : s1 + s2 + s3 + s4 + s5], 
       s1, s2, s3, s4, s5
s1
--- (if s1 > 1 then arrayapply(P, srt                      ) else 1)
tot                                  s1 - 1, s2, s3, s4, s5
                           arrayapply(P, srt                      ) s2
                                            s1, s2 - 1, s3, s4, s5
 + (if s2 <= 1 then 0 else -------------------------------------------)
                                               tot
                           arrayapply(P, srt                      ) s3
                                            s1, s2, s3 - 1, s4, s5
 + (if s3 <= 1 then 0 else -------------------------------------------)
                                               tot
                           arrayapply(P, srt                      ) s4
                                            s1, s2, s3, s4 - 1, s5
 + (if s4 <= 1 then 0 else -------------------------------------------)
                                               tot
                           arrayapply(P, srt                      ) s5
                                            s1, s2, s3, s4, s5 - 1
 + (if s5 <= 1 then 0 else -------------------------------------------))
                                               tot
(%i3) P[1,3,3,3,3];
                                      243
(%o3)                                 ---
                                      455
(%i4) %o3 *100.0;
(%o4)          100.0 
[abs,block,length,makelist,random,sort] [append,exp,false,if,max,random,sort,true,while] [append,listify,setify,sort,sqrt,transpose] [apply,cos,fpprec,li,load,makelist,outermap,plot2d,round,sin,sort,string] [apply,do,first,genmatrix,kill,makelist,ordergreatp,permanent,permutations,print,random,rest,row,sort,sum] [array,arrayapply,block,if,sort] [arrayapply,arrayinfo,block,cons,if,sort] [arrayinfo,block,cons,if,sort] [arrayinfo,block,if,sort,subvar] [arrayinfo,block,if,sort] [assume,sort] [block,cons,if,linsolve,sort] [block,cons,if,sort,xreduce] [block,cons,if,sort] [block,cos,flatten,if,li,load,makelist,map,numer,outermap,plot2d,sin,sort,unique] [block,cos,flatten,if,map,numer,outermap,plot2d,sin,sort,unique] [block,do,simp,sort,true] [block,if,sort] [block,length,makelist,random,sort] [block,sort] [ceiling,col,do,endcons,float,genmatrix,kill,makelist,min,permanent,print,random,row,sort,sqrt,transpose] [ceiling,do,float,genmatrix,kill,makelist,ordergreatp,permanent,print,random,row,sort,sqrt,sum] [col,cons,endcons,genmatrix,kill,min,permanent,print,random,row,sort,sqrt,transpose] [col,disp,genmatrix,min,numer,permanent,random,row,sort,sqrt,transpose] [col,do,endcons,genmatrix,kill,makelist,min,permanent,print,random,row,sort,sqrt,transpose] [col,do,endcons,genmatrix,kill,min,permanent,print,random,row,sort,sqrt,transpose] [col,genmatrix,min,numer,permanent,print,random,row,sort,sqrt,transpose] [col,genmatrix,min,numer,permanent,random,row,sort,sqrt,transpose] [cos,flatten,if,li,load,makelist,map,numer,outermap,plot2d,sin,sort,unique] [cos,flatten,li,load,makelist,map,numer,outermap,plot2d,sin,sort,unique] [cos,flatten,li,load,makelist,map,outermap,plot2d,sin,sort,string] [cos,fpprec,li,load,makelist,outermap,plot2d,round,sin,sort,string] [delete,every,full_listify,lambda,listify,makelist,map,mod,primep,set_partitions,sort,sublist] [display,length,listify,makelist,map,powerset,setify,sort,sqrt] [do,first,genmatrix,kill,makelist,max,ordergreatp,permanent,permutations,print,random,rest,row,sort,sum] [do,first,genmatrix,kill,makelist,min,ordergreatp,permanent,permutations,print,random,rest,row,sort,sum] [do,genmatrix,kill,makelist,ordergreatp,permanent,print,random,row,sort,sum] [eval_string,flatten,full_listify,lambda,listify,lreduce,maplist,mod,permut,powerset,setify,sort,string] [eval_string,lambda,lreduce,map,permut,sort,string] [floor,length,makelist,plot2d,realroots,reverse,solve,sort] [genmatrix,makelist,random,row,sort,sqrt,sum] [genmatrix,makelist,random,row,sort,sqrt] [lambda,sort] [length,listify,makelist,map,powerset,setify,sort,sqrt] [linsolve,sort] [load,sort] [makelist,map,powerset,sort,sqrt,transpose] [makelist,random_permutation,rest,sort] [reverse,sort] [sort]

Related Help

Help for Sort