<<     >>

APL Exercises 9
Power Operator
 

⎕io←0 throughout.
 

9.0 Drills I

Predict the result of each expression before evaluating it.

1∘+⍣3 ⊢0
1∘+⍣4 ⊢0
{⍵+1}⍣3 ⊢0
{⍵+1}⍣4 ⊢0
×⍨⍣3 ⊢2
×⍨⍣2 ⊢2
×⍨⍣1 ⊢2
×⍨⍣0 ⊢2
{×⍨⍣⍵⊢2}¨⍳4

9.1 Drills II

Predict the result of each expression before evaluating it.

{2÷⍨⍵+2÷⍵}⍣1⊢ 1
{2÷⍨⍵+2÷⍵}⍣2⊢ 1
{2÷⍨⍵+2÷⍵}⍣3⊢ 1
{{2÷⍨⍵+2÷⍵}⍣⍵⊢1}¨⍳10
{2÷⍨⍵+2÷⍵}⍣≡ 1
3 {2÷⍨⍵+⍺÷⍵}⍣≡ 1
4 {2÷⍨⍵+⍺÷⍵}⍣≡ 1
5 {2÷⍨⍵+⍺÷⍵}⍣≡ 1

9.2 Binomial Coefficients

The binomial coefficients of order can be written as a recursion:

   bc←{0=⍵:,1 ⋄ (t,0)+0,t←∇ ⍵-1}

   bc 3
1 3 3 1
   bc 4
1 4 6 4 1
   bc 5
1 5 10 10 5 1

Write a function to compute the binomial coefficients of order using the power operator, without recursion.