### Related

##### arrayapply-arrayinfo-block-cons-if-sort

P [s1,s2,s3,s4,s5] :=...

P[2,2,2,2,2];

g[s1,s2,s3,s4,s5] := ...

Calculate

##### arrayapply-arrayinfo-block-cons-if-sort

P [s1,s2,s3,s4,s5] :=...

srt[s1,s2,s3,s4,s5] :...

P [s1,s2,s3,s4,s5] :=...

Calculate

? arrayapply;

Calculate

##### arrayapply

arrayapply (A, [2,3,4...

Calculate

##### arrayapply-arrayinfo-block-cons-if-sort

P [s1,s2,s3,s4,s5] :=...

P[2,2,2,2,2];

g[s1,s2,s3,s4,s5] := ...

Calculate

##### arrayapply-arrayinfo-block-cons-if-sort

P [s1,s2,s3,s4,s5] :=...

srt[s1,s2,s3,s4,s5] :...

P [s1,s2,s3,s4,s5] :=...

Calculate

? arrayapply;

Calculate

##### arrayapply

arrayapply (A, [2,3,4...

Calculate

### arrayapply

Run Example
```(%i1)arrayapply (A, [2,3,4,5,6,7,8]);
(%o1)                        A
2, 3, 4, 5, 6, 7, 8
(%i2) ```
Run Example
```? arrayapply;

-- Function: arrayapply (<A>, [<i_1>, ..., <i_n>])
Evaluates `<A> [<i_1>, ..., <i_n>]', where <A> is an array and
<i_1>, ..., <i_n> are integers.

This is reminiscent of `apply', except the first argument is an

(%o1)                                true
(%i2) ```
Run Example
```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 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) );
(%o3) 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
(%i4) P[2,2,2,2,2];
1
(%o4)                                  -
5
(%i5) g[s1,s2,s3,s4,s5] := cons(s1 , sort([s2,s3,s4,s5]));
(%o5)       g                   := cons(s1, sort([s2, s3, s4, s5]))
s1, s2, s3, s4, s5
(%i6) arrayapply(P, g[1,5,4,3,2]);
96601
(%o6)                               ------
180180
(%i7) foo[sort([3,5,1,5,1])]:42;
(%o7)                                 42
(%i8) if subvar(foo,sort([3,5,0,5,1]))>
0 then foo[sort([3,5,1,5,1])]+12 else 12;
(%o8) if foo                > 0 then foo                      + 12 else 12
[0, 1, 3, 5, 5]             sort([3, 5, 1, 5, 1])
(%i9) subvar(foo,sort([3,5,e,5,1]))>
0;
(%o9)                       foo                > 0
[1, 3, 5, 5, e]
(%i10) arrayinfo(foo);
(%o10)                  [hashed, 1, [[1, 1, 3, 5, 5]]]
(%i11) ```

### Related Help

Help for Arrayapply