Skip to content

Instantly share code, notes, and snippets.

@vihanb
Last active January 29, 2016 05:40
Show Gist options
  • Save vihanb/8ecf1ff3c65a70dd13dd to your computer and use it in GitHub Desktop.
Save vihanb/8ecf1ff3c65a70dd13dd to your computer and use it in GitHub Desktop.
Unicorn, the language!
32: " "
33: "🐐"
34: "πŸ¦„"
35: "✨"
36: "🌈"
37: "1"
38: "2"
39: "3"
40: "4"
41: "5"
42: "6"
43: "7"
44: "8"
45: "9"
46: "0"
47: "🌀"
function Unicorn(code) {
var chars = code.split(" ").map(function(ch) {
var emoji = (ch.match(/🌀|🌈|✨|πŸ¦„|🐐/g)||[])[0];
return /[\d\(\)\[\]]/.test(ch) ? ch : ch.charCodeAt() < 5000 ? "" : emoji === "✨" ? String.fromCharCode(ch.length * 6) : emoji === "🌈" ? String.fromCharCode(ch.length * 2) : emoji === "🌀" ? String.fromCharCode((ch.length / 2) * 3) : emoji === "🐐" ? String.fromCharCode(ch.length / 2) : emoji === "πŸ¦„" ? String.fromCharCode(ch.length) : ""
}).join("");
return chars;
}
function GenerateUnicorn(JavaScriptCode) {
return JavaScriptCode.split``.map(function(l) {
return /[\d\(\)\[\]]/.test(l) ? l : l.charCodeAt() % 6 === 0 ? "✨".repeat(l.charCodeAt() / 6) : l.charCodeAt() % 4 === 0 ? "🌈".repeat(l.charCodeAt()/4) : l.charCodeAt() % 3 === 0 ? "🌀".repeat(l.charCodeAt() / 3) : l.charCodeAt() % 2 ? "🐐".repeat(l.charCodeAt() / 2) : "πŸ¦„".repeat(l.charCodeAt())
}).join ` `;
}

Unicorn

Unicorn is a simple language like BF. It uses 1 character but is just as powerful as it's compiler's language.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment