Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

eddmann/santa-lang

Open more actions menu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

71 Commits
71 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

santa-lang

santa-lang

A functional, C-like programming language designed for solving Advent of Code puzzles. Read the docs →

Features

  • First-class functions and closures with tail-call optimization
  • Functional pipelines (|>) and composition (>>)
  • Pattern matching with match expressions and guards
  • Lazy sequences and infinite ranges (1..)
  • Persistent immutable data structures
  • Placeholder syntax (_ + 1) for concise lambdas
  • Built-in memoization support
  • Rich built-in function library for AoC puzzles
  • AoC runner with automatic input fetching

Examples

Language Features

// Pattern matching
let fibonacci = |n| match n {
  0 { 0 }
  1 { 1 }
  n { fibonacci(n - 1) + fibonacci(n - 2) }
};

// Pipelines and functional operations
let result = 1..10
  |> filter(|n| n % 2 == 0)
  |> map(_ * 2)
  |> sum;

// Lazy infinite sequences
let evens = 0.. |> filter(|n| n % 2 == 0) |> take(5);

Advent of Code Solution

A complete solution for AoC 2015 Day 1:

input: read("aoc://2015/1")

part_one: {
  input |> fold(0) |floor, direction| {
    if direction == "(" { floor + 1 } else { floor - 1 }
  }
}

part_two: {
  zip(1.., input) |> fold(0) |floor, [index, direction]| {
    let next_floor = if direction == "(" { floor + 1 } else { floor - 1 };
    if next_floor < 0 { break index } else { next_floor }
  }
}

test: {
  input: "()())"
  part_one: -1
  part_two: 5
}

Reindeer

The language has multiple implementations (affectionately called "reindeer") exploring different execution models and technologies.

Codename Type Language
Comet Tree-walking interpreter Rust
Blitzen Bytecode VM Rust
Dasher LLVM native compiler Rust
Donner JVM bytecode compiler Kotlin
Vixen Embedded bytecode VM C
Prancer Tree-walking interpreter TypeScript

Tooling

Name Description Language
Workbench Desktop IDE Tauri/React
Tinsel Code formatter Zig

About

santa-lang specification and documentation - a functional programming language for Advent of Code

Topics

Resources

Stars

Watchers

Forks

Used by

Contributors

Languages

Morty Proxy This is a proxified and sanitized view of the page, visit original site.