# APL Symbols Meaning and Code Example

This page is a list of APL symbol's meanings.

## Monadic Functions

Name | Notation | Meaning |
---|---|---|

Roll | ? | One integer selected randomly from the first B integers |

Ceiling | β | Least integer greater than or equal to B |

Floor | β | Greatest integer less than or equal to B |

Shape | β΄ | Number of components in each dimension of B |

Not | βΌ | Logical: βΌ1 is 0, βΌ0 is 1 |

Absolute value | β£ | Magnitude of B |

Index generator | β³ | Vector of the first B integers |

Exponential | β | e to the B power |

Negation | β | Changes sign of B |

Identity | + | No change to B |

Signum | Γ | Β―1 if B<0; 0 if B=0; 1 if B>0 |

Reciprocal | Γ· | 1 divided by B |

Ravel | , | Reshapes B into a vector |

Matrix inverse | βΉ | Inverse of matrix B |

Pi times | β | Multiply by Ο |

Logarithm | β | Natural logarithm of B |

Reversal | β½ | Reverse elements of B along last axis |

Reversal | β | Reverse elements of B along first axis |

Grade up | β | Indices of B which will arrange B in ascending order |

Grade down | β | Indices of B which will arrange B in descending order |

Execute | β | Execute an APL expression |

Monadic format | β | A character representation of B |

Monadic transpose | β | Reverse the axes of B |

Factorial | ! | Product of integers 1 to B |

## Dyadic functions

Name | Notation | Meaning |
---|---|---|

Add | + | Sum of A and B |

Subtract | β | A minus B |

Multiply | Γ | A multiplied by B |

Divide | Γ· | A divided by B |

Exponentiation | β | A raised to the B power |

Circle | β | Trigonometric functions of B selected by A. A=1: sin(B) A=2: cos(B) A=3: tan(B) |

Deal | ? | A distinct integers selected randomly from the first B integers |

Membership | β | 1 for elements of A present in B; 0 where not. |

Maximum | β | The greater value of A or B |

Minimum | β | The smaller value of A or B |

Reshape | β΄ | Array of shape A with data B |

Take | β | Select the first (or last) A elements of B according to ΓA |

Drop | β | Remove the first (or last) A elements of B according to ΓA |

Decode | β₯ | Value of a polynomial whose coefficients are B at A |

Encode | β€ | Base-A representation of the value of B |

Residue | β£ | B modulo A |

Catenation | , | Elements of B appended to the elements of A |

Expansion | \ | Insert zeros (or blanks) in B corresponding to zeros in A |

Compression | / | Select elements in B corresponding to ones in A |

Index of | β³ | The location (index) of B in A; 1+β/β³β΄A if not found |

Matrix divide | βΉ | Solution to system of linear equations Ax = B |

Rotation | β½ | The elements of B are rotated A positions |

Rotation | β | The elements of B are rotated A positions along the first axis |

Logarithm | β | Logarithm of B to base A |

Dyadic format | β | Format B into a character matrix according to A |

General transpose | β | The axes of B are ordered by A |

Combinations | ! | Number of combinations of B taken A at a time |

Less than | < | Comparison: 1 if true, 0 if false |

Less than or equal | β€ | Comparison: 1 if true, 0 if false |

Equal | = | Comparison: 1 if true, 0 if false |

Greater than or equal | β₯ | Comparison: 1 if true, 0 if false |

Greater than | > | Comparison: 1 if true, 0 if false |

Not equal | β | Comparison: 1 if true, 0 if false |

Or | β¨ | Logic: 0 if A and B are 0; 1 otherwise |

And | β§ | Logic: 1 if A and B are 1; 0 otherwise |

Nor | β± | Logic: 1 if both A and B are 0; otherwise 0 |

Nand | β² | Logic: 0 if both A and B are 1; otherwise 1 |

## Operators and axis indicator

Name | Symbol | Example | Meaning (of example) |
---|---|---|---|

Reduce (last axis) | / | +/B | Sum across B |

Reduce (first axis) | βΏ | +βΏB | Sum down B |

Scan (last axis) | \ | +\B | Running sum across B |

Scan (first axis) | β | +βB | Running sum down B |

Inner product | β | A+.ΓB | Matrix product of A and B |

Outer product | β | Aβ.ΓB | Outer product of A and B |

Create TeX/Math/APL Keyboard Layout

For full detail, see: APL syntax and symbols

## Sample APL Code

Sample APL source code: apl_cgi_script.apl

