Skip to content

FayCarsons/Lank

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Lank

Working title. WIP Clojure dialect intended for functional computational music composition. Currently a toy lisp with some vaguely Rust-y / ML inspired syntax. Development is currently paused but there are plans for a major refactor including a bytecode interpreter and finishing sequencing portion of standard library as soon as I get the time.

Rough at the moment, many things are likely to change, but a lot of the standard library is present. Some bugs to work out and decisions to re-evaluate.

Running requires Rust to be installed. git clone the repo and then cargo run to open a REPL CLI. Add the flag --release to optimize.

Examples

Syntax largely follows Clojure syntax:

(def a 1) => None
(defn inc [n] (+ n 1)) => None
(inc a) => 2

(defn factorial [n]
  (let [one-to-n (map inc 
                      (range (inc n))]
    (reduce * one-to-n))

With some differences:

// Comments are C-like
/* Multiline comment goes like
  this */

(def greeting "hi") => None

// Display vs print
(display greeting) => "hi" None

// Format in stdlib vs JVM interop, using syntax similar to Rust's `format!` macro
(format "{} {}" greeting "lank") => "hi lank"

// Very simple matching instead of `cond` etc
(match greeting
  "foo" -> true
  "bar" -> false
  s -> (bytes s)) => [104 105]

// None instead of nil
(when (== greeting "bonk!")
  true) => None

// `prepend` and `append` as opposed to `cons` and `conj` 
(def l [1 2 3]) => None
(prepend l 0) => [0 1 2 3]
(append l 4) => [1 2 3 4]

// Truthiness mirrors Clojure
[(some? 0) (some? []) (some? true)]  => [true true true]
[(some? None) (some? false)]  => [false false]

About

WIP Clojure dialect for music composition

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages