Below, you can find another hint for the Generalized Challenge.
You should only get here after reading, digesting, and applying the .
Although we will construct the desired program G in this hint, the journey is not over yet. At the end, you will find an interesting continuation of the challenge.
Encoding the fixed part of the blueprint for Pf (and replacing # by ~@) is done by the following program, where we use the generalized function encode(s, t):
, to obtain the output:
This needs to be put together with the other ingredients (definitions of the constants and the functions copy(s), transcribe(s, t), encode(s, t), and the main body of the program; see the ) to obtain :
As a test case, we can apply it to the function f(s) that writes a frequency table of all characters in string s. Could you constructed a program that writes its own character frequency table? Here is a definition of f(s):
The output of program G applied to this function is ():
Now you can that this output is indeed a program that writes a frequency table for itself (note that (10) represents the newline character):
To help you check the output above, you can (that produces a frequency table for its input):
with the preceding program as input to check that it produces the same frequency table:
You are encouraged to try program G with some other JavaScript definitions of function f on strings as input.
So far, we have considered functions f that do a purely syntactic analysis of the string argument, for instance, determine its length, its reverse, duplicate it, determine its shadow, or construct a character frequency table.
It is even more interesting to consider functions f that (attempt to) do some semantic analysis of the string, that is, to analyze the string for behavioral properties based on the execution of the string as a program.
Can you think of some examples for such functions? And then see what applying program G could lead to?
It is your turn ...
If you have no idea how to get started, or if you tried some programs and do not see how to proceed, then you are ready for the .