esolang

Aheui

A Befunge written in Korean. Each Hangul syllable is one command, and its vowel decides where the cursor goes next.

Puzzlet Chung, 2005 · Turing complete: yes · ●●○ moderate · esolangs.org

Tested with 4 known programs · Hello World on Try It Online: identical · Test method

Run it

Expected: 7

The idea

Puzzlet Chung designed Aheui (아희) in 2005, the first esolang for Hangul, the Korean alphabet. It borrows its grid and moving cursor from Befunge. The new part is how a command is spelled.

Read the story

A Hangul syllable is built from up to three letters: a first consonant, a vowel and a final consonant. Unicode stores all 11,172 syllables in that order, so the three parts fall out of the code point by simple arithmetic. Aheui gives each part a job. The first consonant is the instruction. The vowel is the direction. The final consonant is the argument, such as which storage to use. 밤 is ㅂ+ㅏ+ㅁ: push 4 (the strokes in ㅁ), then move right.

Instead of one stack there are 26 stacks and a queue. There is no command to change the code, so the grid is pure program.

The machine

A grid of syllables; anything that is not a full syllable is a comment. The cursor starts at the top left moving down, and wraps at the edges. Each step, the vowel sets the momentum, the consonant acts, and the cursor moves.

VowelMomentum
ㅏ ㅓ ㅗ ㅜRight, left, up, down, one cell
ㅑ ㅕ ㅛ ㅠThe same, two cells
ㅡ ㅣ ㅢReflect vertical, horizontal, both
First consonantDoes
ㅇNothing
ㅎEnd
ㄷ ㄸ ㅌ ㄴ ㄹAdd, multiply, subtract, divide, modulo (second by top)
ㅁPop; with final ㅇ print it as a number, with ㅎ as a character
ㅂPush: with final ㅇ an input number, with ㅎ an input character, else the final's stroke count
ㅃ ㅍDuplicate, swap
ㅅSelect the storage named by the final
ㅆMove the top value to the storage named by the final
ㅈPush 1 if second ≥ top, else 0
ㅊPop; if it is 0, reverse

The final ㅇ names the queue; the others name stacks. A command that finds too few values reverses the cursor instead.

Example

An A+B program.

An A+B program. The cursor starts on the top left but every vowel is ㅏ, so it moves right. 방 (ㅂ with final ㅇ) reads a number, twice. 다 adds them. 망 (ㅁ with final ㅇ) prints the sum, and 희 ends.

Patterns it teaches

Try this

  1. Print the number 8 by pushing 밤 (4) twice and adding.
  2. Read a number and print it twice.
  3. Hard: print the numbers 1 to 5 with a loop that uses ㅊ to leave.

Further

CJK

Queue-based

Write your own in Run Convert a program from Aheui

Implementation

JavaScript interpreter, source and command line

A JavaScript interpreter, used in the browser and on the command line. Id: aheui.

Command line

shib run aheui -e '방방다망희' --input '3 4'
shib manual aheui

Source

Module
langs/stack/ports.js
Interpreter
langs/stack/aheui.js

Docs: Kernel instructions · The .shib format · Command line · Adding a language

Source esolangs.org (CC0) · Edit on esolangs.org