Evaluation of APL direct functions -
here snippet testing recently. takes 2 diameters (⍺,⍵
) , computes circumference of circle:
10{(○1×⍺){⍺ ⍵}○1×⍵}10 ⍝ note brackets around ⍺ 31.4159 31.4159 10{○1×⍺{⍺ ⍵}○1×⍵}10 31.4159 98.696
i understand how evaluation of expression works - why first 1 evaluating correctly , second 1 isn't?
i using dyalog apl.
you have nested functions. in both cases, inner function returns right , left argument. in first case, left argument inner function expression (○ 1×⍺), in second case left argument inner function ⍺, or unaltered left argument of outer function -- entire result of inner function multiplied ○ , 1.
note argument circle function right 1 x totally redundant.
in apl, expressions evaluated right left. can function applies right unless modified parens. therefore in first expression ○ takes 1 multiplied right ⍺ due parentheses. in second expression ○ takes 1 multiplied right result of inner function.
furthermore, note due scalar extension, can compute 2 numbers no braces @ all:
○10 10 31.415926535898 31.415926535898
more interesting different diameters:
○10 15 20 31.415926535898 47.123889803847 62.831853071796
Comments
Post a Comment