Training dataset for fine-tuning LLMs to generate Hemlock code. 120 working, tested examples covering algorithms, systems programming, cross-language translation, and practical programs.
Benchmark results for hemlang/Hemlock2-Coder-7B (Q8_0, zero-shot):
| Level | Score |
|---|---|
| L1 Syntax & Basics | 44.4% |
| L2 Stdlib Usage | 60.0% |
| L3 Algorithms | 28.6% |
| L4 Systems Programming | 42.9% |
| L5 Translation | 0.0% |
| L6 Debugging | 60.0% |
| Overall | 38.9% |
L3, L4, and especially L5 need more training data. This dataset targets those gaps.
Sorting (8)
- Bubble sort
- Insertion sort
- Selection sort
- Merge sort (recursive)
- Quicksort
- Heap sort
- Counting sort
- Radix sort
Search (4)
- Binary search (iterative)
- Binary search (recursive)
- Linear search with sentinel
- Interpolation search
Trees (7)
- BST insert/search/delete
- BST in-order traversal
- BST level-order traversal (BFS)
- AVL tree with rotations
- Trie insert/search/prefix
- Expression tree evaluation
- Lowest common ancestor
Graphs (9)
- Dijkstra's shortest path
- BFS shortest path (unweighted)
- DFS traversal
- Topological sort
- Floyd-Warshall
- Prim's MST
- Kruskal's MST (union-find)
- Cycle detection (directed)
- A* pathfinding
Dynamic Programming (8)
- Longest common subsequence
- Longest increasing subsequence
- Knapsack (0/1)
- Edit distance (Levenshtein)
- Coin change
- Matrix chain multiplication
- Fibonacci (memoized)
- Rod cutting
Classic Data Structures (8)
- Two sum (hashmap)
- Linked list reversal
- Stack-based bracket matching
- Queue with two stacks
- Priority queue (min-heap)
- LRU cache
- Ring buffer
- String permutations
Memory (8)
- Manual linked list (alloc/free)
- Dynamic array (realloc pattern)
- Arena allocator
- Memory pool / slab allocator
- Double-ended queue with pointers
- Buffer builder (growing buffer)
- Struct-of-arrays with ptr arithmetic
- Reference counting
Concurrency (10)
- Producer-consumer (channels)
- Fan-out/fan-in worker pool
- Pipeline (multi-stage channels)
- Barrier synchronization
- Lock-free atomic counter
- Parallel merge sort
- Dining philosophers
- Thread-safe queue
- Map-reduce pattern
- Async file processing
Defer Patterns (4)
- File open/defer close
- alloc/defer free
- Nested resource cleanup
- Error cleanup with defer
From Python (10)
- Word frequency counter
- List comprehension → map/filter
- Context manager → defer
- Generator → closure/iterator
- Class → define + functions
- Decorator → higher-order fn
- CSV processing
- JSON parsing and transformation
- Regex find-all
- argparse → @stdlib/args
From JavaScript (10)
- Promise.all → spawn + join
- async/await → spawn/await
- Array.map/filter/reduce chain
- EventEmitter → channels
- Fetch API → http_get/http_post
- setTimeout → spawn + sleep
- Object spread/destructuring
- Template literals → template strings
- try/catch/finally
- Map/Set → HashMap/Set
From C (10)
- malloc/free → alloc/free
- struct + functions → define + fn
- Linked list with pointers
- File I/O (fopen/fread/fwrite)
- String manipulation
- Bit manipulation
- Signal handling
- Fork/exec → spawn
- pthread → spawn/join
- Socket server (basic TCP)
From Go (6)
- Goroutine fan-out → spawn + channels
- sync.WaitGroup → join
- select → channel recv patterns
- defer → defer
- error handling → try/catch
- Mutex → atomic ops
From Rust (6)
- Vec operations → array methods
- Option/Result → null + try/catch
- Ownership/borrowing → manual alloc/free
- Arc/Mutex → atomic + spawn
- Iterator chains → map/filter/reduce
- Pattern matching → match
- HTTP server (hello world)
- CLI tool with arg parsing
- File watcher
- Simple chat (TCP + channels)
- JSON config loader
- Log file parser
- Markdown to HTML (basic)
- Base64 encoder/decoder from scratch
- Simple REPL
- Unit test runner
- SQLite CRUD app
- URL shortener (in-memory)
Requires Hemlock 2.0.0+ on PATH.
# Test all examples
find hemlock -name '*.hml' | while read f; do
echo -n "$f: "
timeout 10 hemlock "$f" > /dev/null 2>&1 && echo "PASS" || echo "FAIL"
doneSame as Hemlock.