Try it online!
Still one byte away from 05AB1E ლ(ಠ益ಠლ). Weirdest way I've ever defined a Jelly link, but it works. Takes the string via STDIN (no shorter than taking an ARGV, in this instance)
How it works
ØAṙ13żµ;ŒlZyɠ - Main link. No arguments
ØA - Yield the upper case alphabet ["A", "B", ... "Y", "Z"]
ṙ13 - Rotate by 13 units left ["N", "O", ... "L", "M"]
ż - Zip with alphabet. Call this X [["N", "A"], ... ["M", "Z"]]
µ - Begin a monadic chain with X as argument
Œl - X lowercased [["n", "a"], ... ["m", "z"]]
; - Concatenate with X [["N", "A"], ... ["m", "z"]]
Z - Transpose rows and columns [["N", ... "m"], ... ["A", ... "z"]]
ɠ - Yield a line from STDIN. Call this Y "Hello, World!"
y - Transliterate Y based on the mapping in Y "Uryyb, Jbeyq!"
A lot of the work here is done by the
y atom. This is a dyad whose arguments are broken up as follows:
- Left argument: A two element array, consisting of the following elements:
- Characters to be changed from.
- Characters to be changed into.
- Right argument: Character array to transliterate
This is a good example of how it works.
In the right argument (the character array), it replaces each occurrence of a key in the left argument (the mapping) with the corresponding result. Any characters that aren't a key are just left alone.
One of the key things to grasp is that
y doesn't take the mapping in
[key, result] pairs. Instead, it takes the list as a transposition of these pairs, so the pairs
[['a', 'b'], ['c', 'd'], ['e', 'f']]
d etc. would be represented as
[['a', 'c', 'e'], ['b', 'd', 'f']]
in order to use
y. When using
y, if no result is produced and STDERR has an error message, try prepending a
Z, to make
Zy, and see if that works.