We are currently working on new rules for what content should and shouldn't be allowed on this website, and are looking for feedback! See Esolang:2026 topicality proposal to view and give feedback on the current draft.

Псевдо-растяжение

From Esolang
Jump to navigation Jump to search

Псевдо-растяжение is a stack-based esoteric language with only four commands.

Commands

Command Description
0-9 push digit to stack
& pop top of stack
! print top of stack
@ halt

Examples

XKCD Random Number

4!

Implementations

An implementation in Python:

import sys

program = " " # Program goes here

stack = []

for i in program:

    if i.isnumeric():
        stack.append(i)
    elif i == "&" and len(stack) > 0:
        stack.pop()
    elif i == "!" and len(stack) > 0:
        print(stack[-1], end="")
    elif i == "@":
        sys.exit(0)

Lua implementation:

s = {}
repeat
    c = io.read(1)
     if not c then break end
     b = c:byte()
    if b > 47 and b < 58 then
        s[#s+1] = b - 48
    elseif c == '&' then
        s[#s] = nil
    elseif c == '!' then
        print(s[#s])
    end
until c == '@'

Lua golf:

s={}io.read"*a":gsub("@.+",""):gsub("[0-9&!]",load's[#s+1]=tonumber(...)if...=="&"then print(s[#s])end s[#s]=...=="&"and s[#s]or nil')