Search

Affichage des articles dont le libellé est quine. Afficher tous les articles
Affichage des articles dont le libellé est quine. Afficher tous les articles

lundi 20 mars 2017

Multiquine: final (4)

Context
Previous post  already presented the CS code template.
Now, here is the JS one
/*BOOTSTRAP*/
(function(language){
 var quote = String.fromCharCode(34), backslash = String.fromCharCode(92), newline = backslash + String.fromCharCode(114) + backslash + String.fromCharCode(110);
 var data =
 {
/*DATA*/
  cs: "CS_CODE_PLACEHOLDER",
  js: "JS_CODE_PLACEHOLDER",
  bf: "BF_CODE_PLACEHOLDER",
/*CODE*/
 };

 if(!language) language = 'js';
 var code = data[language];
 var bootstraps =
 {
   js: 'JS_BOOTSTRAP_PLACEHOLDER',
   cs: 'CS_BOOTSTRAP_PLACEHOLDER',
   bf: 'BF_BOOTSTRAP_PLACEHOLDER',
 }
 var res = bootstraps[language]
 switch(language)
 {
  case 'js':
   for(var i in data) res += ' ' + i + ': ' + quote + data[i].replace(new RegExp('\\\\', 'g'), backslash + backslash).replace(new RegExp(quote, 'g'), backslash + quote).replace(new RegExp(newline, 'g'), backslash + 'r' + backslash + 'n') + quote + ',\r\n';
   break;
  case 'cs':
   for(var i in data) res += ' data.Add(' + quote + i + quote + ', ' + quote + data[i].replace(new RegExp('\\\\', 'g'), backslash + backslash).replace(new RegExp(quote, 'g'), backslash + quote).replace(new RegExp(newline, 'g'), backslash + 'r' + backslash + 'n') + quote + ');\r\n';
   break;
  case 'bf':
   for(var i in data)
   {
     for (var j = 0; j < i.length; j++) { if (i.charCodeAt(j) == 13) continue; res += "+".repeat(i.charCodeAt(j)); res += '>'; }
res += '>';
for (var j = 0; j < data[i].length; j++) { if (data[i].charCodeAt(j) == 13) continue; res += "+".repeat(data[i].charCodeAt(j)); res += '>'; }
res += '>';
   }
   res += '\r\n';
 }
 res += code;
 console.log(res);
})()

Not really different from the C# version... Now, here is the BF one:
/*BOOTSTRAP*/
>>>>
/*DATA*/
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>>CS_CODE_PLACEHOLDER>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>>JS_CODE_PLACEHOLDER>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>>BF_CODE_PLACEHOLDER>
/*CODE*/
,>+<[>+++++++++[-<---------->]+<+[[-]>-<JS_BOOTSTRAP_PLACEHOLDER<<<[[<]<]>>[<++++++++[-<++++>]<..>>[<+>----------[------------------------[<++++++++++++++[->----<]+>++[<++++++++++++[->+++++++<]>+.[-<<+>>]]<[++++++++++++[-<+++++++>]<+..>]>]<[++++++++++++[->+++++++<]>+.[-]<<++++++++++++++++++++++++++++++++++.>]>]<[->+++++[-<++++++++++++++++>]<++++++++++++.++++++++++++++++++++++.----------------------.++++++++++++++++++.[-]<++++++++++>]>>]+++[-<++++++++++++++++>]<++++++++++.--------------------------.++.[-]>>[<+>----------[------------------------[<++++++++++++++[->----<]+>++[<++++++++++++[->+++++++<]>+.[-<<+>>]]<[++++++++++++[-<+++++++>]<+..>]>]<[++++++++++++[->+++++++<]>+.[-]<<++++++++++++++++++++++++++++++++++.>]>]<[->+++++[-<++++++++++++++++>]<++++++++++++.++++++++++++++++++++++.----------------------.++++++++++++++++++.[-]<++++++++++>]>>]++[-<++++++++++++++++>]<++.++++++++++.[-]++++++++++.[-]>>]<<<<[[<]<]>>[>]>[>]>[>]>[.>]>[>]>[>]>>>]>[-CS_BOOTSTRAP_PLACEHOLDER<<<[[<]<]>>[<++[-<++++++++++++++++>]<............[-]>++++++[-<++++++++++++++++>]<++++.---.+++++++++++++++++++.-------------------.[-]>++[-<++++++++++++++++>]<++++++++++++++.+++++++++++++++++++.+++++++++++++++++++++++++++++++++++..[-]>++[-<++++++++++++++++>]<++++++++.------.[-]>>[<+>----------[------------------------[<++++++++++++++[->----<]+>++[<++++++++++++[->+++++++<]>+.[-<<+>>]]<[++++++++++++[-<+++++++>]<+..>]>]<[++++++++++++[->+++++++<]>+.[-]<<++++++++++++++++++++++++++++++++++.>]>]<[->+++++[-<++++++++++++++++>]<++++++++++++.++++++++++++++++++++++.----------------------.++++++++++++++++++.[-]<++++++++++>]>>]++[-<++++++++++++++++>]<++.++++++++++.------------.++.[-]>>[<+>----------[------------------------[<++++++++++++++[->----<]+>++[<++++++++++++[->+++++++<]>+.[-<<+>>]]<[++++++++++++[-<+++++++>]<+..>]>]<[++++++++++++[->+++++++<]>+.[-]<<++++++++++++++++++++++++++++++++++.>]>]<[->+++++[-<++++++++++++++++>]<++++++++++++.++++++++++++++++++++++.----------------------.++++++++++++++++++.[-]<++++++++++>]>>]++[-<++++++++++++++++>]<++.+++++++.++++++++++++++++++.[-]++++++++++.[-]>>]<<<<[[<]<]>>[>]>[.>]>[[>]>]>>>]<]>[-<<<[[<]<]+++[-<+++++++>]<[->++>+++<<]>+>-....<<++++++++++.[-]>>>[[[[-<<.<+>>>]<.[->+<]<[->+<]>>>]<.[->+<]<[->+<]>>>]]<<<<<[<]++++++++++.[-]>[.>]]
 

Hum. Hum. Sigh...
Ok. Let's analyze.

  • Bootstrap: leave some free space.
  • Data: write "cs", leave a cell, write CS DATA (placeholder), then write "js", leave a cell, write JS DATA (placeholder), and finally write "bf", leave a cell, write BF DATA (... ?)
  • Code: read input
      • No entry : that's BF. Write BF bootstrap (>>>>), then go the the first data cell, copy data declaration (leave a cell when needed), go to BF part of the data and print as text
      • Input = "c" : that's CS. Write CS bootstrap, then go the first data cell, write '      data.Add("', then language name, then '", "', then language code (from data), by replacing " by \", \ by \\ and line breaks by \r\n. Finally, go to CS part of the data and print as text (change line breaks to real line breaks)
      • Otherwise: that's JS (and globally same as CS...)
The final part to our quine implementation would be to create a generation tool (that read templates, and inject bootstraps / code into each template to create final codes).
That's what I did, but it's clearly out of scope for this post.

Code - CS

using System;
using System.Collections.Generic;
using System.Text;

namespace Multiquine
{
    class Program
    {
        static void Main(string[] args)
        {
            Dictionary<string, string> data = new Dictionary<string, string>();
            data.Add("cs", " string language = args.Length == 0 ? \"cs\" : args[0];\r\n string code = data[language];\r\n Dictionary<string, string> bootstraps = new Dictionary<string, string>();\r\n bootstraps.Add(\"cs\", \"using System;\\r\\nusing System.Collections.Generic;\\r\\nusing System.Text;\\r\\n\\r\\nnamespace Multiquine\\r\\n{\\r\\n class Program\\r\\n {\\r\\n static void Main(string[] args)\\r\\n {\\r\\n Dictionary<string, string> data = new Dictionary<string, string>();\\r\\n\");\r\n bootstraps.Add(\"js\", \"(function(language){\\r\\n var quote = String.fromCharCode(34), backslash = String.fromCharCode(92), newline = backslash + String.fromCharCode(114) + backslash + String.fromCharCode(110);\\r\\n var data = \\r\\n {\\r\\n\");\r\n bootstraps.Add(\"bf\", \">>>>\\r\\n\");\r\n Dictionary<string, string> dataAdd = new Dictionary<string, string>();\r\n dataAdd.Add(\"cs\", \" data.Add(\\\"{0}\\\", \\\"{1}\\\");\" + Environment.NewLine);\r\n dataAdd.Add(\"js\", \" {0}: \\\"{1}\\\",\" + Environment.NewLine);\r\n string res = bootstraps[language];\r\n if (language == \"bf\")\r\n {\r\n StringBuilder sb = new StringBuilder();\r\n foreach (string key in data.Keys)\r\n {\r\n foreach (char c in key)\r\n {\r\n if (c == '\\n') continue;\r\n if (c == '\\r')\r\n {\r\n sb.Append(\"++++++++++>\");\r\n continue;\r\n }\r\n sb.Append(new string('+', (int)c) + \">\");\r\n }\r\n sb.Append(\">\");\r\n foreach (char c in data[key])\r\n {\r\n if (c == '\\n') continue;\r\n if (c == '\\r')\r\n {\r\n sb.Append(\"++++++++++>\");\r\n continue;\r\n }\r\n sb.Append(new string('+', (int)c) + \">\");\r\n }\r\n sb.Append(\">\");\r\n }\r\n res += sb.ToString() + Environment.NewLine;\r\n }\r\n else\r\n {\r\n foreach (string key in data.Keys)\r\n res += String.Format(dataAdd[language], key, data[key].Replace(\"\\\\\", \"\\\\\\\\\").Replace(\"\\\"\", \"\\\\\\\"\").Replace(Environment.NewLine, @\"\\r\\n\"));\r\n }\r\n res += code;\r\n Console.Write(res);\r\n }\r\n }\r\n}");
            data.Add("js", " };\r\n\r\n if(!language) language = 'js';\r\n var code = data[language];\r\n var bootstraps = \r\n {\r\n js: '(function(language){\\r\\n var quote = String.fromCharCode(34), backslash = String.fromCharCode(92), newline = backslash + String.fromCharCode(114) + backslash + String.fromCharCode(110);\\r\\n var data = \\r\\n {\\r\\n',\r\n cs: 'using System;\\r\\nusing System.Collections.Generic;\\r\\nusing System.Text;\\r\\n\\r\\nnamespace Multiquine\\r\\n{\\r\\n class Program\\r\\n {\\r\\n static void Main(string[] args)\\r\\n {\\r\\n Dictionary<string, string> data = new Dictionary<string, string>();\\r\\n',\r\n bf: '>>>>\\r\\n',\r\n }\r\n var res = bootstraps[language]\r\n switch(language)\r\n {\r\n case 'js':\r\n for(var i in data) res += ' ' + i + ': ' + quote + data[i].replace(new RegExp('\\\\\\\\', 'g'), backslash + backslash).replace(new RegExp(quote, 'g'), backslash + quote).replace(new RegExp(newline, 'g'), backslash + 'r' + backslash + 'n') + quote + ',\\r\\n';\r\n break;\r\n case 'cs':\r\n for(var i in data) res += ' data.Add(' + quote + i + quote + ', ' + quote + data[i].replace(new RegExp('\\\\\\\\', 'g'), backslash + backslash).replace(new RegExp(quote, 'g'), backslash + quote).replace(new RegExp(newline, 'g'), backslash + 'r' + backslash + 'n') + quote + ');\\r\\n';\r\n break;\r\n case 'bf':\r\n for(var i in data)\r\n {\r\n for (var j = 0; j < i.length; j++) { if (i.charCodeAt(j) == 13) continue; res += \"+\".repeat(i.charCodeAt(j)); res += '>'; }\r\n res += '>';\r\n for (var j = 0; j < data[i].length; j++) { if (data[i].charCodeAt(j) == 13) continue; res += \"+\".repeat(data[i].charCodeAt(j)); res += '>'; }\r\n res += '>';\r\n }\r\n res += '\\r\\n';\r\n }\r\n res += code;\r\n console.log(res);\r\n})()");
            data.Add("bf", ",>+<[>+++++++++[-<---------->]+<+[[-]>-<[-]>++[-<++++++++++++++++>]<++++++++.[-]>++++++[-<++++++++++++++++>]<++++++.+++++++++++++++.-------.-----------.+++++++++++++++++.-----------.++++++.-.[-]>++[-<++++++++++++++++>]<++++++++.[-]>++++++[-<++++++++++++++++>]<++++++++++++.-----------.+++++++++++++.-------.++++++++++++++.--------------------.++++++.--.[-]>++[-<++++++++++++++++>]<+++++++++.[-]>+++++++[-<++++++++++++++++>]<+++++++++++.[-]++++++++++.++++++++++++++++++++++.[-]>+++++++[-<++++++++++++++++>]<++++++.---------------------.+++++++++++++++++.[-]>++[-<++++++++++++++++>]<.[-]>+++++++[-<++++++++++++++++>]<+.++++.------.+++++.---------------.[-]>++[-<++++++++++++++++>]<.+++++++++++++++++++++++++++++.[-]>++[-<++++++++++++++++>]<.[-]>+++++[-<++++++++++++++++>]<+++.+++++++++++++++++++++++++++++++++.--.---------.+++++.-------.[-]>++[-<++++++++++++++++>]<++++++++++++++.[-]>++++++[-<++++++++++++++++>]<++++++.++++++++++++.---.--.[-]>++++[-<++++++++++++++++>]<+++.+++++++++++++++++++++++++++++++++++++.-------.+++++++++++++++++.[-]>++++[-<++++++++++++++++>]<+++.++++++++++++++++++++++++++++++++++++++++++++.-----------.+.[-]>++[-<++++++++++++++++>]<++++++++.+++++++++++.+.-----------.+++.------------.[-]>++++++[-<++++++++++++++++>]<++.-.++.++++++++.++++++++.-------.-----------.++++++++++++++++++.-----------.[-]>++[-<++++++++++++++++>]<.+++++++++++++++++++++++++++++.[-]>++[-<++++++++++++++++>]<.[-]>+++++[-<++++++++++++++++>]<+++.+++++++++++++++++++++++++++++++++.--.---------.+++++.-------.[-]>++[-<++++++++++++++++>]<++++++++++++++.[-]>++++++[-<++++++++++++++++>]<++++++.++++++++++++.---.--.[-]>++++[-<++++++++++++++++>]<+++.+++++++++++++++++++++++++++++++++++++.-------.+++++++++++++++++.[-]>++++[-<++++++++++++++++>]<+++.++++++++++++++++++++++++++++++++++++++++++++.-----------.+.[-]>++[-<++++++++++++++++>]<++++++++.+++++++++++++++++.-------.---------.+++.------------.[-]>++++++[-<++++++++++++++++>]<++++++++++++++.---------.++++++++++++++++++.-----------.---.+++++.---------.[-]>++[-<++++++++++++++++>]<.+++++++++++++++++++++++++++++.[-]>++[-<++++++++++++++++>]<.[-]>++++++[-<++++++++++++++++>]<++.-.++.++++++++.++++++++.-------.-----------.++++++++++++++++++.-----------.[-]>++[-<++++++++++++++++>]<.+++++++++++.-----------.[-]>+++++[-<++++++++++++++++>]<+++.+++++++++++++++++++++++++++++++++.--.---------.+++++.-------.[-]>++[-<++++++++++++++++>]<++++++++++++++.[-]>++++++[-<++++++++++++++++>]<++++++.++++++++++++.---.--.[-]>++++[-<++++++++++++++++>]<+++.+++++++++++++++++++++++++++++++++++++.-------.+++++++++++++++++.[-]>++++[-<++++++++++++++++>]<+++.++++++++++++++++++++++++++++++++++++++++++++.-----------.+.[-]>++[-<++++++++++++++++>]<++++++++.+++++++++..+++.-----------.---------.+++++++++++.-----------.[-]>++++++[-<++++++++++++++++>]<++.-.++.++++++++.++++++++.-------.-----------.++++++++++++++++++.-----------.[-]>++[-<++++++++++++++++>]<.+++++++++++.-----------.[-]>+++++[-<++++++++++++++++>]<+++.+++++++++++++++++++++++++++++++++.--.---------.+++++.-------.[-]>++[-<++++++++++++++++>]<++++++++++++++.[-]>++++++[-<++++++++++++++++>]<++++++.++++++++++++.---.--.[-]>++++[-<++++++++++++++++>]<+++.+++++++++++++++++++++++++++++++++++++.-------.+++++++++++++++++.[-]>++++[-<++++++++++++++++>]<+++.++++++++++++++++++++++++++++++++++++++++++++.-----------.+.[-]>++[-<++++++++++++++++>]<++++++++.+++++++++..-.-------.++++++++++++++++++.[-]++++++++++.++++++++++++++++++++++.[-]>+++++++[-<++++++++++++++++>]<++++++.---------------------.+++++++++++++++++.[-]>++[-<++++++++++++++++>]<.[-]>++++++[-<++++++++++++++++>]<++++.---.+++++++++++++++++++.-------------------.[-]>++[-<++++++++++++++++>]<.+++++++++++++++++++++++++++++.[-]>++[-<++++++++++++++++>]<.[-]++++++++++.++++++++++++++++++++++.[-]>+++++++[-<++++++++++++++++>]<+++++++++++.[-]++++++++++.[-]<<<[[<]<]>>[<++++++++[-<++++>]<..>>[<+>----------[------------------------[<++++++++++++++[->----<]+>++[<++++++++++++[->+++++++<]>+.[-<<+>>]]<[++++++++++++[-<+++++++>]<+..>]>]<[++++++++++++[->+++++++<]>+.[-]<<++++++++++++++++++++++++++++++++++.>]>]<[->+++++[-<++++++++++++++++>]<++++++++++++.++++++++++++++++++++++.----------------------.++++++++++++++++++.[-]<++++++++++>]>>]+++[-<++++++++++++++++>]<++++++++++.--------------------------.++.[-]>>[<+>----------[------------------------[<++++++++++++++[->----<]+>++[<++++++++++++[->+++++++<]>+.[-<<+>>]]<[++++++++++++[-<+++++++>]<+..>]>]<[++++++++++++[->+++++++<]>+.[-]<<++++++++++++++++++++++++++++++++++.>]>]<[->+++++[-<++++++++++++++++>]<++++++++++++.++++++++++++++++++++++.----------------------.++++++++++++++++++.[-]<++++++++++>]>>]++[-<++++++++++++++++>]<++.++++++++++.[-]++++++++++.[-]>>]<<<<[[<]<]>>[>]>[>]>[>]>[.>]>[>]>[>]>>>]>[-[-]>+++++++[-<++++++++++++++++>]<+++++.--.----------.+++++.-------.[-]>++[-<++++++++++++++++>]<.[-]>+++++[-<++++++++++++++++>]<+++.++++++++++++++++++++++++++++++++++++++.------.+.---------------.++++++++.[-]>+++[-<++++++++++++++++>]<+++++++++++.[-]++++++++++.[-]>+++++++[-<++++++++++++++++>]<+++++.--.----------.+++++.-------.[-]>++[-<++++++++++++++++>]<.[-]>+++++[-<++++++++++++++++>]<+++.++++++++++++++++++++++++++++++++++++++.------.+.---------------.++++++++.[-]>++[-<++++++++++++++++>]<++++++++++++++.+++++++++++++++++++++.++++++++++++++++++++++++++++++++++++++++++++.---..-------.--.+++++++++++++++++.-----------.++++++.-.+++++.[-]>++[-<++++++++++++++++>]<++++++++++++++.+++++++++++++++++++++++++.++++++++++++++++++++++++++++++.+++++++++.---------.+++++++++++++.---------.------.[-]>+++[-<++++++++++++++++>]<+++++++++++.[-]++++++++++.[-]>+++++++[-<++++++++++++++++>]<+++++.--.----------.+++++.-------.[-]>++[-<++++++++++++++++>]<.[-]>+++++[-<++++++++++++++++>]<+++.++++++++++++++++++++++++++++++++++++++.------.+.---------------.++++++++.[-]>++[-<++++++++++++++++>]<++++++++++++++.[-]>+++++[-<++++++++++++++++>]<++++.+++++++++++++++++.+++++++++++++++++++.----.[-]>+++[-<++++++++++++++++>]<+++++++++++.[-]++++++++++.[-]++++++++++.[-]>++++++[-<++++++++++++++++>]<++++++++++++++.-------------.++++++++++++.--------.++++++++++++++.---.---------------.++.++.[-]>++[-<++++++++++++++++>]<.[-]>++++[-<++++++++++++++++>]<+++++++++++++.[-]>+++++++[-<++++++++++++++++>]<+++++.---------.++++++++.-----------.++++++++.++++.------------.+++++.---------.[-]++++++++++.[-]>+++++++[-<++++++++++++++++>]<+++++++++++.[-]++++++++++.++++++++++++++++++++++....[-]>++++++[-<++++++++++++++++>]<+++.+++++++++.-----------.++++++++++++++++++..[-]>++[-<++++++++++++++++>]<.[-]>+++++[-<++++++++++++++++>]<.++++++++++++++++++++++++++++++++++.---.--------.+++++++++++.-----------------.++++++++++++.[-]++++++++++.++++++++++++++++++++++....[-]>+++++++[-<++++++++++++++++>]<+++++++++++.[-]++++++++++.++++++++++++++++++++++........[-]>+++++++[-<++++++++++++++++>]<+++.+.-------------------.+++++++++++++++++++.-----------.------.[-]>++[-<++++++++++++++++>]<.[-]>+++++++[-<++++++++++++++++>]<++++++.-------.------.-----.[-]>++[-<++++++++++++++++>]<.[-]>++++[-<++++++++++++++++>]<+++++++++++++.++++++++++++++++++++.++++++++.+++++.[-]>++[-<++++++++++++++++>]<++++++++.[-]>+++++++[-<++++++++++++++++>]<+++.+.--.---------.+++++.-------.------------.++.[-]>++[-<++++++++++++++++>]<.[-]>++++++[-<++++++++++++++++>]<+.+++++++++++++++++.-----------.++++++++++++.[-]>++[-<++++++++++++++++>]<+++++++++.[-]++++++++++.++++++++++++++++++++++........[-]>+++++++[-<++++++++++++++++>]<+++++++++++.[-]++++++++++.++++++++++++++++++++++............[-]>++++[-<++++++++++++++++>]<++++.+++++++++++++++++++++++++++++++++++++.------.+++++++++++++++++.-----------.++++++.-.-------------.+++++++++++++++++.+++++++.[-]>+++[-<++++++++++++++++>]<++++++++++++.[-]>+++++++[-<++++++++++++++++>]<+++.+.--.---------.+++++.-------.[-]>++[-<++++++++++++++++>]<++++++++++++.------------.[-]>+++++++[-<++++++++++++++++>]<+++.+.--.---------.+++++.-------.-----------------------------------------.[-]>++[-<++++++++++++++++>]<.[-]>++++++[-<++++++++++++++++>]<++++.---.+++++++++++++++++++.-------------------.[-]>++[-<++++++++++++++++>]<.+++++++++++++++++++++++++++++.[-]>++[-<++++++++++++++++>]<.[-]>++++++[-<++++++++++++++++>]<++++++++++++++.---------.++++++++++++++++++.[-]>++[-<++++++++++++++++>]<.[-]>++++[-<++++++++++++++++>]<++++.+++++++++++++++++++++++++++++++++++++.------.+++++++++++++++++.-----------.++++++.-.-------------.+++++++++++++++++.+++++++.[-]>+++[-<++++++++++++++++>]<++++++++++++.[-]>+++++++[-<++++++++++++++++>]<+++.+.--.---------.+++++.-------.[-]>++[-<++++++++++++++++>]<++++++++++++.------------.[-]>+++++++[-<++++++++++++++++>]<+++.+.--.---------.+++++.-------.-----------------------------------------.----------------------.+.++++++++++++++++++.[-]++++++++++.[-]<<<[[<]<]>>[<++[-<++++++++++++++++>]<............[-]>++++++[-<++++++++++++++++>]<++++.---.+++++++++++++++++++.-------------------.[-]>++[-<++++++++++++++++>]<++++++++++++++.+++++++++++++++++++.+++++++++++++++++++++++++++++++++++..[-]>++[-<++++++++++++++++>]<++++++++.------.[-]>>[<+>----------[------------------------[<++++++++++++++[->----<]+>++[<++++++++++++[->+++++++<]>+.[-<<+>>]]<[++++++++++++[-<+++++++>]<+..>]>]<[++++++++++++[->+++++++<]>+.[-]<<++++++++++++++++++++++++++++++++++.>]>]<[->+++++[-<++++++++++++++++>]<++++++++++++.++++++++++++++++++++++.----------------------.++++++++++++++++++.[-]<++++++++++>]>>]++[-<++++++++++++++++>]<++.++++++++++.------------.++.[-]>>[<+>----------[------------------------[<++++++++++++++[->----<]+>++[<++++++++++++[->+++++++<]>+.[-<<+>>]]<[++++++++++++[-<+++++++>]<+..>]>]<[++++++++++++[->+++++++<]>+.[-]<<++++++++++++++++++++++++++++++++++.>]>]<[->+++++[-<++++++++++++++++>]<++++++++++++.++++++++++++++++++++++.----------------------.++++++++++++++++++.[-]<++++++++++>]>>]++[-<++++++++++++++++>]<++.+++++++.++++++++++++++++++.[-]++++++++++.[-]>>]<<<<[[<]<]>>[>]>[.>]>[[>]>]>>>]<]>[-<<<[[<]<]+++[-<+++++++>]<[->++>+++<<]>+>-....<<++++++++++.[-]>>>[[[[-<<.<+>>>]<.[->+<]<[->+<]>>>]<.[->+<]<[->+<]>>>]]<<<<<[<]++++++++++.[-]>[.>]]");
            string language = args.Length == 0 ? "cs" : args[0];
            string code = data[language];
            Dictionary<string, string> bootstraps = new Dictionary<string, string>();
            bootstraps.Add("cs", "using System;\r\nusing System.Collections.Generic;\r\nusing System.Text;\r\n\r\nnamespace Multiquine\r\n{\r\n class Program\r\n {\r\n static void Main(string[] args)\r\n {\r\n Dictionary<string, string> data = new Dictionary<string, string>();\r\n");
            bootstraps.Add("js", "(function(language){\r\n var quote = String.fromCharCode(34), backslash = String.fromCharCode(92), newline = backslash + String.fromCharCode(114) + backslash + String.fromCharCode(110);\r\n var data = \r\n {\r\n");
            bootstraps.Add("bf", ">>>>\r\n");
            Dictionary<string, string> dataAdd = new Dictionary<string, string>();
            dataAdd.Add("cs", " data.Add(\"{0}\", \"{1}\");" + Environment.NewLine);
            dataAdd.Add("js", " {0}: \"{1}\"," + Environment.NewLine);
            string res = bootstraps[language];
            if (language == "bf")
            {
                StringBuilder sb = new StringBuilder();
                foreach (string key in data.Keys)
                {
                    foreach (char c in key)
                    {
                        if (c == '\n') continue;
                        if (c == '\r')
                        {
                            sb.Append("++++++++++>");
                            continue;
                        }
                        sb.Append(new string('+', (int)c) + ">");
                    }
                    sb.Append(">");
                    foreach (char c in data[key])
                    {
                        if (c == '\n') continue;
                        if (c == '\r')
                        {
                            sb.Append("++++++++++>");
                            continue;
                        }
                        sb.Append(new string('+', (int)c) + ">");
                    }
                    sb.Append(">");
                }
                res += sb.ToString() + Environment.NewLine;
            }
            else
            {
                foreach (string key in data.Keys)
                    res += String.Format(dataAdd[language], key, data[key].Replace("\\", "\\\\").Replace("\"", "\\\"").Replace(Environment.NewLine, @"\r\n"));
            }
            res += code;
            Console.Write(res);
        }
    }
}

Code - JS

(function(language){
 var quote = String.fromCharCode(34), backslash = String.fromCharCode(92), newline = backslash + String.fromCharCode(114) + backslash + String.fromCharCode(110);
 var data =
 {
 cs: " string language = args.Length == 0 ? \"cs\" : args[0];\r\n string code = data[language];\r\n Dictionary<string, string> bootstraps = new Dictionary<string, string>();\r\n bootstraps.Add(\"cs\", \"using System;\\r\\nusing System.Collections.Generic;\\r\\nusing System.Text;\\r\\n\\r\\nnamespace Multiquine\\r\\n{\\r\\n class Program\\r\\n {\\r\\n static void Main(string[] args)\\r\\n {\\r\\n Dictionary<string, string> data = new Dictionary<string, string>();\\r\\n\");\r\n bootstraps.Add(\"js\", \"(function(language){\\r\\n var quote = String.fromCharCode(34), backslash = String.fromCharCode(92), newline = backslash + String.fromCharCode(114) + backslash + String.fromCharCode(110);\\r\\n var data = \\r\\n {\\r\\n\");\r\n bootstraps.Add(\"bf\", \">>>>\\r\\n\");\r\n Dictionary<string, string> dataAdd = new Dictionary<string, string>();\r\n dataAdd.Add(\"cs\", \" data.Add(\\\"{0}\\\", \\\"{1}\\\");\" + Environment.NewLine);\r\n dataAdd.Add(\"js\", \" {0}: \\\"{1}\\\",\" + Environment.NewLine);\r\n string res = bootstraps[language];\r\n if (language == \"bf\")\r\n {\r\n StringBuilder sb = new StringBuilder();\r\n foreach (string key in data.Keys)\r\n {\r\n foreach (char c in key)\r\n {\r\n if (c == '\\n') continue;\r\n if (c == '\\r')\r\n {\r\n sb.Append(\"++++++++++>\");\r\n continue;\r\n }\r\n sb.Append(new string('+', (int)c) + \">\");\r\n }\r\n sb.Append(\">\");\r\n foreach (char c in data[key])\r\n {\r\n if (c == '\\n') continue;\r\n if (c == '\\r')\r\n {\r\n sb.Append(\"++++++++++>\");\r\n continue;\r\n }\r\n sb.Append(new string('+', (int)c) + \">\");\r\n }\r\n sb.Append(\">\");\r\n }\r\n res += sb.ToString() + Environment.NewLine;\r\n }\r\n else\r\n {\r\n foreach (string key in data.Keys)\r\n res += String.Format(dataAdd[language], key, data[key].Replace(\"\\\\\", \"\\\\\\\\\").Replace(\"\\\"\", \"\\\\\\\"\").Replace(Environment.NewLine, @\"\\r\\n\"));\r\n }\r\n res += code;\r\n Console.Write(res);\r\n }\r\n }\r\n}",
 js: " };\r\n\r\n if(!language) language = 'js';\r\n var code = data[language];\r\n var bootstraps = \r\n {\r\n js: '(function(language){\\r\\n var quote = String.fromCharCode(34), backslash = String.fromCharCode(92), newline = backslash + String.fromCharCode(114) + backslash + String.fromCharCode(110);\\r\\n var data = \\r\\n {\\r\\n',\r\n cs: 'using System;\\r\\nusing System.Collections.Generic;\\r\\nusing System.Text;\\r\\n\\r\\nnamespace Multiquine\\r\\n{\\r\\n class Program\\r\\n {\\r\\n static void Main(string[] args)\\r\\n {\\r\\n Dictionary<string, string> data = new Dictionary<string, string>();\\r\\n',\r\n bf: '>>>>\\r\\n',\r\n }\r\n var res = bootstraps[language]\r\n switch(language)\r\n {\r\n case 'js':\r\n for(var i in data) res += ' ' + i + ': ' + quote + data[i].replace(new RegExp('\\\\\\\\', 'g'), backslash + backslash).replace(new RegExp(quote, 'g'), backslash + quote).replace(new RegExp(newline, 'g'), backslash + 'r' + backslash + 'n') + quote + ',\\r\\n';\r\n break;\r\n case 'cs':\r\n for(var i in data) res += ' data.Add(' + quote + i + quote + ', ' + quote + data[i].replace(new RegExp('\\\\\\\\', 'g'), backslash + backslash).replace(new RegExp(quote, 'g'), backslash + quote).replace(new RegExp(newline, 'g'), backslash + 'r' + backslash + 'n') + quote + ');\\r\\n';\r\n break;\r\n case 'bf':\r\n for(var i in data)\r\n {\r\n for (var j = 0; j < i.length; j++) { if (i.charCodeAt(j) == 13) continue; res += \"+\".repeat(i.charCodeAt(j)); res += '>'; }\r\n res += '>';\r\n for (var j = 0; j < data[i].length; j++) { if (data[i].charCodeAt(j) == 13) continue; res += \"+\".repeat(data[i].charCodeAt(j)); res += '>'; }\r\n res += '>';\r\n }\r\n res += '\\r\\n';\r\n }\r\n res += code;\r\n console.log(res);\r\n})()",
 bf: ",>+<[>+++++++++[-<---------->]+<+[[-]>-<[-]>++[-<++++++++++++++++>]<++++++++.[-]>++++++[-<++++++++++++++++>]<++++++.+++++++++++++++.-------.-----------.+++++++++++++++++.-----------.++++++.-.[-]>++[-<++++++++++++++++>]<++++++++.[-]>++++++[-<++++++++++++++++>]<++++++++++++.-----------.+++++++++++++.-------.++++++++++++++.--------------------.++++++.--.[-]>++[-<++++++++++++++++>]<+++++++++.[-]>+++++++[-<++++++++++++++++>]<+++++++++++.[-]++++++++++.++++++++++++++++++++++.[-]>+++++++[-<++++++++++++++++>]<++++++.---------------------.+++++++++++++++++.[-]>++[-<++++++++++++++++>]<.[-]>+++++++[-<++++++++++++++++>]<+.++++.------.+++++.---------------.[-]>++[-<++++++++++++++++>]<.+++++++++++++++++++++++++++++.[-]>++[-<++++++++++++++++>]<.[-]>+++++[-<++++++++++++++++>]<+++.+++++++++++++++++++++++++++++++++.--.---------.+++++.-------.[-]>++[-<++++++++++++++++>]<++++++++++++++.[-]>++++++[-<++++++++++++++++>]<++++++.++++++++++++.---.--.[-]>++++[-<++++++++++++++++>]<+++.+++++++++++++++++++++++++++++++++++++.-------.+++++++++++++++++.[-]>++++[-<++++++++++++++++>]<+++.++++++++++++++++++++++++++++++++++++++++++++.-----------.+.[-]>++[-<++++++++++++++++>]<++++++++.+++++++++++.+.-----------.+++.------------.[-]>++++++[-<++++++++++++++++>]<++.-.++.++++++++.++++++++.-------.-----------.++++++++++++++++++.-----------.[-]>++[-<++++++++++++++++>]<.+++++++++++++++++++++++++++++.[-]>++[-<++++++++++++++++>]<.[-]>+++++[-<++++++++++++++++>]<+++.+++++++++++++++++++++++++++++++++.--.---------.+++++.-------.[-]>++[-<++++++++++++++++>]<++++++++++++++.[-]>++++++[-<++++++++++++++++>]<++++++.++++++++++++.---.--.[-]>++++[-<++++++++++++++++>]<+++.+++++++++++++++++++++++++++++++++++++.-------.+++++++++++++++++.[-]>++++[-<++++++++++++++++>]<+++.++++++++++++++++++++++++++++++++++++++++++++.-----------.+.[-]>++[-<++++++++++++++++>]<++++++++.+++++++++++++++++.-------.---------.+++.------------.[-]>++++++[-<++++++++++++++++>]<++++++++++++++.---------.++++++++++++++++++.-----------.---.+++++.---------.[-]>++[-<++++++++++++++++>]<.+++++++++++++++++++++++++++++.[-]>++[-<++++++++++++++++>]<.[-]>++++++[-<++++++++++++++++>]<++.-.++.++++++++.++++++++.-------.-----------.++++++++++++++++++.-----------.[-]>++[-<++++++++++++++++>]<.+++++++++++.-----------.[-]>+++++[-<++++++++++++++++>]<+++.+++++++++++++++++++++++++++++++++.--.---------.+++++.-------.[-]>++[-<++++++++++++++++>]<++++++++++++++.[-]>++++++[-<++++++++++++++++>]<++++++.++++++++++++.---.--.[-]>++++[-<++++++++++++++++>]<+++.+++++++++++++++++++++++++++++++++++++.-------.+++++++++++++++++.[-]>++++[-<++++++++++++++++>]<+++.++++++++++++++++++++++++++++++++++++++++++++.-----------.+.[-]>++[-<++++++++++++++++>]<++++++++.+++++++++..+++.-----------.---------.+++++++++++.-----------.[-]>++++++[-<++++++++++++++++>]<++.-.++.++++++++.++++++++.-------.-----------.++++++++++++++++++.-----------.[-]>++[-<++++++++++++++++>]<.+++++++++++.-----------.[-]>+++++[-<++++++++++++++++>]<+++.+++++++++++++++++++++++++++++++++.--.---------.+++++.-------.[-]>++[-<++++++++++++++++>]<++++++++++++++.[-]>++++++[-<++++++++++++++++>]<++++++.++++++++++++.---.--.[-]>++++[-<++++++++++++++++>]<+++.+++++++++++++++++++++++++++++++++++++.-------.+++++++++++++++++.[-]>++++[-<++++++++++++++++>]<+++.++++++++++++++++++++++++++++++++++++++++++++.-----------.+.[-]>++[-<++++++++++++++++>]<++++++++.+++++++++..-.-------.++++++++++++++++++.[-]++++++++++.++++++++++++++++++++++.[-]>+++++++[-<++++++++++++++++>]<++++++.---------------------.+++++++++++++++++.[-]>++[-<++++++++++++++++>]<.[-]>++++++[-<++++++++++++++++>]<++++.---.+++++++++++++++++++.-------------------.[-]>++[-<++++++++++++++++>]<.+++++++++++++++++++++++++++++.[-]>++[-<++++++++++++++++>]<.[-]++++++++++.++++++++++++++++++++++.[-]>+++++++[-<++++++++++++++++>]<+++++++++++.[-]++++++++++.[-]<<<[[<]<]>>[<++++++++[-<++++>]<..>>[<+>----------[------------------------[<++++++++++++++[->----<]+>++[<++++++++++++[->+++++++<]>+.[-<<+>>]]<[++++++++++++[-<+++++++>]<+..>]>]<[++++++++++++[->+++++++<]>+.[-]<<++++++++++++++++++++++++++++++++++.>]>]<[->+++++[-<++++++++++++++++>]<++++++++++++.++++++++++++++++++++++.----------------------.++++++++++++++++++.[-]<++++++++++>]>>]+++[-<++++++++++++++++>]<++++++++++.--------------------------.++.[-]>>[<+>----------[------------------------[<++++++++++++++[->----<]+>++[<++++++++++++[->+++++++<]>+.[-<<+>>]]<[++++++++++++[-<+++++++>]<+..>]>]<[++++++++++++[->+++++++<]>+.[-]<<++++++++++++++++++++++++++++++++++.>]>]<[->+++++[-<++++++++++++++++>]<++++++++++++.++++++++++++++++++++++.----------------------.++++++++++++++++++.[-]<++++++++++>]>>]++[-<++++++++++++++++>]<++.++++++++++.[-]++++++++++.[-]>>]<<<<[[<]<]>>[>]>[>]>[>]>[.>]>[>]>[>]>>>]>[-[-]>+++++++[-<++++++++++++++++>]<+++++.--.----------.+++++.-------.[-]>++[-<++++++++++++++++>]<.[-]>+++++[-<++++++++++++++++>]<+++.++++++++++++++++++++++++++++++++++++++.------.+.---------------.++++++++.[-]>+++[-<++++++++++++++++>]<+++++++++++.[-]++++++++++.[-]>+++++++[-<++++++++++++++++>]<+++++.--.----------.+++++.-------.[-]>++[-<++++++++++++++++>]<.[-]>+++++[-<++++++++++++++++>]<+++.++++++++++++++++++++++++++++++++++++++.------.+.---------------.++++++++.[-]>++[-<++++++++++++++++>]<++++++++++++++.+++++++++++++++++++++.++++++++++++++++++++++++++++++++++++++++++++.---..-------.--.+++++++++++++++++.-----------.++++++.-.+++++.[-]>++[-<++++++++++++++++>]<++++++++++++++.+++++++++++++++++++++++++.++++++++++++++++++++++++++++++.+++++++++.---------.+++++++++++++.---------.------.[-]>+++[-<++++++++++++++++>]<+++++++++++.[-]++++++++++.[-]>+++++++[-<++++++++++++++++>]<+++++.--.----------.+++++.-------.[-]>++[-<++++++++++++++++>]<.[-]>+++++[-<++++++++++++++++>]<+++.++++++++++++++++++++++++++++++++++++++.------.+.---------------.++++++++.[-]>++[-<++++++++++++++++>]<++++++++++++++.[-]>+++++[-<++++++++++++++++>]<++++.+++++++++++++++++.+++++++++++++++++++.----.[-]>+++[-<++++++++++++++++>]<+++++++++++.[-]++++++++++.[-]++++++++++.[-]>++++++[-<++++++++++++++++>]<++++++++++++++.-------------.++++++++++++.--------.++++++++++++++.---.---------------.++.++.[-]>++[-<++++++++++++++++>]<.[-]>++++[-<++++++++++++++++>]<+++++++++++++.[-]>+++++++[-<++++++++++++++++>]<+++++.---------.++++++++.-----------.++++++++.++++.------------.+++++.---------.[-]++++++++++.[-]>+++++++[-<++++++++++++++++>]<+++++++++++.[-]++++++++++.++++++++++++++++++++++....[-]>++++++[-<++++++++++++++++>]<+++.+++++++++.-----------.++++++++++++++++++..[-]>++[-<++++++++++++++++>]<.[-]>+++++[-<++++++++++++++++>]<.++++++++++++++++++++++++++++++++++.---.--------.+++++++++++.-----------------.++++++++++++.[-]++++++++++.++++++++++++++++++++++....[-]>+++++++[-<++++++++++++++++>]<+++++++++++.[-]++++++++++.++++++++++++++++++++++........[-]>+++++++[-<++++++++++++++++>]<+++.+.-------------------.+++++++++++++++++++.-----------.------.[-]>++[-<++++++++++++++++>]<.[-]>+++++++[-<++++++++++++++++>]<++++++.-------.------.-----.[-]>++[-<++++++++++++++++>]<.[-]>++++[-<++++++++++++++++>]<+++++++++++++.++++++++++++++++++++.++++++++.+++++.[-]>++[-<++++++++++++++++>]<++++++++.[-]>+++++++[-<++++++++++++++++>]<+++.+.--.---------.+++++.-------.------------.++.[-]>++[-<++++++++++++++++>]<.[-]>++++++[-<++++++++++++++++>]<+.+++++++++++++++++.-----------.++++++++++++.[-]>++[-<++++++++++++++++>]<+++++++++.[-]++++++++++.++++++++++++++++++++++........[-]>+++++++[-<++++++++++++++++>]<+++++++++++.[-]++++++++++.++++++++++++++++++++++............[-]>++++[-<++++++++++++++++>]<++++.+++++++++++++++++++++++++++++++++++++.------.+++++++++++++++++.-----------.++++++.-.-------------.+++++++++++++++++.+++++++.[-]>+++[-<++++++++++++++++>]<++++++++++++.[-]>+++++++[-<++++++++++++++++>]<+++.+.--.---------.+++++.-------.[-]>++[-<++++++++++++++++>]<++++++++++++.------------.[-]>+++++++[-<++++++++++++++++>]<+++.+.--.---------.+++++.-------.-----------------------------------------.[-]>++[-<++++++++++++++++>]<.[-]>++++++[-<++++++++++++++++>]<++++.---.+++++++++++++++++++.-------------------.[-]>++[-<++++++++++++++++>]<.+++++++++++++++++++++++++++++.[-]>++[-<++++++++++++++++>]<.[-]>++++++[-<++++++++++++++++>]<++++++++++++++.---------.++++++++++++++++++.[-]>++[-<++++++++++++++++>]<.[-]>++++[-<++++++++++++++++>]<++++.+++++++++++++++++++++++++++++++++++++.------.+++++++++++++++++.-----------.++++++.-.-------------.+++++++++++++++++.+++++++.[-]>+++[-<++++++++++++++++>]<++++++++++++.[-]>+++++++[-<++++++++++++++++>]<+++.+.--.---------.+++++.-------.[-]>++[-<++++++++++++++++>]<++++++++++++.------------.[-]>+++++++[-<++++++++++++++++>]<+++.+.--.---------.+++++.-------.-----------------------------------------.----------------------.+.++++++++++++++++++.[-]++++++++++.[-]<<<[[<]<]>>[<++[-<++++++++++++++++>]<............[-]>++++++[-<++++++++++++++++>]<++++.---.+++++++++++++++++++.-------------------.[-]>++[-<++++++++++++++++>]<++++++++++++++.+++++++++++++++++++.+++++++++++++++++++++++++++++++++++..[-]>++[-<++++++++++++++++>]<++++++++.------.[-]>>[<+>----------[------------------------[<++++++++++++++[->----<]+>++[<++++++++++++[->+++++++<]>+.[-<<+>>]]<[++++++++++++[-<+++++++>]<+..>]>]<[++++++++++++[->+++++++<]>+.[-]<<++++++++++++++++++++++++++++++++++.>]>]<[->+++++[-<++++++++++++++++>]<++++++++++++.++++++++++++++++++++++.----------------------.++++++++++++++++++.[-]<++++++++++>]>>]++[-<++++++++++++++++>]<++.++++++++++.------------.++.[-]>>[<+>----------[------------------------[<++++++++++++++[->----<]+>++[<++++++++++++[->+++++++<]>+.[-<<+>>]]<[++++++++++++[-<+++++++>]<+..>]>]<[++++++++++++[->+++++++<]>+.[-]<<++++++++++++++++++++++++++++++++++.>]>]<[->+++++[-<++++++++++++++++>]<++++++++++++.++++++++++++++++++++++.----------------------.++++++++++++++++++.[-]<++++++++++>]>>]++[-<++++++++++++++++>]<++.+++++++.++++++++++++++++++.[-]++++++++++.[-]>>]<<<<[[<]<]>>[>]>[.>]>[[>]>]>>>]<]>[-<<<[[<]<]+++[-<+++++++>]<[->++>+++<<]>+>-....<<++++++++++.[-]>>>[[[[-<<.<+>>>]<.[->+<]<[->+<]>>>]<.[->+<]<[->+<]>>>]]<<<<<[<]++++++++++.[-]>[.>]]",
 };

 if(!language) language = 'js';
 var code = data[language];
 var bootstraps =
 {
 js: '(function(language){\r\n var quote = String.fromCharCode(34), backslash = String.fromCharCode(92), newline = backslash + String.fromCharCode(114) + backslash + String.fromCharCode(110);\r\n var data = \r\n {\r\n',
 cs: 'using System;\r\nusing System.Collections.Generic;\r\nusing System.Text;\r\n\r\nnamespace Multiquine\r\n{\r\n class Program\r\n {\r\n static void Main(string[] args)\r\n {\r\n Dictionary<string, string> data = new Dictionary<string, string>();\r\n',
 bf: '>>>>\r\n',
 }
 var res = bootstraps[language]
 switch(language)
 {
 case 'js':
 for(var i in data) res += ' ' + i + ': ' + quote + data[i].replace(new RegExp('\\\\', 'g'), backslash + backslash).replace(new RegExp(quote, 'g'), backslash + quote).replace(new RegExp(newline, 'g'), backslash + 'r' + backslash + 'n') + quote + ',\r\n';
 break;
 case 'cs':
 for(var i in data) res += ' data.Add(' + quote + i + quote + ', ' + quote + data[i].replace(new RegExp('\\\\', 'g'), backslash + backslash).replace(new RegExp(quote, 'g'), backslash + quote).replace(new RegExp(newline, 'g'), backslash + 'r' + backslash + 'n') + quote + ');\r\n';
 break;
 case 'bf':
 for(var i in data)
 {
 for (var j = 0; j < i.length; j++) { if (i.charCodeAt(j) == 13) continue; res += "+".repeat(i.charCodeAt(j)); res += '>'; }
res += '>';
for (var j = 0; j < data[i].length; j++) { if (data[i].charCodeAt(j) == 13) continue; res += "+".repeat(data[i].charCodeAt(j)); res += '>'; }
res += '>';
 }
 res += '\r\n';
 }
 res += code;
 console.log(res);
})()

Code - BF

This one is really long... So, please generate it from either JS or CS code :)

Note

I strongly suggest NOT TO USE the online interpreter (nor any interpreter actually) to try the BF code. I yo're using Ubuntu, you can use the BF package (if you're on any other Linux distribution, you can use the same package by building the source - it even works on Mac OSX).

And if you're using Windows, then you can download Cydia, and compile the BF sources as well 

Mutiquine: structure (3)

Context

The multiquine structure is composed by the bootstrap, the data declaration and the code.
Here is a C# example.

/*BOOTSTRAP*/
using System;
using System.Collections.Generic;
using System.Text;

namespace Multiquine
{
    class Program
    {
        static void Main(string[] args)
        {
            Dictionary<string, string> data = new Dictionary<string, string>();
/*DATA*/
            data.Add("cs", "CS_CODE_PLACEHOLDER");
            data.Add("js", "JS_CODE_PLACEHOLDER");
            data.Add("bf", "BF_CODE_PLACEHOLDER");
/*CODE*/
            string language = args.Length == 0 ? "cs" : args[0];
            string code = data[language];
            Dictionary<string, string> bootstraps = new Dictionary<string, string>();
            bootstraps.Add("cs", "CS_BOOTSTRAP_PLACEHOLDER");
            bootstraps.Add("js", "JS_BOOTSTRAP_PLACEHOLDER");
            bootstraps.Add("bf", "BF_BOOTSTRAP_PLACEHOLDER");
            Dictionary<string, string> dataAdd = new Dictionary<string, string>();
            dataAdd.Add("cs", " data.Add(\"{0}\", \"{1}\");" + Environment.NewLine);
            dataAdd.Add("js", " {0}: \"{1}\"," + Environment.NewLine);
            string res = bootstraps[language];
            if (language == "bf")
            {
                StringBuilder sb = new StringBuilder();
                foreach (string key in data.Keys)
                {
                    foreach (char c in key)
                    {
                        if (c == '\n') continue;
                        if (c == '\r')
                        {
                            sb.Append("++++++++++>");
                            continue;
                        }
                        sb.Append(new string('+', (int)c) + ">");
                    }
                    sb.Append(">");
                    foreach (char c in data[key])
                    {
                        if (c == '\n') continue;
                        if (c == '\r')
                        {
                            sb.Append("++++++++++>");
                            continue;
                        }
                        sb.Append(new string('+', (int)c) + ">");
                    }
                    sb.Append(">");
                }
                res += sb.ToString() + Environment.NewLine;
            }
            else
            {
                foreach (string key in data.Keys)
                    res += String.Format(dataAdd[language], key, data[key].Replace("\\", "\\\\").Replace("\"", "\\\"").Replace(Environment.NewLine, @"\r\n"));
            }
            res += code;
            Console.Write(res);
        }
    }
}

The bootstrap 

/*BOOTSTRAP*/
using System;
using System.Collections.Generic;
using System.Text;

namespace Multiquine
{
    class Program
    {
        static void Main(string[] args)
        {
            Dictionary<string, string> data = new Dictionary<string, string>();
As mentionned, it's a static part, in C#, to initialize our program the way source code should be.
It also initializes the data structure, though the data themselves are not set yet.

The data

/*DATA*/
            data.Add("cs", "CS_CODE_PLACEHOLDER");
            data.Add("js", "JS_CODE_PLACEHOLDER");
            data.Add("bf", "BF_CODE_PLACEHOLDER");
In other words, for each language, add some data (we use placeholders that will be filled later)

The code

/*CODE*/
            string language = args.Length == 0 ? "cs" : args[0];
            string code = data[language];
            Dictionary<string, string> bootstraps = new Dictionary<string, string>();
            bootstraps.Add("cs", "CS_BOOTSTRAP_PLACEHOLDER");
            bootstraps.Add("js", "JS_BOOTSTRAP_PLACEHOLDER");
            bootstraps.Add("bf", "BF_BOOTSTRAP_PLACEHOLDER");
            Dictionary<string, string> dataAdd = new Dictionary<string, string>();
            dataAdd.Add("cs", " data.Add(\"{0}\", \"{1}\");" + Environment.NewLine);
            dataAdd.Add("js", " {0}: \"{1}\"," + Environment.NewLine);
            string res = bootstraps[language];
            if (language == "bf")
            {
                StringBuilder sb = new StringBuilder();
                foreach (string key in data.Keys)
                {
                    foreach (char c in key)
                    {
                        if (c == '\n') continue;
                        if (c == '\r')
                        {
                            sb.Append("++++++++++>");
                            continue;
                        }
                        sb.Append(new string('+', (int)c) + ">");
                    }
                    sb.Append(">");
                    foreach (char c in data[key])
                    {
                        if (c == '\n') continue;
                        if (c == '\r')
                        {
                            sb.Append("++++++++++>");
                            continue;
                        }
                        sb.Append(new string('+', (int)c) + ">");
                    }
                    sb.Append(">");
                }
                res += sb.ToString() + Environment.NewLine;
            }
            else
            {
                foreach (string key in data.Keys)
                    res += String.Format(dataAdd[language], key, data[key].Replace("\\", "\\\\").Replace("\"", "\\\"").Replace(Environment.NewLine, @"\r\n"));
            }
            res += code;
            Console.Write(res);
        }
    }
}
Everything that arrives after data declaration is the code. And our C# code does exactly what JS code will do, or BF code as well.

  • First, determine the desired output language (CS, JS or BF)
  • Then, initialize the output with target language's bootstrap (again, using placeholders, as other languages' bootstrap codes are not defined yet)
  • In theory, we should do the same for the 2 other languages, and only then move to the next part of the code, as it requires some knowledge about other quines' data declaration structure...
    • Build BF data declaration (write language name, and then language data, for each language), just make sure line breaks are processed in a slightly different way (to be more compliant with different interpreters)
    • OR build other languages data declaration (C# and JS were grouped because quite similar)
  • Finally, append target language's specific code (id est, append data as it's supposed to be the code, as string)
The next post will present the 3 templates, for CS, BF and JS, and the final results.

Multiquine : construction (2)

Context

We defined what a multiquine is, and picked 3 languages (C#, JS and BF).
Now, let's build our multiquine.

As a reminder, when building a simple quine, we stated that a quine needs 2 parts:

  • The data
  • The code
Code's goal is to write data definition, based on data contents, then write code, again based on data contents
And data is written afterwards, when code is completed, based on code source code.

To make things a bit more clear, let's introduce a third part (actually, the first one in our source codes): the bootstrap.

The bootstrap will be some static source code, written before data declaration.

Then, to build a multiquine:

  • Write the bootstrap
  • Declare data (leaving some blanks to be filled later) for each language
  • Write code
    • For a given language L (passed as program argument)
      • Write target bootstrap
      • Declare data the way it should be declared in language L
        • Note: declare data for all languages
      • Write code based on specific data related to language L

Multiquine : definition (1)

Context

We already implemented a quine, and also what we called a double-quine, though it's definitely not an official name.
Actually, double-quine may make people think it's a multiquine of 2 languages, which is not the case.

Let's first define what a multiquine is, and then try to implement one.
Considering a set S of N Turing-complete programming languages, a multiquine is a program, written in a language from S, that:

  • can be run without argument. It then prints its own source code, like a normal quine
  • can be run with an argument (that can have, in theory, N-1 different values). It then prints another program in a different language from S, that have the same 2 properties we are describing.
In other words, considering programming languages A, B and C, I have 3 programs Pa, Pb, Pc written in A, B and C
  • When Pa() is executed, it prints Pa's source code.
  • When Pa(arg1) is executed, it prints Pb's source code.
  • When Pa(arg2) is executed, it prints Pc's source code.
  • When Pb() is executed, it prints Pb's source code.
  • When Pb(arg3) is executed, it prints Pa's source code.
  • When Pb(arg4) is executed, it prints Pc's source code.
  • When Pc() is executed, it prints Pb's source code.
  • When Pc(arg5) is executed, it prints Pa's source code.
  • When Pc(arg6) is executed, it prints Pb's source code.
arg1 may be equal to arg6, arg2 to arg4 and arg4 to arg5, though it's not a mandatory condition.

In the following articles, we'll implement a multiquine for the 3 languages BrainFuck (of course), C# (I don't like Java...) and JavaScript (yes, it's a language)

lundi 13 mars 2017

Quine: double quine (6)

Context

Now that our quine is done, let's solve another quine-related problem.
There are programs named quine chains, or quine relays: a program in a language A generates some source code in a language B, that generates some source code in a language C, that generates ... until it generates the same program in language A. See this page for an incredible quine relay that chains about 100 different programming languages !!
Here, we'll use a slightly simpler chain, with 2 programs written using BF. The idea is to have 2 (different) source codes, each one generating the other.
Again, we can apply the fixed point theorem to prove its existence. For any Turing-complete language, and for any string chains X and Y, there is a program able to generate its own source code, preceded by string X and followed by string Y.
Therefore

  • we can have a program A that will be a simple "Print B", B being another program
  • then, program B will be "Print A", or in other words, Print "Print B"
This is just pseudo-code of course, but we can see here that, X being Print "Print  and Y being ", we can find a B such as B prints A and A prints B

Initial state

  • Memory: empty
  • Cursor: first cell
  • Input: empty

Process

  • Let's start to leave 4 empty cells, then store some data (to be generated afterwards)
  • Print > 4 times (for the 4 emptys cells mentionned above)
  • Print some code that generates the same data
    • Go on first data cell
    • Print + as many times as needed
    • Print >
  • Print some code that print some code that generates the same data ^^
    • Code is (see above): go on first cell, print + as many times as needed, print >
    • We just need to write those same instructions, instead of executing them
  • Print some code that print instructions based on data
    • In our simple quine, it was just going through the data and displayed them as characters
    • Here, we need to print some code that do the same
  • Once it's done, take all the code after data generation part, convert it (see what we did for quine), and put it inside our code
  • And that's all. There is obviously no need to write the second program : it'll be automatically generated by this one :)

