Unicorn is a simple language like BF. It uses 1 character but is just as powerful as it's compiler's language.
Last active
January 29, 2016 05:40
-
-
Save vihanb/8ecf1ff3c65a70dd13dd to your computer and use it in GitHub Desktop.
Unicorn, the language!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: "π€" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 ` `; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment