You were already told about the character set it uses, so let me say more about the rest.
APL is the language that pretty much invented the array programming paradigm, like the one you would see in NumPy. In APL, typing 1 2 3 + 4 5 6 gives you 5 7 9, automatically applying addition to each element. It has a lot of other symbols for many different kinds of operations like reversing, sorting, transposing, reducing, scanning, searching, etc. This allows you to write programs very concisely, without using loops or branching
So in APL, to create an array you just type a bunch of values (In this case numbers) next to each other, so 1 2 3 results in a 3-element array containing 1, 2, and 3. Numbers are written as you normally would, except negative numbers use ¯ prefix instead of - (Cause - is instead a function), so you write ¯5 to get negative 5.
Next, how functions are parsed. All functions in APL use infix notation, with only one precedence rule - functions take everything to the right of them, and only the closest thing on the left. So 1-2-3 parses as 1-(2-3), 2*2+2 parses as 2*(2+2). You need explicit parentheses for left side to be evaluated first: (1-2)-3. That is, function calls are right-associative, or in other words, APL is evaluated right to left.
Each function has two ways it can be called - with one argument (monadically, which happens when there is no value on the left of the function) or with two arguments (dyadically). For same function these two variants usually perform closely related operations, but not necessarily. For instance, dyadic ÷ is division, so 4÷2 is 2, while monadic ÷ is multiplicative inverse, so ÷2 is 0.5.
Now, primitive functions like + are defined to operate on whole arrays instead of just individual elements. For arithmetic functions, if you use them on arrays of same shape, they will apply to each corresponding element, so 1 2 3+4 5 6 is 5 7 9 like was already shown. You can also use arithmetic on an array and a single number, which will apply it to every element of the array and that number, so 1 2 3+5 is 6 7 8. Same for monadic arithmetic of course, it just applies to each element, so -1 2 3 is ¯1 ¯2 ¯3.
There are more functions of course, like monadic ⌽ for reversing an array, monadic ⍉ for transposing a matrix (Arrays in APL can be multidimensional), ⍴ for reshaping an array (Or getting its shape if used monadically), etc.
Then there are operators, which take functions and result in new functions. They are parsed differently than functions, being left-associative. For instance, / operator takes a function on its left and produces a function that reduces an array by inserting that function in-between each element. For example, +/1 2 3 is equivalent to 1+2+3 and results in 6.
For more info I'd visit something like tryapl.com, it is a good playground to learn APL, and has some tutorials too. If you wish to download an interpreter locally, the most popular and feature rich one is Dyalog APL, which is free for personal, non-commercial use.
View all comments
Show parent comment
3
u/Daniikk1012 20d ago
You were already told about the character set it uses, so let me say more about the rest.
APL is the language that pretty much invented the array programming paradigm, like the one you would see in NumPy. In APL, typing
1 2 3 + 4 5 6gives you5 7 9, automatically applying addition to each element. It has a lot of other symbols for many different kinds of operations like reversing, sorting, transposing, reducing, scanning, searching, etc. This allows you to write programs very concisely, without using loops or branching