>>  <<  Usr  Pri  JfC  LJ  Phr  Dic  Rel  Voc  !:  Help  Dictionary

 Power u^:n  _ _ _

n may be integer, boxed, or a gerund.

Integer. The verb u is applied n times. An infinite power n produces the limit of the application of u . For example, (2&o.^:_)1 is 0.73908 , the solution of the equation y=Cos y . If n is negative, the obverse u^:_1 (see below) is applied |n times. Finally, u^:n y for an array n is produced by assembling u^:a y (for all the atoms a in n) into an overall result.

The obverse is used in u&.v and is produced by v b. _1 . Repeated application of a verb is also provided by Bond (&).

Boxed. If n is boxed it must be an atom, and u^:(<m)
 ↔ u^:(i.m) y if m is a non-negative integer ↔ u^:(i.k) y if m is _ or '' , where k is the smallest positive integer such that (u^:(k-1) y) -: u^:k y ↔ u^:_1^:(<|m) y if m is negative

Gerund. See on the right.

n may be integer, boxed, or a gerund.

Integer or Boxed. x u^:n y x&u^:n y

Gerund. (Compare with the gerund cases of the merge adverb })
x u^:(v0`v1`v2)y (x v0 y)u^:(x v1 y) (x v2 y)
x u^:(   v1`v2)y x u^:([`v1`v2) y
u^:(   v1`v2)y u^:(v1 y) (v2 y)

The obverse (which is normally the inverse) is specified for six cases:

1.  The self-inverse functions + - -. % %. |. |: /: [ ] C. p.

2.  The pairs in the following tables:

 < > <: >: +. j./"1"_ +: -: *. r./"1"_ *: %: ^ ^. \$. \$.^:_1 ,: {. ;: ;@(,&' '&.>"1) #. #:

 ! 3 : '(-(!-y"_)%1e_3&* !"0 D:1 ])^:_^.y' 3!:1 3!:2 3!:3 3!:2 \: /:@|. ". ": j. %&0j1 o. %&1p1 p: π(n) q: */ r. %&0j1@^. s: 5&s: u: 3&u: x: _1&x:

 +~ -: *~ %: ^~ 3 : '(- -&b@(*^.) % >:@^.)^:_ b=.^.y'"0 ,~ <.@-:@# {. ] ,:~ {. ;~ >@{. j.~ %&1j1

3.  Obviously invertible bonded dyads such as -&3 and 10&^. and 1 0 2&|: and 3&|. and 1&o. and a.&i. as well as u@v and u&v if u and v are invertible.

4.  Monads of the form v/\ and v/\. where v is one of + * - % = ~:

5.  Obverses specified by the conjunction :.

6.  The following cases merit special mention:
p:^:_1 n gives the number of primes less than n, denoted by π(n) in math
q:^:_1 is */
b&#^:_1 where b is a boolean list is Expand (whose fill atom f can be specified by fit, b&#^:_1!.f or #^:_1!.f )
a&#.^:_1 produces the base-a representation
!^:_1 and !&n^:_1 and n&!^:_1 produce the appropriate results
{= and i."1&1 are inverses of each other; these convert between integer permutation vectors and boolean permutation matrices

Example 1:
```   (] ; +/\ ; +/\^:2 ; +/\^:0 1 2 3 _1 _2 _3 _4) 1 2 3 4 5
+---------+-----------+------------+-------------+
|1 2 3 4 5|1 3 6 10 15|1 4 10 20 35|1  2  3  4  5|
|         |           |            |1  3  6 10 15|
|         |           |            |1  4 10 20 35|
|         |           |            |1  5 15 35 70|
|         |           |            |1  1  1  1  1|
|         |           |            |1  0  0  0  0|
|         |           |            |1 _1  0  0  0|
|         |           |            |1 _2  1  0  0|
+---------+-----------+------------+-------------+
```

Example 2: Fibonacci Sequence

```   +/\@|.^:(i.10) 0 1
0  1
1  1
1  2
2  3
3  5
5  8
8 13
13 21
21 34
34 55
{. +/\@|.^:n 0 1x [ n=:128       NB. n-th term of the Fibonacci sequence
251728825683549488150424261
{.{: +/ .*~^:k 0 1,:1 1x [ k=:7  NB. (2^k)-th term of the Fibonacci sequence
251728825683549488150424261
```

Example 3: Newton Iteration

```   -:@(+2&%)^:(0 1 2 3) 1
1 1.5 1.41667 1.41422
-:@(+2&%)^:(_) 1
1.41421
-:@(+2&%)^:a: 1
1 1.5 1.41667 1.41422 1.41421 1.41421
%: 2
1.41421
```

Example 4: Subgroup Generated by a Set of Permutations

```   sg=: ~. @ (,/) @ ({"1/~) ^: _ @ (i.@{:@\$ , ])
sg ,: 1 2 3 0 4
0 1 2 3 4
1 2 3 0 4
2 3 0 1 4
3 0 1 2 4
# sg 1 2 3 4 5 0 ,: 1 0 2 3 4 5
720
```

Example 5: Transitive Closure

```   x=: (#x)<. (#x),~x=: (i.20)+1+20 ?.@# 3
(i.#x) ,: x
0 1 2 3 4 5 6 7  8  9 10 11 12 13 14 15 16 17 18 19 20
1 4 5 5 7 6 9 9 10 12 11 14 14 15 16 18 18 18 20 20 20
{&x^:(<15) 0
0 1 4 7 9 12 14 16 18 20 20 20 20 20 20
{&x^:a: 0
0 1 4 7 9 12 14 16 18 20
x {~^:a: 0
0 1 4 7 9 12 14 16 18 20
```

Interpretation: x specifies a directed graph with nodes numbered i.#x and links from i to i{x . For example, the links are: 0 1 , 1 4 , 2 5 , 3 5 and so on. Then {&x^:a:0 or x{~^:a:0 computes all the nodes reachable from node 0.

Example 6: Transitive Closure

Each record of a file begins with a byte indicating the record length (excluding the record length byte itself), followed by the record contents. Given a file, the verb rec below produces the list of boxed records.

```rec=: 3 : 0
n=. #y
d=. _1 ,~ n<.1+(i.n)+a.i.y
m=. d {~^:a: 0
((i.n) e. m) <;._1 y
)

randomfile=: 3 : 0
c  =. 1+y ?@\$ 255           NB. record lengths
rec=. {&a.&.> c ?@\$&.> 256  NB. record contents
(c{a.),&.> rec              NB. records with lengths
)

boxed_rec=: randomfile 1000
\$ boxed_rec
1000

file=: ; boxed_rec
\$ file
132045

r=: rec file
\$r
1000

r -: }.&.> boxed_rec
1
```

The last phrase verifies that the result of rec are the records without the leading length bytes.

>>  <<  Usr  Pri  JfC  LJ  Phr  Dic  Rel  Voc  !:  Help  Dictionary