Aheui
- Note: This article contains special characters.
Aheui (아희 in Korean language) is the first esoteric programming language ever to be designed for Hangul, the Korean alphabet, designed by User:Puzzlet Chung.
Many of the Aheui's concept is derived from Befunge-93, except the fact that it has no instruction for self-modifying, and that it has 26 stacks and one queue.
Execution
A program is a grid of characters(it doesn't need to be a rectangle). If the cursor arrives at a boundary of the grid, it wraps around to the other side of the grid but maintains the same momentum. Complete Hangul characters(they are commands) are made of three parts:
- initial consonant
- vowel
- final consonant
The initial consonants are:
ㄱ,ㄲ,ㄴ,ㄷ,ㄸ,ㄹ,ㅁ,ㅂ,ㅃ,ㅅ,ㅆ,ㅇ,ㅈ,ㅉ,ㅊ,ㅋ,ㅌ,ㅍ,ㅎ
The vowels are:
ㅏ,ㅐ,ㅑ,ㅒ,ㅓ,ㅔ,ㅕ,ㅖ,ㅗ,ㅘ,ㅙ,ㅚ,ㅛ,ㅜ,ㅝ,ㅞ,ㅟ,ㅠ,ㅡ,ㅢ,ㅣ
And the final consonants are:
(no consonant),ㄱ,ㄲ,ㄳ,ㄴ,ㄵ,ㄶ,ㄷ,ㄹ,ㄺ,ㄻ,ㄼ,ㄽ,ㄾ, ㄿ,ㅀ,ㅁ,ㅂ,ㅄ,ㅅ,ㅆ,ㅇ,ㅈ,ㅊ,ㅋ,ㅌ,ㅍ,ㅎ
The examples of complete Hangul characters: 한, 가, 응. Incomplete Hangul(ㄱ, ㅇ, ㅑ, ㅟ) and non-Hangul characters are treated as comments. The commands are executed as follows:
- Process the consonants(they specify the actual instruction). Update the momentum if required by the consonants.
- Set the momentum of the cursor based on the current momentum and the vowel(it changes the momentum).
- Move the cursor based on the current momentum.
Instruction pointer starts at the top left corner([0;0]) and is moving down(it has a [1;0] momentum).
Instructions
Vowels
In Aheui, the following vowels have no use (although they can still be included in valid programs):
ㅐ,ㅒ,ㅖ,ㅘ,ㅙ,ㅚ,ㅝ,ㅞ,ㅟ
Other vowels change momentum as follows:
Vowel | Momentum |
---|---|
ㅏ (A)
|
[0;1](right) |
ㅓ (Ö)
|
[0;-1](left) |
ㅗ (O)
|
[-1;0](up) |
ㅜ (U)
|
[1;0](down) |
ㅑ (ʲA)
|
[0;2] |
ㅕ (ʲÖ)
|
[0;-2] |
ㅛ (ʲO)
|
[-2;0] |
ㅠ (ʲU)
|
[2;0] |
ㅡ (Ǝ)
|
current momentum reflected vertically. |
ㅣ (I)
|
current momentum reflected horizontally. |
ㅢ (ʲI)
|
current momentum reflected both vertically and horizontally. |
Consonants
When reading a character, the initial consonant specifies the action to be performed. If the action takes in some parameter, the final consonant (or lack thereof) is used as the value for the parameter. If there is less values than needed in the current storage, instructions only reverse the momentum. The functionality of the consonants can be broken down into the following groups:
The "ㅇ" group:
Consonant | Description |
---|---|
ㅇ (ʔ-ŋ)
|
Nop |
ㅎ (h-h)
|
Terminate the program.
(If the current storage is non-empty, the program pops from the storage and returns the result. If the current storage is empty, the program returns 0.) |
The final consonant is not used.
The "ㄷ" group (arithmetic operations):
Consonant | Description |
---|---|
ㄷ (d-d)
|
Pops two values from the current storage and pushes their sum. |
ㄸ (d²-d²)
|
Pops two values from the current storage and pushes their product |
ㄴ (n-n)
|
Pops two values from the current storage,
performs integer division and pushes the result. |
ㅌ (t-t)
|
Pops two values from the current storage,
subtracts the 1st value from the 2nd and pushes the result. |
ㄹ (r-l)
|
Pops two values from the current storage,
performs modulo(second%first) and pushes the result. |
All of the "ㄷ" group ingnores the final consonant.
The "ㅁ" group(storage manipulation):
Consonant | Description |
---|---|
ㅁ (m-m)
|
Pops the value from the current storage.
If the final consonant is "ㅇ": Print it as an integer. If it is "ㅎ": Print as the unicode(UTF-8) character. Otherwise do nothing with the value. |
ㅂ (b-b)
|
If the final consonant is "ㅇ":
Pushes an integer from the input to the current storage. If it is "ㅎ": Pushes the value of the unicode(UTF-8) character from the input to the current storage. Otherwise, pushes the number of strokes required to draw the consonant to the current storage: ㄱ:2 ㄴ:2 ㄷ:3 ㄹ:5 ㅁ:4 ㅂ:4 ㅅ:2 ㅈ:3 ㅊ:4 ㅋ:3 ㅌ:4 ㅍ:4 ㄲ:4 ㄳ:4 ㄵ:5 ㄶ:5 ㄺ:7 ㄻ:9 ㄼ:9 ㄽ:7 ㄾ:9 ㄿ:9 ㅀ:8 ㅄ:6 ㅆ:4 (no consonant):0 |
ㅃ (b²-b²)
|
DUP |
ㅍ (p-p)
|
SWAP |
The "ㅅ" group:
Consonant | Description |
---|---|
ㅅ (s-s)
|
Current storage is changed by the final consonants. |
ㅆ (s²-s²)
|
The current storage is popped and the returned value is pushed into the storage mapped to by the final consonant. |
ㅈ (ĵ-ĵ)
|
Pops 2 values from the current storage. If the latter value is greater than or equal to the former value(first≥second), pushes 1 to the current storage, pushes 0 otherwise. |
ㅊ (ĉ-ĉ)
|
Pops a value from current storage. If the value is zero, reverses the current momentum. Else, do nothing. |
The final consonants are mapped to the storages as follows:
The stacks: none, ㄱ, ㄴ, ㄷ, ㄹ, ㅁ, ㅂ, ㅇ, ㅅ, ㅈ, ㅊ, ㅋ, ㅌ, ㅍ, ㅎ, ㄲ, ㄳ, ㄵ, ㄶ, ㄺ, ㄻ, ㄼ, ㄽ, ㄾ, ㄿ, ㅀ, ㅄ, or ㅆ. The queue: ㅇ. The extension protocol: ㅎ.
Computational class
Unlike Befunge-93, Aheui does not specify limit of codespace; however, Aheui does not use codespace as a storage. Aheui has additional stacks instead. Since a pair of unbounded stacks can be used to simulate the unbounded tape of a Turing machine, it is likely that Aheui is Turing-complete. Partial proof.
Examples
Hello world
This code prints "Hello, world!":
밤밣따빠밣밟따뿌 빠맣파빨받밤뚜뭏 돋밬탕빠맣붏두붇 볻뫃박발뚷투뭏붖 뫃도뫃희멓뭏뭏붘 뫃봌토범더벌뿌뚜 뽑뽀멓멓더벓뻐뚠 뽀덩벐멓뻐덕더벅
Truth-machine
뱡먕뺘뼈처망희
A+B Problem
방방다망희
Times table generator
Not available
Project Euler
Problem 1
This code is for Project Euler's Problem 1. It may still need reduction.
바싹밣발발발따따뚜 루벌루벋뻐터너벌벌 우뽀처빠쑥사빠아초희멍 처아아오삭도오어샥여오여
Problem 2
This program may need reduction.
바싹바발발나빠뱐주뱔뗘땨뼈뺘뗘뺘변따뗘 삭망희ㅇ루벅포뼈차 싹샥뼈댜챠사빠쑥 ㅇㅇㅇㅇ쌰석쇼뎌
Problem 5
발발나싹발밤따뿌망희 뿌석뻐서썬뻐석처속 사싹샥도루발나툐 빠쌱션속쳐볼서
Problem 6
바싹밤발발따뚜 투너벌벌뻐뻐뻐 따따싹삭두빠초 뭉뱔벌냐셔토삭 희
Special characters
This article contains special characters that fall in the Hangul Syllable area of the Unicode charset. You need an appropriate font for the browser to display it correctly. Because Aheui is a two-dimensional language, using a monospacial Hangul font is highly recommended. (e.g. UnDotum)
External resources
- Specification of Aheui
- Interpreter in JavaScript
- Implementations in various languages
- AheuiAheui, Implementation in Aheui
- AVIS, Visual Aheui editor & interpreter
- AheuiChem Visual Aheui editor