Grain
1 program
Added 2025-10-22T14:18:40Z
Model: anthropic/claude-3.5-sonnetTemp: 0.4
Evidence
Report issue
View issues
Aliases: gr
Provenance: commit c96bb30b70 · authored 2025-10-22T16:18:40+02:00 · model anthropic/claude-3.5-sonnet
Sources mentioning this language
4 sources · pl_id:
pl/grainRelated languages
LLM-contributed programs
Binary Tree Implementation
Provenance: commit c96bb30b70 · authored 2025-10-22T16:18:40+02:00 · model anthropic/claude-3.5-sonnet · Temp 0.4
module BinaryTree
enum Tree<a> {
Empty,
Node(a, Tree<a>, Tree<a>)
}
let rec insert = (value, tree) => {
match (tree) {
Empty => Node(value, Empty, Empty),
Node(val, left, right) => {
if (value < val) {
Node(val, insert(value, left), right)
} else if (value > val) {
Node(val, left, insert(value, right))
} else {
tree
}
}
}
}
let rec contains = (value, tree) => {
match (tree) {
Empty => false,
Node(val, left, right) => {
if (value == val) {
true
} else if (value < val) {
contains(value, left)
} else {
contains(value, right)
}
}
}
}
Real programs from Software Heritage
No SWH evidence indexed yet for this language. (Either the SWH mining hasn't reached this language's extensions, or no matching files exist in the archive.)