Translate a Glypho program
Pyth, 37 35 34 bytes
The code contains unprintable characters, so here is the xxd
hexdump:
0000000: 5663 7a34 7040 2e22 216f d78c 40bf d4f0 Vcz4p@."!o..@...
0000010: 38d6 7dfe 7312 3ff8 ea22 6958 4e7b 4e55 8.}.s.?.."iXN{NU
0000020: 5433 T3
Here's a printable version at 36 bytes:
Vcz4p@"ni >\\1 <d+[o*e-!]"iXN{NUT3
Try it online. Test suite.
Explanation
Vcz4p@."…"iXN{NUT3 implicit: z = input
z input
c 4 split to 4-character blocks
V loop over that in N
X replace...
N in current part
{N unique chars in current part, in order
UT with numbers 0-9
i 3 interpret as base 3
@ take that item of
."…" string "ni >\\1 <d+[o*e-!]"
p and print without newline
CJam, 42 39 35 bytes
Saved 4 bytes borrowing user81655's idea of using base 3 instead of base 4.
l4/{__&f#3b"ni >\1 <d+[o*e-!]"=}%
Run all test cases.
There's gotta be a better way to compress the lookup table of commands...
JavaScript (ES6), 97
For each block of 4 characters, I substitute each symbol with its position in the block, getting a base 4 number. For instance 'aabc' -> '0023'
. The possibile numbers are in the range 0..0123, that is 0..27 in decimal. I use the number as an index to find the right instruction character from a 28 chars string.
s=>s.replace(/.{4}/g,s=>'n..i....>.\\1....<d.+[o.*e-!]'[[...s].map(c=>n=n*4+s.indexOf(c),n=0),n])
Test
F=s=>s.replace(/.{4}/g,s=>'n..i....>.\\1....<d.+[o.*e-!]'[[...s].map(c=>n=n*4+s.indexOf(c),n=0),n])
function test() { O.textContent=F(I.value) }
test();
#I { width:90% }
<input id=I value="nananananananana batman!" oninput="test()">
<br><span id=O></span>