Code - "first" program - try it

>>>>++++++++++++++++++>+++++++++++++++++++++++++++++++++++++++++++++++++>++++++++++++++++++>+++++++++++++++++++++++++++++++++++++++++++++++++++>++++++++++++++++++>++++++++++++++++++>+>+>+>+>+>+>+>+++++++++++++++++++++++++++++++++++++++++++++++++>+++>++++++++++++++++++++>+>+>+>+>+>+>+>+>+>++++++++++++++++++++>+>+>+>+>+>+>++++++++++++++++++>++++++++++++++++++>+++++++++++++++++++++++++++++++++++++++++++++++++++>++++++++++++++++++++>+++>++++>++++>++++>++++>++++++++++++++++++++>+>++++++++++++++++++++>+++++++++++++++++++++++++++++++++++++++++++++++++>+++++++++++++++++++++++++++++++++++++++++++++++++>+++>++++++++++++++++++>++++>++++++++++++++++++>++++++++++++++++++>+>++++++++++++++++++++>++++++++++++++++++++>++++++++++++++++++++>+++++++++++++++++++++++++++++++++++++++++++++++++++>++++++++++++++++++>+++++++++++++++++++++++++++++++++++++++++++++++++>+++>++++++++++++++++++++>+>++++++++++++++++++>+++++++++++++++++++++++++++++++++++++++++++++++++++>++++++++++++++++++>++++>+++++++++++++++++++++++++++++++++++++++++++++++++>+++>++++++++++++++++++++>+>++++++++++++++++++>+++++++++++++++++++++++++++++++++++++++++++++++++++>++++++++++++++++++++>++++++++++++++++++++>++++++++++++++++++++>+++++++++++++++++++++++++++++++++++++++++++++++++++>++++++++++++++++++>+++++++++++++++++++++++++++++++++++++++++++++++++>+++>++++++++++++++++++++>++++++++++++++++++++>+>++++++++++++++++++++>+>++++++++++++++++++++>+>++++++++++++++++++>++++++++++++++++++>++++++++++++++++++>++++++++++++++++++>+++++++++++++++++++++++++++++++++++++++++++++++++++>++++++++++++++++++>+++++++++++++++++++++++++++++++++++++++++++++++++>+++>++++++++++++++++++++>+>++++++++++++++++++++>+>++++++++++++++++++>++++++++++++++++++>+++++++++++++++++++++++++++++++++++++++++++++++++++>++++++++++++++++++++>+++>+++>++++++++++++++++++++>++++++++++++++++++++>++++++++++++++++++++>+>+>++++++++++++++++++++>+>+>+>+++++++++++++++++++++++++++++++++++++++++++++++++>+++>++++++++++++++++++++>+>+>++++++++++++++++++++>+>+>++++++++++++++++++++>+>++++++++++++++++++>++++++++++++++++++>++++++++++++++++++>+++++++++++++++++++++++++++++++++++++++++++++++++++>++++++++++++++++++++>++++++++++++++++++++>++++++++++++++++++++>+++++++++++++++++++++++++++++++++++++++++++++++++>+++>++++++++++++++++++>++++++++++++++++++>++++++++++++++++++>+>++++++++++++++++++++>++++++++++++++++++++>++++++++++++++++++++>+++++++++++++++++++++++++++++++++++++++++++++++++++>++++++++++++++++++>+>++++++++++++++++++>+++>+++++++++++++++++++++++++++++++++++++++++++++++++>++++++++++++++++++>+++++++++++++++++++++++++++++++++++++++++++++++++++>++++++++++++++++++++>++++>++++++++++++++++++++>++++++++++++++++++++>++++++++++++++++++++>++++++++++++++++++++>++++++++++++++++++++>++++>+++++++++++++++++++++++++++++++++++++++++++++++++>++++++++++++++++++>+++++++++++++++++++++++++++++++++++++++++++++++++++>++++++++++++++++++++>++++>+++++++++++++++++++++++++++++++++++++++++++++++++>++++++++++++++++++++>+++++++++++++++++++++++++++++++++++++++++++++++++++>++++++++++++++++++>++++>+++++++++++++++++++++++++++++++++++++++++++++++++>++++++++++++++++++>+++++++++++++++++++++++++++++++++++++++++++++++++++>++++++++++++++++++++>++++>++++>++++++++++++++++++++>++++++++++++++++++++>++++>++++>++++>++++>++++>++++>++++>++++++++++++++++++++>++++++++++++++++++++>++++++++++++++++++++>++++>++++++++++++++++++>++++++++++++++++++>++++>++++++++++++++++++>++++++++++++++++++>++++>++++++++++++++++++++>++++>++++>++++>++++>++++>++++>++++>++++>++++>++++++++++++++++++>++++>++++++++++++++++++++>++++>++++>++++>++++>++++>++++>++++++++++++++++++>++++++++++++++++++>++++>++++>+++++++++++++++++++++++++++++++++++++++++++++++++>++++++++++++++++++++>+++++++++++++++++++++++++++++++++++++++++++++++++++>++++++++++++++++++>++++>++++++++++++++++++>++++++++++++++++++>++++++++++++++++++>++++++++++++++++++>++++++++++++++++++>++++>++++++++++++++++++++>++++++++++++++++++++>++++>++++++++++++++++++++>++++>++++>++++>++++>++++++++++++++++++>++++++++++++++++++>++++++++++++++++++>++++>++++++++++++++++++++>++++>++++++++++++++++++>++++>++++++++++++++++++++>++++++++++++++++++++>++++++++++++++++++++>++++++++++++++++++++>++++>++++>++++++++++++++++++>++++++++++++++++++>++++>++++++++++++++++++>++++++++++++++++++>++++++++++++++++++>++++>++++++++++++++++++++>++++++++++++++++++++>++++++++++++++++++++>++++++++++++++++++++>++++>++++++++++++++++++>++++++++++++++++++>++++++++++++++++++>++++++++++++++++++>++++>++++>++++++++++++++++++++>++++++++++++++++++++>++++>++++++++++++++++++>++++>++++>++++>+++++++++++++++++++++++++++++++++++++++++++++++++>++++++++++++++++++++>+++++++++++++++++++++++++++++++++++++++++++++++++++>++++++++++++++++++>++++>+++++++++++++++++++++++++++++++++++++++++++++++++>++++++++++++++++++>+++++++++++++++++++++++++++++++++++++++++++++++++++>++++++++++++++++++++>++++>++++++++++++++++++++>++++++++++++++++++++>++++++++++++++++++++>++++++++++++++++++++>++++++++++++++++++++>++++>++++++++++++++++++>++++++++++++++++++>++++>++++++++++++++++++>++++++++++++++++++>++++++++++++++++++>++++>++++>++++++++++++++++++++>++++++++++++++++++++>++++>++++++++++++++++++>++++>++++>++++>++++++++++++++++++++>++++>++++++++++++++++++>++++++++++++++++++>++++>+++++++++++++++++++++++++++++++++++++++++++++++++>++++++++++++++++++++>+++++++++++++++++++++++++++++++++++++++++++++++++++>++++++++++++++++++>++++>+++++++++++++++++++++++++++++++++++++++++++++++++>++++++++++++++++++>+++++++++++++++++++++++++++++++++++++++++++++++++++>++++++++++++++++++++>++++>++++++++++++++++++++>++++++++++++++++++++>++++++++++++++++++++>++++++++++++++++++++>++++>++++++++++++++++++++>++++>++++++++++++++++++>++++++++++++++++++>++++>++++++++++++++++++>++++++++++++++++++>++++>++++++++++++++++++++>++++>++++++++++++++++++>++++++++++++++++++>++++>+++++++++++++++++++++++++++++++++++++++++++++++++>++++++++++++++++++++>+++++++++++++++++++++++++++++++++++++++++++++++++++>++++++++++++++++++>++++>++++++++++++++++++>++++++++++++++++++>++++++++++++++++++>++++++++++++++++++>++++++++++++++++++>++++>++++>++++>+++++++++++++++++++++++++++++++++++++++++++++++++>++++++++++++++++++++>+++++++++++++++++++++++++++++++++++++++++++++++++++>++++++++++++++++++>++++>+++++++++++++++++++++++++++++++++++++++++++++++++>++++++++++++++++++>+++++++++++++++++++++++++++++++++++++++++++++++++++>++++++++++++++++++++>++++>++++>++++>++++>++++++++++++++++++++>++++++++++++++++++++>++++++++++++++++++++>++++++++++++++++++++>++++++++++++++++++++>++++>+++++++++++++++++++++++++++++++++++++++++++++++++>++++++++++++++++++>+++++++++++++++++++++++++++++++++++++++++++++++++++>++++++++++++++++++++>++++>+++++++++++++++++++++++++++++++++++++++++++++++++>++++++++++++++++++++>+++++++++++++++++++++++++++++++++++++++++++++++++++>++++++++++++++++++>++++>++++++++++++++++++>++++++++++++++++++>++++++++++++++++++>++++++++++++++++++>++++++++++++++++++>++++>++++++++++++++++++++>++++++++++++++++++++>++++++++++++++++++++>++++++++++++++++++++>++++>++++++++++++++++++>++++++++++++++++++>++++>++++++++++++++++++++>++++>++++++++++++++++++>++++++++++++++++++>++++++++++++++++++>++++>++++++++++++++++++++>++++++++++++++++++++>++++++++++++++++++++>++++++++++++++++++++>++++++++++++++++++++>++++><[<]<<+++++++[->+++++++++>++++++<<]>-....>+>[[-<.<<+>>>]<[-<<+>>>+<]<.[->+<]>>>]<<<<[<]>[-.>]

