Topic: `APLX Help` : `Help on APL language` : `APL Primitives` : `⍎ Execute`
[ Previous | Next | Contents | Index | APL Home ]

# `⍎` Execute

Execute, followed by an APL text expression, causes the expression to be evaluated as if it had been entered at the keyboard in calculator mode. This has numerous applications, some of which are briefly summarized below.

It can be used to turn character data, which contains numeric characters only, into numeric data:

```             LIST ← '345 567'
⍴ LIST
7                             (LIST contains 7 characters.)
⍴ ⍎ LIST                (LIST is executed, and ⍴ is applied to the
2                              result - 2 numbers)
```
```             1 + ⍎ LIST              (This demonstrates that the
346 568                        executed form of LIST can be
used in arithmetic)
```

It can be used as an alternative to branching in a user-defined function:

```       [4]   ⍎ (LOOP=10)/'DATA←DATA×10'
```

If LOOP does not equal 10 when line 4 is executed, the `/` operator will give an empty vector to `⍎,` and nothing will happen. If LOOP does equal 10, the `/` operator will pass the character data to `⍎,` and the value of DATA will be multiplied by 10 after execution.

In APLX, system commands can be executed using the `⍎` primitive:

```             ∇LIB
[1] ⍝ Show contents of library 0
[2] ⍎')LIB'
[3] ∇
```

The output from executed system commands can be captured in a variable:

```            X←⍎')SYMBOLS'
X
IS 1026, USED 21
```

`⍎` can be used to execute single line function definition statements. The implicit result of the operation is an empty vector, as is the result of executing any statement which does not have a result.

With an existing function called FUNCTION:

```             ⍎'∇FUNCTION[3]A←2∇'
⍎'∇FUNCTION[2]B←1'      (Note ⍎ supplies the closing ∇)
```

With an existing function called FN:

```             ∇FN[⎕]∇                 (Function with no result)
[1] A←1 2 3
∇
⍴FN
VALUE ERROR
⍴FN
^
⍴⍎'FN'                  (Execution gives an empty vector result)
0
```

Topic: `APLX Help` : `Help on APL language` : `APL Primitives` : `⍎ Execute`
[ Previous | Next | Contents | Index | APL Home ]