[ interpret everything to the next ] as a string+ push two values off the stack, add them and push the resultz push the current stack depth1 push one<r pop two values and execute register r if the original top-of-stack (1)is smaller] end of the string, will push the whole thing to the stacksr pop a value (the string above) and store it in register rz push the current stack depth again1 push 1<r pop two values and execute register r if the original top-of-stack (1)is smallerp print the current top-of-stack
### Implement some commands from dcregisters = {'r': None}stack = []def add():stack.append(stack.pop() + stack.pop())def z():stack.append(len(stack))def less(reg):if stack.pop() < stack.pop():registers[reg]()def store(reg):registers[reg] = stack.pop()def p():print stack[-1]
### Python version of the dc command above
# The equivalent to -f: read a file and push every line to the stackimport fileinputfor line in fileinput.input():stack.append(int(line.strip()))
def cmd():add()z()stack.append(1)less('r')
stack.append(cmd)store('r')z()stack.append(1)less('r')p()
% echo "1\n2\nnot a number" | raku -e "say [+] slurp.lines"Cannot convert string to number: base-10 number must begin with valid digits or '.' in '⏏not a number' (indicated by ⏏)in block <unit> at -e line 1