Whispers v1, 349 343 bytes
>> #2
> Input
>> [13]
>> LⁿR
>> Each 20 27
>> Each 4 29 30
> 0
> 65
> 90
> 97
> 122
>> 8…9
>> 10…11
>> [12]
>> Then 14 3
>> Then 3
>> Then 15
>> 7-L
>> ≻L
>> ?L
>> 'L
>> L∈R
>> 2ⁿL
>> LⁱR
>> (1]
>> Each 18 25
>> Each 23 26
>> 1⋅16
>> 1⋅17
>> Each 22 5 28
>> Each 24 6 5
>> Each 19 31
>> Each 4 6 32
>> Each 21 33
>> Output 34
Try it online!
In Whispers, the last line is executed first. The other lines are executed when they are referenced in an executing line. Since this program contains many nested operations, I will try to explain it in a bottom-up approach.
For better understanding, I will go through the explanation using the example input HelloWorld
.
Input:
2 >> Input
Takes the first line of input. Example: HelloWorld
Constants:
7 > 0
8 > 65
9 > 90
10 > 97
11 > 122
Simple integers.
12 >> 8…9
Returns the set {result of line 8 .. result of line 9}, so we get {65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90}
.
13 >> 10…11
We get {97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122}
.
14 >> [12]
Converts the result of line 12 into a list. We get [65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90]
. Since this array occurs several times in this explanation, I will call it A
.
3 >> [13]
[97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122]
. We call this array B
.
15 >> Then 14 3
[A, B]
16 >> Then 3
[B]
17 >> Then 15
[[A, B]]
Functions:
Functions take an argument L
and/or an argument R
from a previously executed line.
4 >> LⁿR
Returns the R
th position of L
.
18 >> 7-L
Takes the result from line 7, subtracts it with L
and returns it. Since the result of line 7 is 0
line 18 simply negates its argument.
19 >> ≻L
Increments L
.
20 >> ?L
Returns the integer representation of L
.
21 >> 'L
Returns the string representation of L
.
22 >> L∈R
Returns true if L
is in R
, else false.
23 >> 2ⁿL
Returns the L
th position of the result of line 2. Since line 2 is our example input HelloWorld
it will return the L
th character of this word.
24 >> LⁱR
Returns the index of R
in L
.
Variables:
1 >> #2
Returns the length of result of line 2. In this example it is 10
.
25 >> (1]
Returns the set {1 .. result of line 1}, so we get {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
.
The Each
command iterates over the second argument and applies the function given by the first argument. If two arrays are passed, they are zipped.
26 >> Each 18 25
[-1, -2, -3, -4, -5, -6, -7, -8, -9, -10]
27 >> Each 23 26
dlroWolleH
5 >> Each 20 27
[100, 108, 114, 111, 87, 111, 108, 108, 101, 72]
28 >> 1⋅16
[B, B, B, B, B, B, B, B, B, B]
29 >> 1⋅17
[[A, B], [A, B], [A, B], [A, B], [A, B], [A, B], [A, B], [A, B], [A, B], [A, B]]
30 >> Each 22 5 28
[True, True, True, True, False, True, True, True, True, False]
6 >> Each 4 29 30
[B, B, B, B, A, B, B, B, B, A]
31 >> Each 24 6 5
[3, 11, 17, 14, 22, 14, 11, 11, 4, 7]
32 >> Each 19 31
[4, 12, 18, 15, 23, 15, 12, 12, 5, 8]
33 >> Each 4 6 32
[101, 109, 115, 112, 88, 112, 109, 109, 102, 73]
34 >> Each 21 33
emspXpmmfI
Output:
35 >> Output 34
Outputs the result of line 34.
But why the strange order? Because the order is essential. The lines 1-6 are called several times. So they should better be on a small number line.