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
youtube-api
service
grpc
microcontroller
python-requests
stdout
crm
datetimepicker
opengl-es
ms-access-2010
angularjs-directive
autocad
opacity
cdn
rethinkdb
ndepend
point-of-sale
virtualenv
versioning
aiml
udeploy
prepros
oracle-golden-gate
functional-dependencies
bootstrap-accordion
ppp
rollupjs
gulp-jshint
azure-table-storage
pypy
federated
textview
tikz
directions
postgresql-9.6
unity3d-5
fastadapter
intersection
ragel
perf
multi-user
wicket-tester
glide-image-library
binary-decision-diagram
line-endings
rivets.js
photoshop-script
node-java
critical-section
disassembly
vertex-shader
breadcrumbs
universe
access-violation
vga
falcon
hotkeys
jcalendar
nugetgallery
custom-build-step
skbio
jquery-draggable
matlab-engine
skscene
polarion
targetprocess
log-analysis
valdr-bean-validation
skview
teamstudio-unplugged
pysvn
zoneminder
time-frequency
sendy
azure-caching
nodeunit
elixir-framework
connections
flask-mongoengine
mahara
xml-validation
code-complete
dylan
ie-developer-tools
kohana-orm
junction-table
vline
openafs
xcode4.6.3
beep
django-1.4
socketasynceventargs
datasheet
idtabs
scriptmanager
jqtransform
moss2007-security
nbehave
cryptolicensing
conditional-operator
virtual-destructor
nstoolbar
table-valued-parameters
newspeak
dynamic-scope
focus-stealing
httpbrowsercapabilities

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