Current location - Training Enrollment Network - Mathematics courses - Introduction to APL language
Introduction to APL language
APL is a very powerful, expressive and concise programming language in many application fields (mathematics, science, engineering technology, computer design, robotics, data display, insurance technology, traditional data processing, etc.). It is usually used in an environment with a user interface. Its original design purpose is to write mathematical formulas in a way that computers can understand. It is generally easy to learn, but it often takes some time to analyze the programs written by APL. Different from traditional structured programming languages, APL programs are generally composed of a series of unary or binary functions or operating symbols used in sequence. Because APL has many nonstandard operation symbols, there is no priority between these symbols (for example, multiplication symbols, division symbols and subtraction symbols have priority in general mathematics, but APL does not have such priority). The original APL language does not have any control structure such as do-while or if-then-else, but some sequence operation symbols can be used to simulate the programming structure. for example, iota (used to obtain the sequence from 1 to n) can be used to simulate repetition (for).

The working environment of APL is called workplace. In this seminar, users can define programs and data. Data can also exist outside the program in the workplace. Users can change data outside the program, such as:

N & lt- 4 5 6 7

Grant a series of data 4, 5, 6 and 7 to n.

N + 4

Outputs 8, 9, 10, 1 1.

+/N

Output the sum of all numbers in n, which is 22.

Users can store the workspace with all the data and programs in it. Anyway, these programs are not compiled and executed, but interpreted.

APL is most famous for using a set of non-ASCII symbols. These symbols are not just ordinary algebraic and computational symbols. All the problems of air traffic control can be solved by two lines of such grotesque symbols. In fact, in some APL versions, any computable function can be represented by one line. You can express the structure of this function in one line. Because of its precise structure and nonstandard symbols, some people call APL "write-only language". Except mathematicians, it is difficult for others to understand the programs written by APL. Some mathematicians find other languages more difficult to understand than APL. Because APL uses unusual symbols, many programmers use special APL keyboards when writing APL programs. Today, there are different ways to write APL using only ASCII letters.

Iverson later designed the successor of APL, called J language, using only ASCII symbols. So far, there is only one J language. Other languages also provide functions similar to APL. A+ is an open source programming language, and many instructions are the same as APL.

The following example arranges a sequence of words in X according to the length of each word:

X[X+。 & no; ' '; ]