In @Adám's Dyalog APL Extended, the
⍢ (under) operator means conjugation: apply one function, then a second function, then the inverse of the first. It's fun to think of real-life actions in terms of conjugation:
A problem is transformed by g into another domain where it more readily solved by f , and then transformed back into the original domain. An example from real life is “under anesthetics”:
apply anesthetics perform surgery wake up from anesthetics
The inverse of a line
g is "un" prepended to
g, and vice versa. Define any line between
s and its inverse, in that order, as being "under"
s. For each line
f in input in order:
fand its inverse both occur, do nothing
fis not "under" any other action, print
fis "under" a line
f + " under " + gwhere
A nonempty multiline string, or list of strings, etc., consisting of spaces and lowercase letters (you may instead use uppercase). Exactly one line will begin with "un"; and it will be the inverse of some other line. No line will be empty.
Output in the same format you took input in, or as allowed by Standard I/O.
Input: apply anesthetics perform surgery unapply anesthetics Output: perform surgery under apply anesthetics Input: unite asia establish the silk road ite asia Output: establish the silk road under unite asia Input: desire a book walk to store take the book pay for the book unwalk to store read the book Output: desire a book take the book under walk to store pay for the book under walk to store read the book Input: drink excessively undrink excessively Output: [empty string]