Deadfih
Jump to navigation
Jump to search
- Not to be confused with Deadfish.
Deadfih is an esolang based on Deadfish.
Instructions
It's just Deadfish without the S instruction, so:
instruction | meaning |
---|---|
i | Increment |
d | Decrement |
o | Output as character |
It follows the deadfish acc==-1 || acc==256
tradition.
Examples
print 'A':
iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiio
See also
Implementation
The following interpreter has been implemented in the programming language Common Lisp:
(defun interpret-Deadfih () "Launches the Deadfih interpreter, which perpetually queries the standard input for a line of code, evaluates the same, and repeats the process, returning in the case of an abortion no value." (let ((accumulator 0)) (declare (type integer accumulator)) (loop do (format T "~&>> ") (finish-output) (let ((user-input (read-line))) (declare (type string user-input)) (loop for token of-type character across user-input do (case token (#\i (incf accumulator 1)) (#\d (decf accumulator 1)) (#\o (format T "~c" (code-char accumulator))) (otherwise (format T "~%"))) (when (or (= accumulator -1) (= accumulator 256)) (setf accumulator 0)))))) (values))
Python:
def interpret(code): code = list code x = 0 for char in code: if char == 'i': x += 1 elif char == 'd': x -= 1 elif char == 'o': print(x)