Primitive Pointers
Vector 18:2, page 44
Transcribed from the printed issue; not yet reviewed. Read it in the PDF of the issue, page 44
(The purpose of this column is to point out some facts about the primitive APL functions you may have overlooked or forgotten. If you don’t believe use, try it out!)
From last issue: the first step in parsing an executable APL expression for identifier names is to ignore the text within quotes. Here’s an example:
The identifiers used in this expression are SUB and NAMES. FL is not an identifier because it’s within quotes. The =\ and ≠\ functions can be used to distinguish between text within quotes and text outside quotes. Let’s try them (blanks between bit elements are omitted for clarity):
Mark the quotes:
Text within quotes including leading quote:
Select all other characters:
=\ is the opposite of ≠\:
Exclude both quotes, selecting just non-quoted text:
(=\EXPR≠'''')∧EXPR≠''''
111111100001111111111111
((=\EXPR≠'''')∧EXPR≠'''')/EXPR
SUB←(∨/⍷NAMES)⌿NAMES
The second step in parsing an executable APL expression is to ignore the text following lamp (⍝) symbols. An example:
The identifiers used in this expression are SUB and NAMES, not FL, LOOK, or FOR. What APL expression selects from a character vector X just those characters that are not with quotes or comments?
Answer next issue. (Hint: Experiment with ∧\ and ∨\. Consider only lamp symbols outside quotes.)
Reprinted with kind permission from Zark APL Tutor News, a quarterly publication of Zark Incorporated, 23 Ketchbrook Lane, Ellington, CT06029, USA