Skip to content

2233admin/pulselang

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PulseLang

An APL-inspired functional array language written in Rust.

PulseLang is a concise, composable notation where arrays are the fundamental data type and operations implicitly map over collections. Inspired by APL, K/Q, and BQN — designed for time-series analytics, signal processing, and vector computation.

Quick Start

cargo build --release

# REPL
./target/release/pulselang

# Run a script
./target/release/pulselang examples/demo.pulse

# Benchmarks
cargo run --release --bin benchmark

Language Overview

Right-to-Left Evaluation

  ) 2 * 3 + 4
14

Vectors & Array Operations

  ) 1 2 3 + 10 20 30
11 22 33

  ) sum 1 2 3 4 5
15

  ) avg 10 20 30
20

Pipelines

  ) 1 2 3 4 5 |> deltas |> sum
4

Lambdas

  ) double: {x * 2}
  ) double[21]
42

  ) {[a;b] a + b}[3; 4]
7

Time-Series Primitives

  ) mavg[3; 1.0 2.0 3.0 4.0 5.0]
1 1.5 2 3 4

  ) ema[0.5; 1.0 2.0 3.0 4.0]
1 1.5 2.25 3.125

  ) deltas 10 13 17 22
10 3 4 5

Data Structures

  ) `a`b`c ! 1 2 3
`a:1 `b:2 `c:3

  ) x: 10 20 30 40 50
  ) x[0]
10
  ) x[-1]
50
  ) x[10010b]
10 40

Type System

Type Literal Description
int 42 64-bit signed integer
float 3.14 64-bit IEEE 754 float
bool 1b, true Boolean
sym `host Interned symbol
str "hello" UTF-8 string
ts 2024.01.15D14:30:00 Nanosecond timestamp
dur 5m, 1h, 30s Time duration

Operators

Arithmetic (element-wise)

+ - * % (divide) ^ (power) mod

Comparison (return bool vectors)

= <> < > <= >= ~ (match) like

Aggregation

sum avg min max count first last med dev var

Scans (running aggregates)

sums avgs mins maxs prds

Structural

til rev asc desc distinct group flip raze , (join) # (take) _ (drop) ? (find) in

Time-Series

deltas ratios prev next mavg msum ema wma xbar cor fills ffill bfill

Iterators

f' x (each) f/ x (over/reduce) f\ x (scan) f': x (each-prior)

Benchmarks

Run cargo run --release --bin benchmark to see performance across vector arithmetic, aggregations, scans, sorting, filtering, lambdas, and pipelines.

Origin

Extracted from PulseDB as a standalone language interpreter.

License

MIT

About

PulseLang — an APL-inspired functional array language written in Rust

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages