Katahdin

1 program Added 2026-02-26T10:00:00Z Agent: claude-codeModel: claude-sonnet-4-6WebSearch: enabled Evidence Report issue View issues
Aliases: —
Provenance: commit de9f626b7c · authored 2026-02-26T14:33:56+01:00 · agent claude-code · model claude-sonnet-4-6

Sources mentioning this language

1 source · not in taxonomy (canonical name didn't match any upstream)
LLM (this repo) · 1

Related languages

Kamin (0.31)Kuin (0.23)Kalyn (0.21)Klein (0.21)Myrddin (0.19)

Programs collected by LLM agents experimental · unverified

Gathered by LLM agents during the experiment that started this catalogue. They are not verified: the agent names an origin, but a program can be altered or invented — an audit found one attributed to a file that does not exist, in a syntax the language does not have. The catalogue's goal is the languages themselves, grounded in sources (PLDB, Wikipedia, Rosetta Code, …), with real archived programs; these examples may be dropped.

Factorial with Custom Operator Syntax

Provenance: commit de9f626b7c · authored 2026-02-26T14:33:56+01:00 · agent claude-code · model claude-sonnet-4-6 · WebSearch enabled
code.kat · added: 2026-02-26T10:00:00Z
/*
    Factorial is normally implemented as a function.
*/

function factorial(n)
{
    if (n == 0)
        return 1;
    else
        return n * factorial(n - 1);
}

print "Using the function:";
print "    2! = ", factorial(2);
print "    5! = ", factorial(5);
print "    14! = ", factorial(14);

/*
    In Katahdin we can implement it as an operator, even though there is no
    existing operator to overload, and the name is already in use for
    the not operator.
    
    Inheriting from UnaryExpression means that we have the same precedence
    as other unary operators. We could also inherit from Expression and set
    the precedence ourselves.
    
    We inherit from Expression or one of its subclasses so that our new syntax
    can fit in anywhere an Expression is expected.
*/

class FactorialExpression : UnaryExpression
{
    pattern
    {
        option leftRecursive;
        
        a:Expression "!"
    }
    
    method Get()
    {
        /*
            The operator is implemented in terms of the existing syntax.
        */
        
        return factorial(this.a.Get...());
    }
}

/*
    Immediately after defining the new syntax, we can use it, even within the
    same file.
*/

print "Using the syntax:";
print "    2! = ", 2!;
print "    5! = ", 5!;
print "    14! = ", 14!;

/*
    The syntax is on the same level as any built in syntax and can be used
    anywhere any other operator can.
*/

print "    (4! / 2)! = ", (4! / 2)!;

a = [3, 2, 3, 4, 7, 2, 8, 7, 3];
print "    a[3!]! = ", a[3!]!;

Contribute — propose a file extension

Tell us where to find evidence about Katahdin (mapped to pl/katahdin). A reference URL is required; at least one of extension or program code must be provided too. A maintainer reviews each submission via a draft PR before anything lands.
Optional: attach a program from that URL
If the reference URL points at a single source file you'd like to add as an example program, paste it below. The workflow will write it under languages/Katahdin/programs/<sha>/. Keep under ~200 lines.
(or open the pre-filled issue directly)
← kasaya kate →