(phixonline)--> with javascript_semantics integer id = 0, ipr = 1, ipc = 1 procedure step() if and_bits(id,1) == 0 then ipc += 1 - and_bits(id,2) else ipr += 1 - and_bits(id,2) end if end procedure procedure snusp(integer dlen, string s) sequence ds = repeat(0,dlen) -- data store integer dp = 1 -- data pointer -- remove leading '\n' from string if present s = trim_head(s,'\n') -- make 2 dimensional instruction store and set instruction pointers sequence cs = split(s,'\n') ipr = 1 ipc = 1 -- look for starting instruction for i=1 to length(cs) do ipc = find('$',cs[i]) if ipc then ipr = i exit end if end for id = 0 -- execute while ipr>=1 and ipr<=length(cs) and ipc>=1 and ipc<=length(cs[ipr]) do integer op = cs[ipr][ipc] switch op do case '>' : dp += 1 case '<' : dp -= 1 case '+' : ds[dp] += 1 case '-' : ds[dp] -= 1 case '.' : puts(1,ds[dp]) case ',' : ds[dp] = getc(0) case '/' : id = not_bits(id) case '\\': id = xor_bits(id,1) case '!' : step() case '?' : if ds[dp]=0 then step() end if end switch step() end while end procedure constant hw = """ /++++!/===========?\>++.>+.+++++++..+++\ \+++\ | /+>+++++++>/ /++++++++++<<.++>./ $+++/ | \+++++++++>\ \+++++.>.+++.-----\ \==-<<<<+>+++/ /=.>.+>.--------.-/""" snusp(5, hw)