One-liner

From APL Wiki
Jump to navigation Jump to search
This article is about one-liners in APL. For other languages, see Wikipedia.

A one-liner is an APL program consisting of a single line of code. Creating such programs to perform various tasks, which might be considered a less precisely-measured form of code golf, was a popular challenge in early APL. The one-line constraint was significantly more limiting in this era, as it prevented creating defined functions or using Branch for control flow, and other possibilities like Each did not exist until the development of nested APLs. Once introduced, Execute became one possibility for performing repeated evaluation.[1] Like excessive code golfing, writing in an unusual style solely to fit code into a single line is sometimes criticized as harmful to readability.

In the case of a well-known conversational programming language I have been told from various sides that as soon as a programming community is equipped with a terminal for it, a specific phenomenon occurs that even has a well-established name: it is called “the one-liners”. It takes one of two different forms: one programmer places a one-line program on the desk of another and either he proudly tells what it does and adds the question “Can you code this in less symbols?” —as if this were of any conceptual relevance!— or he just asks “Guess what it does!”

E. W. Dijkstra[2]

References

  1. Michael Gertelman. Conway's Game of Life in one line of APL. 2005.
  2. Edsger W. Dijkstra. The Humble Programmer. ACM Turing Lecture 1972. EWD340.
APL syntax [edit]
General Comparison with traditional mathematicsPrecedenceTacit programming (Train, Hook, Split composition)
Array Numeric literalStringStrand notationObject literalArray notation (design considerations)
Function ArgumentFunction valenceDerived functionDerived operatorNiladic functionMonadic functionDyadic functionAmbivalent functionDefined function (traditional)DfnFunction train
Operator OperandOperator valenceTradopDopDerived operator
Assignment MultipleIndexedSelectiveModified
Other Function axisBracket indexingBranchStatement separatorQuad nameSystem commandUser commandKeywordDot notationFunction-operator overloadingControl structureComment