Prize Competition: Wrap Up (with Competition Rules)
Vector 2:1, page 105
Transcribed from the printed issue; not yet reviewed. Read it in the PDF of the issue, page 105
Very often APL programmers will represent rows in a notional text matrix as the concatenation of vectors delimited by carriage return characters. This representation usually takes up less workspace because trailing blanks are not included.
For example, many APLs use a system function quadVR to return the visual representation of a user-defined function. This is a character vector containing imbedded carriage returns that displays as a neat function listing. Unfortunately, such displays often exceed some arbitrary width, because lines between the carriage returns are too long. In such cases it is desirable to wrap the offending lines by inserting appropriate extra carriage return characters. Example output could be:
,S←'IN PARADISE',cr,'HERONS',cr,'APPROACH FROM THE LEFT.'
IN PARADISE
HERONS
APPROACH FROM THE LEFT.
10 0 WRAP cr,S
IN PARADIS
E
HERONS
APPROACH F
ROM THE LE
FT.
In this example the result is similar to the argument except that three extra carriage returns have been inserted; one after the ‘S’ of ‘PARADISE’, one after the ‘F’ of ‘FROM’ and one after the ‘E’ of ‘LEFT’. Notice that the function \<WRAP> is quite general, with the first element of its right argument providing the delimiter character to be used. The left argument specifies the maximum allowable length substring between delimiters in the result, followed by the amount of indentation required. The indentation amount determines the number of leading blanks in each wrapped segment. For example:
The problem is to write such a function \<WRAP>. As usual, the winning programs must be ISO APL standard conforming (use no extensions like replicate, nested arrays or special quad functions, etc.). Each entrant must submit only one competition entry, but may include alternatives for comparison and possible publication. These alternatives may be written in ANY APL, so let’s see some APL2 (etc) solutions too!
Entries will be judged on robustness, resource requirements, generality and intelligibility. A first prize of £30 and two others of £10 each will be sent to the winners.
The closing date for entries is 25th October 1985.
Competition Rules¶
- Entries must be in legible English or APL as appropriate and should preferably be machine produced.
- Entrants must declare the type of computer and the version and release level of the APL interpreter on which their functions were written.
- The date and your full name and address should appear on each sheet of your entry.
- Entries should be physically separate from other contributions such as letters, and should be clearly marked ‘Competition Entry’
- All submissions should be sent to the editor.
- Those on the committee, activities group or journal group of the British APL Association are ineligible.
- DOS format diskettes containing APL*PLUS, IBM or Sharp APL workspaces are acceptable, Diskettes will be returned.
- Unless otherwise stated, you should submit only one entry. We encourage submission of alternative approaches, but you must indicate clearly which answer is the competition entry.