Code - "second" program - try it

>>>>++++++++++++++++++>+++++++++++++++++++++++++++++++++++++++++++++++++>++++++++++++++++++>+++++++++++++++++++++++++++++++++++++++++++++++++++>++++++++++++++++++>++++++++++++++++++>+>+>+>+>+>+>+>+++++++++++++++++++++++++++++++++++++++++++++++++>+++>++++++++++++++++++++>+>+>+>+>+>+>+>+>+>++++++++++++++++++++>+>+>+>+>+>+>++++++++++++++++++>++++++++++++++++++>+++++++++++++++++++++++++++++++++++++++++++++++++++>++++++++++++++++++++>+++>++++>++++>++++>++++>++++++++++++++++++++>+>++++++++++++++++++++>+++++++++++++++++++++++++++++++++++++++++++++++++>+++++++++++++++++++++++++++++++++++++++++++++++++>+++>++++++++++++++++++>++++>++++++++++++++++++>++++++++++++++++++>+>++++++++++++++++++++>++++++++++++++++++++>++++++++++++++++++++>+++++++++++++++++++++++++++++++++++++++++++++++++++>++++++++++++++++++>+++++++++++++++++++++++++++++++++++++++++++++++++>+++>++++++++++++++++++++>+>++++++++++++++++++>+++++++++++++++++++++++++++++++++++++++++++++++++++>++++++++++++++++++>++++>+++++++++++++++++++++++++++++++++++++++++++++++++>+++>++++++++++++++++++++>+>++++++++++++++++++>+++++++++++++++++++++++++++++++++++++++++++++++++++>++++++++++++++++++++>++++++++++++++++++++>++++++++++++++++++++>+++++++++++++++++++++++++++++++++++++++++++++++++++>++++++++++++++++++>+++++++++++++++++++++++++++++++++++++++++++++++++>+++>++++++++++++++++++++>++++++++++++++++++++>+>++++++++++++++++++++>+>++++++++++++++++++++>+>++++++++++++++++++>++++++++++++++++++>++++++++++++++++++>++++++++++++++++++>+++++++++++++++++++++++++++++++++++++++++++++++++++>++++++++++++++++++>+++++++++++++++++++++++++++++++++++++++++++++++++>+++>++++++++++++++++++++>+>++++++++++++++++++++>+>++++++++++++++++++>++++++++++++++++++>+++++++++++++++++++++++++++++++++++++++++++++++++++>++++++++++++++++++++>+++>+++>++++++++++++++++++++>++++++++++++++++++++>++++++++++++++++++++>+>+>++++++++++++++++++++>+>+>+>+++++++++++++++++++++++++++++++++++++++++++++++++>+++>++++++++++++++++++++>+>+>++++++++++++++++++++>+>+>++++++++++++++++++++>+>++++++++++++++++++>++++++++++++++++++>++++++++++++++++++>+++++++++++++++++++++++++++++++++++++++++++++++++++>++++++++++++++++++++>++++++++++++++++++++>++++++++++++++++++++>+++++++++++++++++++++++++++++++++++++++++++++++++>+++>++++++++++++++++++>++++++++++++++++++>++++++++++++++++++>+>++++++++++++++++++++>++++++++++++++++++++>++++++++++++++++++++>+++++++++++++++++++++++++++++++++++++++++++++++++++>++++++++++++++++++>+>++++++++++++++++++>+++>+++++++++++++++++++++++++++++++++++++++++++++++++>++++++++++++++++++>+++++++++++++++++++++++++++++++++++++++++++++++++++>++++++++++++++++++++>++++>++++++++++++++++++++>++++++++++++++++++++>++++++++++++++++++++>++++++++++++++++++++>++++++++++++++++++++>++++>+++++++++++++++++++++++++++++++++++++++++++++++++>++++++++++++++++++>+++++++++++++++++++++++++++++++++++++++++++++++++++>++++++++++++++++++++>++++>+++++++++++++++++++++++++++++++++++++++++++++++++>++++++++++++++++++++>+++++++++++++++++++++++++++++++++++++++++++++++++++>++++++++++++++++++>++++>+++++++++++++++++++++++++++++++++++++++++++++++++>++++++++++++++++++>+++++++++++++++++++++++++++++++++++++++++++++++++++>++++++++++++++++++++>++++>++++>++++++++++++++++++++>++++++++++++++++++++>++++>++++>++++>++++>++++>++++>++++>++++++++++++++++++++>++++++++++++++++++++>++++++++++++++++++++>++++>++++++++++++++++++>++++++++++++++++++>++++>++++++++++++++++++>++++++++++++++++++>++++>++++++++++++++++++++>++++>++++>++++>++++>++++>++++>++++>++++>++++>++++++++++++++++++>++++>++++++++++++++++++++>++++>++++>++++>++++>++++>++++>++++++++++++++++++>++++++++++++++++++>++++>++++>+++++++++++++++++++++++++++++++++++++++++++++++++>++++++++++++++++++++>+++++++++++++++++++++++++++++++++++++++++++++++++++>++++++++++++++++++>++++>++++++++++++++++++>++++++++++++++++++>++++++++++++++++++>++++++++++++++++++>++++++++++++++++++>++++>++++++++++++++++++++>++++++++++++++++++++>++++>++++++++++++++++++++>++++>++++>++++>++++>++++++++++++++++++>++++++++++++++++++>++++++++++++++++++>++++>++++++++++++++++++++>++++>++++++++++++++++++>++++>++++++++++++++++++++>++++++++++++++++++++>++++++++++++++++++++>++++++++++++++++++++>++++>++++>++++++++++++++++++>++++++++++++++++++>++++>++++++++++++++++++>++++++++++++++++++>++++++++++++++++++>++++>++++++++++++++++++++>++++++++++++++++++++>++++++++++++++++++++>++++++++++++++++++++>++++>++++++++++++++++++>++++++++++++++++++>++++++++++++++++++>++++++++++++++++++>++++>++++>++++++++++++++++++++>++++++++++++++++++++>++++>++++++++++++++++++>++++>++++>++++>+++++++++++++++++++++++++++++++++++++++++++++++++>++++++++++++++++++++>+++++++++++++++++++++++++++++++++++++++++++++++++++>++++++++++++++++++>++++>+++++++++++++++++++++++++++++++++++++++++++++++++>++++++++++++++++++>+++++++++++++++++++++++++++++++++++++++++++++++++++>++++++++++++++++++++>++++>++++++++++++++++++++>++++++++++++++++++++>++++++++++++++++++++>++++++++++++++++++++>++++++++++++++++++++>++++>++++++++++++++++++>++++++++++++++++++>++++>++++++++++++++++++>++++++++++++++++++>++++++++++++++++++>++++>++++>++++++++++++++++++++>++++++++++++++++++++>++++>++++++++++++++++++>++++>++++>++++>++++++++++++++++++++>++++>++++++++++++++++++>++++++++++++++++++>++++>+++++++++++++++++++++++++++++++++++++++++++++++++>++++++++++++++++++++>+++++++++++++++++++++++++++++++++++++++++++++++++++>++++++++++++++++++>++++>+++++++++++++++++++++++++++++++++++++++++++++++++>++++++++++++++++++>+++++++++++++++++++++++++++++++++++++++++++++++++++>++++++++++++++++++++>++++>++++++++++++++++++++>++++++++++++++++++++>++++++++++++++++++++>++++++++++++++++++++>++++>++++++++++++++++++++>++++>++++++++++++++++++>++++++++++++++++++>++++>++++++++++++++++++>++++++++++++++++++>++++>++++++++++++++++++++>++++>++++++++++++++++++>++++++++++++++++++>++++>+++++++++++++++++++++++++++++++++++++++++++++++++>++++++++++++++++++++>+++++++++++++++++++++++++++++++++++++++++++++++++++>++++++++++++++++++>++++>++++++++++++++++++>++++++++++++++++++>++++++++++++++++++>++++++++++++++++++>++++++++++++++++++>++++>++++>++++>+++++++++++++++++++++++++++++++++++++++++++++++++>++++++++++++++++++++>+++++++++++++++++++++++++++++++++++++++++++++++++++>++++++++++++++++++>++++>+++++++++++++++++++++++++++++++++++++++++++++++++>++++++++++++++++++>+++++++++++++++++++++++++++++++++++++++++++++++++++>++++++++++++++++++++>++++>++++>++++>++++>++++++++++++++++++++>++++++++++++++++++++>++++++++++++++++++++>++++++++++++++++++++>++++++++++++++++++++>++++>+++++++++++++++++++++++++++++++++++++++++++++++++>++++++++++++++++++>+++++++++++++++++++++++++++++++++++++++++++++++++++>++++++++++++++++++++>++++>+++++++++++++++++++++++++++++++++++++++++++++++++>++++++++++++++++++++>+++++++++++++++++++++++++++++++++++++++++++++++++++>++++++++++++++++++>++++>++++++++++++++++++>++++++++++++++++++>++++++++++++++++++>++++++++++++++++++>++++++++++++++++++>++++>++++++++++++++++++++>++++++++++++++++++++>++++++++++++++++++++>++++++++++++++++++++>++++>++++++++++++++++++>++++++++++++++++++>++++>++++++++++++++++++++>++++>++++++++++++++++++>++++++++++++++++++>++++++++++++++++++>++++>++++++++++++++++++++>++++++++++++++++++++>++++++++++++++++++++>++++++++++++++++++++>++++++++++++++++++++>++++><[<]<<+++++++[->+++++++++>++++++<<]>-....>+>[[-<.<<+>>>]<[->+<]<.[->+<]>>>]<[->>+>+>+<<<<]<[->+>+<<]>-->>>++>+++[->++>++>+<<<]>>>[-<<<+>>>]<+<-[<]>.>>>>>.[<]>.[>]<.[<]>..>>.......>>>.<<.<<.>.........<.>......<<..[>]<.<<<<<.>>.>....<<<.>.<.>>>>..<<.<<<.>>>>.<<<<..>>.<...[>]<.[<]>.>>>>>.<<.<<<..>>.<...>.<<.[>]<.[<]>.>>>>.>.<<.<<.>.<<.[>]<.<<<<<...[>]<.[<]>....>>>>>.[<]>.[>]<.<<<<<.>>>>.<<.>.<<<.>>>>>.  

Final state

  • Memory: our data and some extra chars
  • Cursor: somewhere after data (according to the code we executed)
  • Input: unchanged
  • Output : the other code