evaluation


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.
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

Related Links

Math notation understanding
What criterias do you look for in a WAF (web application firewall)?
Predictionio evaluation fails with Text Classification template
Evaluation of APL direct functions
Modelica Evaluation Order
how compilers evaluate mathematical expressions? [closed]
What does “top-level evaluation” mean?
Boolean expression evaluation with a given context
Is relying on short-circuit evaluation good design? [closed]
Objectively evaluating new GUI toolkits
what are evaluation techniques for HCI projects (without involving users, or psychologist)?
Evaluating developers [closed]
Options to Common Criteria
What are some useful criteria for deciding on which software package to go for?
Having to set objectives for developers, even though objectives don't work [closed]
How would you go about evaluating a programmer? [closed]

Categories

HOME
grizzly
macros
teradata
ssh
display
xamarin.forms
reference
ebay-api
cryengine
open-search-server
virtualhost
vsixmanifest
annyang
olap
core-data
url-parameters
minimagick
restructuredtext
pushbullet
infinite-loop
knapsack-problem
stack-trace
mex
uibarbuttonitem
csproj
osgi-bundle
choco
contextmenustrip
luhn
flickr
certbot
respect-validation
client-server
dotnetnuke-module
framebuffer
jibx
libconfig
iterm2
nscollectionview
socketcluster
susy
aura-framework
html-entities
niagara-ax
mef
pyopenssl
openxava
serialversionuid
px4
wink
nservicebus6
programming-pearls
dynatable
blackberry-webworks
x12
hdr
init
android-xmlpullparser
alchemy
nslocalizedstring
ewam
encode
computability
bioconductor
javapackager
edgar
log4cxx
cyberduck
avrcp
eggplant
mergecursor
httpmodule
accpac
cl.exe
esri-arc-engine
pysvn
novell
lwuit
gnip
tigase
dirname
ios-enterprise
visual-c#-express-2010
isl
xps
pidgin
internet-radio
nomachine
xtify
nop
surfaceview
tlbimp
xrandr
jython-2.5
gmail-imap
pageload
simplemembership
screensharing
derived-class
blackberry-eclipse-plugin
flatten
django-admin-tools
gmagick
cryptolicensing
http-response-codes
fxcopcmd
pitch-shifting
dongle
focus-stealing
vista64

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App