# 靈符

## Commands

The language operates on a tape of cells, each containing an integer.

The program consists of a series of Chinese characters, each representing a different operation.

Instructions:

1. 移 (Yí) - Move the data pointer to the next cell to the right.
2. 靈 (Líng) - Move the data pointer to the next cell to the left.
3. 增 (Zēng) - Increment the value at the current cell by 1.
4. 減 (Jiǎn) - Decrement the value at the current cell by 1.
5. 若 (Ruò) - If the value at the current cell is 0, jump forward to the character after the matching 則 (Zé).
6. 則 (Zé) - Go back to the matching 若 (Ruò) if the value at the current cell is not zero.
7. 輸 (Shū) - Output the ASCII character represented by the value at the current cell.
8. 讀 (Dú) - Input a character and store its ASCII value at the current cell.

(This is just a Brainfuck deriative!)

## Example(Written by myself)

### Hello, World!

```增增增增增增增增增增增若移增增增增增增移增增增增增

```

```讀若輸讀則
```

## Implementation

```import sys
def lingfu(code):
s=[]
matches={}
tape=[0]*1000000
for i,j in enumerate(code):
if j=='若':
s.append(i)
if j=='則':
m=s.pop()
matches[m]=i
matches[i]=m
cp=0
p=0
while cp<len(code):
if code[cp]=='增':
tape[p]=(tape[p]+1)%256
if code[cp]=='減':
tape[p]=(tape[p]-1)%256
if code[cp]=='輸':
tape[p]=(ord(c) if c else 0)%256
if code[cp]=='讀':
print(chr(tape[p]),end='')
if code[cp]=='靈':
p-=1
if code[cp]=='移':
p+=1
if code[cp]=='若':
if not tape[p]:
cp=matches[cp]
if code[cp]=='則':
if tape[p]:
cp=matches[cp]
cp+=1