# Evaluation of APL direct functions

Here is a snippet I was testing recently. It takes two diameters (⍺,⍵) and computes the circumference of a circle:

10{(○1×⍺){⍺ ⍵}○1×⍵}10 ⍝ note the brackets around ⍺ 31.4159 31.4159 10{○1×⍺{⍺ ⍵}○1×⍵}10 31.4159 98.696

I would like to understand how evaluation of this expression works - why is the first one evaluating correctly and the second one isn't?

I am using Dyalog APL.

## Answers

You have nested functions. In both cases, the inner function simply returns its right and left argument. In the first case, the left argument to the inner function is the expression (○ 1×⍺), in the second case the left argument to the inner function is simply ⍺, or the unaltered left argument of the outer function -- then entire result of the inner function is multiplied by ○ and by 1.

Note that the argument to the circle function is everything to its right so the 1 x is totally redundant.

In APL, expressions are evaluated right to left. We can say that function applies to everything to its right unless modified by parens. Therefore we could say that in the first expression ○ takes 1 multiplied by everything to its right which is only ⍺ due to the parentheses. But in the second expression ○ takes 1 multiplied by everything to its right which is the result of the inner function.

Furthermore, note that due to scalar extension, you can compute the two numbers with no braces at all:

○10 10 31.415926535898 31.415926535898

More interesting with a different diameters:

○10 15 20 31.415926535898 47.123889803847 62.831853071796