# Core Constructs lambdagent maps 11 agent constructs to Lambda calculus: | # | Lambda Calculus | DSL | Example | |---|---|---|---| | 1 | λx.body | `Lam(name, prompt)` | `Lam("writer", "Write clearly.")` | | 2 | (f x) | `agent(input)` | `agent("hello")` | | 3 | λx.g(f(x)) | `f >> g` | `extract >> analyze >> report` | | 4 | IF c t e | `If(cond, then_, else_)` | `If(lambda x: len(x)>100, long_handler, short_handler)` | | 5 | Y combinator | `Loop(body, cond, N)` | `Loop(step, lambda r,s: "DONE" in r, 10)` | | 6 | PAIR | `Pair(f, g)` | `Pair(researcher, critic)` | | 7 | FST / SND | `Fst() / Snd()` | `Fst()(("a","b")) # → "a"` | | 8 | Oracle | `Tool(name, fn)` | `Tool("calc", lambda x: eval(x))` | | 9 | CASE | `Route(cls, routes)` | `Route(classifier, {"code": coder, "math": solver})` | | 10 | {x:T\|P(x)} | `Guard(agent, P)` | `Guard(writer, lambda x: len(x)>200, retry=2)` | | 11 | Γ'=Γ∪s | `Memory(agent, store)` | `Memory(assistant, {"user": "Alice"})` | All constructs are subclasses of `Term` and support: - `>>` for composition - `|` for parallel execution - `()` for application (β-reduction)