Difference between Operator and Function in APL?

Learning APL or new to Dyalog? Ask "silly" questions here, without fear...

Difference between Operator and Function in APL?

Postby firesofmay on Mon Jun 29, 2015 2:58 pm

Hi,

I've been reading Mastering Dyalog APL book and I am still not getting the difference between operator and function in APL.

When do you say something is an operator and something is a function in APL?

Thanks!
User avatar
firesofmay
 
Posts: 7
Joined: Sat Jun 27, 2015 2:50 pm

Re: Difference between Operator and Function in APL?

Postby Roger|Dyalog on Mon Jun 29, 2015 5:31 pm

A function takes array argument(s) and produces an array result; an operator takes array or function argument(s) and usually produces a function, which can then be applied to arrays to produce array results. (Primitive operators always produce a function result.)

Operators are a powerful and useful concept and efficiently connect related concepts. They are closely related to the idea of adverbs in natural languages (and functions related to verbs): run quickly, think quickly, type quickly; run slowly, run efficiently, run haphazardly. If you have n symbols you can use them to define n functions, or n÷2 functions and n÷2 operators and thereby getting (n÷2)+(n*2)÷4 functions. (Even more if the operators are dyadic.)

An operator induces a family of functions: +/, ⌈/, ×/, ∧/, ∨/, etc. Once you've understood how / works on one function (e.g. +/ is summation), you'd have a pretty good handle on how it works on other functions (×/ is product, ⌈/ is maximum, and so on).
Roger|Dyalog
 
Posts: 238
Joined: Thu Jul 28, 2011 10:53 am

Re: Difference between Operator and Function in APL?

Postby firesofmay on Mon Jun 29, 2015 8:23 pm

Thanks Roger for the wonderful explanation.
That helped me in getting the basic difference between the two.
User avatar
firesofmay
 
Posts: 7
Joined: Sat Jun 27, 2015 2:50 pm


Return to New to Dyalog?

Who is online

Users browsing this forum: No registered users and 1 guest