Examples
Programs from the language repository, each
shown with the output it prints. They are run by the current
lbd every time the site is built, so they always work.
-
Hello world
The smallest program: print a line.
hello_world.lbd -
Math demos
Fibonacci, factorial, gcd and primes, with recursion and local
letloops.math_demos.lbd -
Conditional branching
Booleans are built in, and
ifonly evaluates the branch it picks.conditional_branching.lbd -
List
Lists are immutable values: every operation returns a new list.
list.lbd -
Shapes
Constants and small functions with type annotations.
shapes.lbd -
Church pairs
Pairs built from nothing but lambdas, from the standard library.
pair.lbd -
A standard library
A small standard library written in Lambda Discipline itself.
std.lbd -
Advent of Code 2024, day 1, part 1
Parse two columns of numbers, sort them and sum the distances.
part_01.lbd -
Advent of Code 2024, day 1, part 2
Count matches between two lists, using the standard library.
part_02.lbd -
Lazy evaluation
Arguments are only evaluated when needed.
lazy_evaluation.lbd -
Let expressions
letis recursive and generalized.let_expressions.lbd -
Mutual recursion
Two definitions that call each other, inferred together.
mutual_recursion.lbd -
Curried functions
Every function takes one argument, so partial application is free.
curried_functions.lbd -
Annotated higher-order functions
Higher-order functions whose annotations name type variables.
complex_typing.lbd -
Polymorphic functions
One
composeused at several types.polymorphic_functions.lbd -
Strings
Joining, splitting, parsing and escaping strings.
strings.lbd -
Deep recursion
A hundred thousand nested calls, and a loop of a million in constant space.
deep_recursion.lbd