Inspired by this question.
Create a program that prompts the user to store some data, and when the program is quitting, spit out the program itself, except the session data changed.
The user then open the newly generated program, and can recall the data from the previous program.
Commands
KEY VALUE
: sets session variableKEY
toVALUE
*
: clear all data! KEY
: deleteKEY
? KEY
: queryKEY
(if not exist: print nothing and move on)- otherwise, quit the program
Neither key or value cannot contain any spaces. The newly generated program's filename must identify the version of the program, you can use dates or counters.
Example interaction:
name test store name = test
data is now { name: test }
0 1 data is now { name: test, 0: 1 }
? name output: test
! 0 delete 0
data is now { name: test }
hello good world data is now { name: test, hello: good }
the extra word "world" is ignored
egiwiwegiuwe the "otherwise" case: quit program
The user opens the newly generated program
? name output: test
name retest data is now { name: retest }
* clear
data is now { }
Sample implementation: https://gist.github.com/1128876
Rules
- You do not need to preserve comments or insignificant whitespaces in the quined program: just preserve the functionality and the data
- You cannot use any external storage.
- No cheating quines, like any other quine problems.
- Shortest code wins.
SELECT 1 AS ID, NAME AS BLAH UNION...
\$\endgroup\$