Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Examples Index

Han ships with a growing set of example programs in the examples/ directory of the repository. Each file is a self-contained .hgl program you can run with:

hgl interpret examples/<name>.hgl

Tutorial Series (교육)

A 10-step progressive tutorial covering the language from basics to integration:

Classic Algorithms

FileTopic
피보나치.hglFibonacci (recursive)
피보나치_SOV.hglFibonacci with SOV 동안 form
팩토리얼.hglFactorial
소수판별.hglPrime number check
정렬알고리즘.hglSorting algorithms
합계.hglSum 1..n
구구단.hglMultiplication table
별찍기.hglStar pattern printing
짝홀.hglEven/odd checker

Strings, Arrays, Structures

FileTopic
문자열보간.hglString interpolation
단어세기.hglWord counter
배열연산.hglArray operations
구조체메서드.hglStruct methods
패턴매칭.hglPattern matching
범위반복.hglRange iteration
클로저고차.hglHigher-order closures
할일목록.hglTodo list with structs
한글연산자.hglKorean logical operators

I/O and Systems

FileTopic
파일처리.hglFile read/write
에러처리.hgl시도/처리 error handling
정규식.hglRegex
JSON처리.hglJSON parsing and generation
HTTP_API.hglHTTP GET/POST
시스템정보.hglSystem / environment info
온도변환.hglTemperature conversion

Mini Apps

FileTopic
계산기.hglString calculator
가위바위보.hglRock-paper-scissors
어텐션.hglAttention mechanism demo
안녕.hglHello world

Sample: Factorial

함수 팩토리얼(n: 정수) -> 정수 {
    만약 n <= 1 이면 {
        반환 1
    }
    반환 n * 팩토리얼(n - 1)
}

함수 main() {
    출력(팩토리얼(10))
}

main()

Output: 3628800

Sample: Sum 1 to 100

함수 합계(n: 정수) -> 정수 {
    변수 합 = 0
    반복 변수 i = 1; i <= n; i += 1 {
        합 += i
    }
    반환 합
}

함수 main() {
    출력(합계(100))
}

main()

Output: 5050