Revision e4f56c1f-fed8-4df1-9abe-6e33ca7e31c7 - Code Golf Stack Exchange

# [Trilangle](https://github.com/bbrk24/Trilangle), <s>14&nbsp;</s> 8 bytes

```
<>i,@##o
```

Try it on [the online interpreter](https://bbrk24.github.io/Trilangle/#%3C%3Ei%2C%40%23%23o)!

The interpreter loads this into a triangular grid and adds trailing `.`s as necessary. When expanded, this program becomes:

```
 <
 > i
 , @ #
# o . .
```

The IP starts on the north corner headed southwest.

[![][1]][1]

Starting on the red path, the interpreter hits the following instructions:

- `<`: Redirect the IP left, where it wraps around to the right side of the next row
- `i`: Read a single character from input
- `>`: Branch

When it hits the branch instruction, the IP changes direction depending on the sign of the character read. EOF is -1 and all other characters are positive, so it branches on EOF.

When it reads EOF, it continues on the green path, and quickly hits `@`, terminating the program. Otherwise, it continues on the blue path:

- `o`: Output a character
- `,`: Pop from the stack
- `#`: Skip the next instruction (twice)

After this, it reaches the `<`, where it merges with the red path.

The `,` instruction is necessary to keep memory bounded when fed an infinite input stream (e.g. when piping `yes` into it).


 [1]: https://i.sstatic.net/Iz9cn.png

AltStyle によって変換されたページ (->オリジナル) /