#!/usr/local/bin/apl --script -- 0 0β΄β')COPY 5 HTML.apl' β This is an APL CGI script that demonstrates the use of APL for CGI scripting β It outputs an HTML page like GNU APL's homepage at www.gnu.org. β β Variable name conventions: β β Variables starting with x, e.g. xB, are strings (simple vectors of β characters), i.e. 1β‘ β‘xB and 1β‘''β΄β΄β΄xB β β Variables starting with y are vectors of character strings, β i.e. 2β‘ β‘yB and 1β‘''β΄β΄β΄yB β β Certain characters in function names have the following meaning: β β T - start tag β E - end tag β X - attributes ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β disable colored output and avoid APL line wrapping β ]COLOR OFF βPWβ1000 βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β β Document variables. Set them to '' so that they are always defined. β Override them in the document section (after )SAVE) as needed. β xTITLEβ'<please-set-xTITLE>' xDESCRIPTIONβ'<please-set-xDESCRIPTION>' yBODYβ0β΄'<please-set-yBODY>' ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β The content of the HTML page ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ βββββββββββββββββββββββββββββββββββββββββ β Return xHTTP_GNU or xHTTP_JSA β depending on the CGI variable SERVER_NAME β βxZβHome;xS xSββ(ββENV 'SERVER_NAME')[;βIO + 1] xZβ"192.168.0.110/apl" β JΓΌrgen's home ? β(Sβ‘'192.168.0.110')/0 β yes, this script was called by apache β(Sβ‘'')/0 β yes, this script called directly xZβxHTTP_GNU,'/apl' β no β βββββββββββββββββββββββββββββββββββββββββ β set xTITLE and xDESCRIPTION that go into the HEAD section of the page β xTITLEβ'GNU APL' xDESCRIPTIONβ'Welcome to GNU APL' βββββββββββββββββββββββββββββββββββββββββ β some URIs used in the BODY β xHTTP_GNUβ"http://www.gnu.org/" xHTTP_JSAβ"http://192.168.0.110/apl/" xFTP_GNUβ"ftp://ftp.gnu.org" xFTP_APLβxFTP_GNU,"/gnu/apl" xCYGWINβ"www.cygwin.org" xMIRRORSβ'http://www.gnu.org/prep/ftp.html' xGNU_PICβHTMLβ__src xHTTP_GNU, "graphics/gnu-head-sm.jpg" βββββββββββββββββββββββββββββββββββββββββ β some file names used in the BODY β xAPL_VERSIONβ'apl-1.5' xTARFILEβxAPL_VERSION, '.tar.gz' xRPMFILEβxAPL_VERSION, '-0.i386.rpm' xSRPMFILEβxAPL_VERSION, '-0.src.rpm' xDEBFILEβxAPL_VERSION, '-1_i386.deb' xSDEBFILEβxAPL_VERSION, '-1.debian.tar.gz' xAPL_TARβxFTP_GNU, '/', xTARFILE xMAIL_GNUβ'gnu@gnu.org' xMAIL_WEBβ'bug-apl@gnu.org' xMAIL_APLβ'bug-apl@gnu.org' xMAIL_APL_ARCHIVEβ'http://lists.gnu.org/archive/html/bug-apl/' xMAIL_APL_SUBSCRIBEβ'https://lists.gnu.org/mailman/listinfo/bug-apl' xSVN_APLβ'https://savannah.gnu.org/svn/?group=apl' βββββββββββββββββββββββββββββββββββββββββ β some features of GNU APL β yFEATURESβ β 'nested arrays and related functions' yFEATURESβyFEATURES, β 'complex numbers, and' yFEATURESβyFEATURES, β 'a shared variable interface' yFEATURESβHTMLβUl yFEATURES βββββββββββββββββββββββββββββββββββββββββ β Installation instructios β βyZβINSTALL;I1;I2;I3;I4 I1β 'Visit one of the ', xMIRRORS HTMLβA 'GNU mirrors' I1β I1, ' and download the tar file <B>', xTARFILE,'</B> in directory' I1ββ I1, ' <B>apl</B>.' I2ββ 'Unpack the tar file: <B>tar xzf ', xTARFILE, '</B>' I3ββ 'Change to the newly created directory: <B>cd ', xAPL_VERSION, '</B>' I4β 'Read (and follow) the instructions in files <B>INSTALL</B>' I4ββ I4, ' and <B>README-*</B>' yZββ HTMLβOl I1, I2, I3, I4 β β βINP acts like a HERE document in bash. The monadic form βINP B β reads subsequent lines from the input (i.e. the lines below βINP β if βINP is called in a script) until pattern B is seen. The lines β read are then returned as the result of βINP. β β The dyadic form A βINP B acts like the monadic form βINP B. β A is either a single string or a nested value of two strings. β β Let A1βA2βA if A is a string or else A1βA[1] and A2βA[2] if A is β a nested 2-element vector containing two strings. β β Then every pattern A1 expression A2 is replaced by β expression. β β We first give an example of βINP in the style of PHP and another, β more compact, example further down below. β yBODYβ '<?apl' '?>' βINP 'END-OF-βINP' β php style <DIV class="c1"> <?apl HTMLβH1[''] xTITLE ?> <TABLE> <TR> <TD> <?apl HTMLβImg[xGNU_PIC, (HTMLβ_alt 'Astrid'), HTMLβ__h_w 122 129] 1 ?> <TD style="width:20%"> <TD><I> Rho, rho, rho of X<BR> Always equals 1<BR> Rho is dimension, rho rho rank.<BR> APL is fun!</I><BR> <BR> <B>Richard M. Stallman</B>, 1969<BR> </TR> </TABLE> <BR><BR><BR> </DIV> <DIV class="c2"> <B>GNU APL</B> is a free interpreter for the programming language APL. <BR><BR> The APL interpreter is an (almost) complete implementation of <I><B>ISO standard 13751</B></I> aka. <I><B>Programming Language APL, Extended.</B></I> <BR> <BR> The APL interpreter has implemented: <?apl β yFEATURES ?> In addition, <B>GNU APL</B> can be scripted. For example, <?apl HTMLβx2y 'APL_demo.html' HTMLβA "<B>this HTML page</B>" ?> is the output of a CGI script written in APL. <BR> <BR> GNU APL was written and is being maintained by JΓΌrgen Sauermann. </DIV> <DIV class="c3"> <?apl HTMLβH2[''] 'Downloading and Installing GNU APL' ?> GNU APL should be available on every <?apl xMIRRORS HTMLβA 'GNU mirror' ?> (in directory <B>apl</B>) and at <?apl xFTP_APL HTMLβA xFTP_GNU ?>. <?apl HTMLβH4[''] 'Normal Installation of GNU APL' ?> The normal (and fully supported) way to install GNU APL is this: <?apl β INSTALL ?> <?apl HTMLβH4[''] 'GNU APL for WINDOWs' ?> GNU APL compiles under CYGWIN, (see <?apl ('http://',xCYGWIN) HTMLβA xCYGWIN ?>), provided that the necessary libraries are installed. A 32-bit <B>apl.exe</B> that may run under CYGWIN lives in the download area. Use at your own risk and see <B>README-5-WINDOWS</B> for further information. <?apl HTMLβH4[''] 'Subversion (SVN) repository for GNU APL' ?> You can also check out the latest version of GNU APL from its subversion repository on Savannah: <BR> <BR> <B>svn co http://svn.savannah.gnu.org/svn/apl/trunk</B>. <BR> <BR> Here is <?apl HTMLβx2y xSVN_APL HTMLβA "<EM>more information</EM>" ?> about using Subversion with GNU APL. <?apl HTMLβH4[''] 'RPMs for GNU APL' ?> For RPM based GNU/Linux distributions we have created source and binary RPMs. Look for files <B><?apl xRPMFILE ?></B> (binary RPM for i386) or <B><?apl xSRPMFILE ?></B> (source RPM). If you encounter a problem with these RPMs, then please report it, but with a solution, since the maintainer of GNU APL may use a GNU/Linux distribution with a different package manager. <?apl HTMLβH4[''] 'Debian packages for GNU APL' ?> For Debian based GNU/Linux distributions we have created source and binary packages for Debian. Look for files <B><?apl xDEBFILE ?></B> (binary Debian package for i386) or <B><?apl xSDEBFILE ?></B> (Debian source package). If you encounter a problem with these packages, then please report it, but with a solution, since the maintainer of GNU APL may use a GNU/Linux distribution with a different package manager. <?apl HTMLβH4[''] 'GNU APL Binary' ?> If you just want to quickly give GNU APL a try, and if you are very lucky then you may be able to start the compiled GNU APL binary <B>apl</B> in the directory <B>apl</B> rather than installing the entire packet . The binary MAY run on a 32-bit i686 Ubuntu. Chances are, however, that it does NOT work, Please DO NOT report any problems if the binary does not run on your machine. Instead use the standard installation method above. <BR><BR> <B>Note:</B> The program <B>APnnn</B> (a support program for shared variables) is not provided in binary form, so you should start the <B>apl</B> binary with command line option --noSV. Note as well that the binary <B>apl</B> will not be updated with every GNU APL release. Therefore it will contain errors that have been corrected already. </DIV> <DIV class="c4"> <?apl HTMLβH2[''] 'Reporting Bugs' ?> GNU APL is made up of more than 75,000 lines of C++ code. In a code of that size, programming mistakes are inevitable. Even though mistakes are hardly avoidable, they can be <B>corrected</B> once they are found. In order to improve the quality of GNU APL, we would like to encourage you to report errors that you find in GNU APL to <?apl HTMLβx2y ("mailto:", xMAIL_APL) HTMLβA "<EM>", xMAIL_APL, "</EM>" ?>. <BR><BR> The emails that we like the most are those that include a small example of how to reproduce the fault. You can see all previous postings to this mailing list at <?apl HTMLβx2y xMAIL_APL_ARCHIVE HTMLβA "<B>", xMAIL_APL_ARCHIVE,"</B>" ?> or subscribe to it at <?apl HTMLβx2y xMAIL_APL_SUBSCRIBE HTMLβA "<B>", xMAIL_APL_SUBSCRIBE,"</B>" ?> </DIV> <DIV class="c5"> <?apl HTMLβH2[''] 'Documentation' ?> We have an <?apl HTMLβx2y 'apl.html' HTMLβA "<B>info manual</B>" ?> for GNU APL. We are also looking for <B>free</B> documentation on APL in general (volunteers welcome) that can be published here. A "Quick start" document for APL is planned but the work has not started yet. <BR><BR> The C++ source files for GNU APL are Doxygen documented. You can generate this documentation by running <B>make DOXY</B> in the top level directory of the GNU APL package. </DIV> <DIV class="c6"> <?apl HTMLβH2[''] 'GNU APL Community' ?> There is a growing group of people that are using GNU APL and that have made their own developments related to APL available to the public. We have created a <?apl 'Community.html' HTMLβA '<b>GNU APL Community Web page</b>' ?> that collects <B>links</B> to those developments to avoid that they get lost. <BR><BR> In addition, we maintain a <?apl 'Bits_and_Pieces/' HTMLβA '<b>Bits-and-Pieces</b>' ?> directory where we collect <B>files</B> that contain APL code sniplets, GNU APL workspaces, and other files that were contributed by the GNU APL Community. The Bits-and-Pieces directory is the right place for contributions for which the creation of an own hosting account would be an overkill. </DIV> END-OF-βINP β the text above used an 'escape style' similar to PHP β (using <?apl ... ?> instead of <?php ... ?>). This style also β resembles the tagging of HTML. β β By calling βINP with different left arguments you can use your β preferred style, for example the more compact { ... } style β as shown in the following example: β yBODYβyBODY, (,Β¨'{}') βINP 'END-OF-βINP' β more compact style <DIV class="c7"> Return to {HTMLβx2y "http://www.gnu.org/home.html" HTMLβA "GNU's home page"}. <P> Please send FSF & GNU inquiries & questions to {HTMLβx2y ("mailto:", xMAIL_GNU) HTMLβA "<EM>", xMAIL_GNU, "</EM>"}. There are also {HTMLβx2y "http://www.gnu.org/home.html#ContactInfo" HTMLβA "other ways to contact"} the FSF. <P> Please send comments on these web pages to {HTMLβx2y ("mailto:", xMAIL_WEB) HTMLβA "<EM>", xMAIL_WEB, "</EM>"}. send other questions to {HTMLβx2y ("mailto:", xMAIL_GNU) HTMLβA "<EM>", xMAIL_GNU, "</EM>"}. <P> Copyright (C) 2014 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA <P> Verbatim copying and distribution of this entire article is permitted in any medium, provided this notice is preserved.<P> </DIV> END-OF-βINP HTMLβemit HTMLβDocument '<!--' )VARS )FNS )SI '-->' )OFF )WSID APL_CGI )DUMP

- Unicode Support in Ruby, Perl, Python, JavaScript, Java, Emacs Lisp, Mathematica
- Problems of Symbol Congestion in Computer Languages; ASCII Jam vs Unicode
- Programing Problem: Normalize a Vector of Any Dimension
- Semantic of Symbols: HTML Entities, Ampersand, Unicode
- Syntax Design: Use of Unicode Matching Brackets as Specialized Delimiters
- Syntax Semantics Design: Use of Unicode Ellipsis Symbol vs Dot Dot Dot
- URL Percent Encoding and Unicode
- Unicode Semantics: the β±― in Turn A Gundam