Skip to content

Golfcart v0.1

Latest
Compare
Choose a tag to compare
@healeycodes healeycodes released this 14 Jul 14:02
· 14 commits to main since this release

This is the initial release of Golfcart! My toy programming language is feature complete.

The language syntax is fully implemented and complex programs can be run.

e.g. the Fibonacci sequence.

// Naive
t = time()
fib = n => if n == 0 {
    0
} else if n == 1 {
    1
} else {
    fib(n - 1) + fib(n - 2)
}
fib(20)
log("fib: " + str(time() - t))

// With memoization 
t = time()
cache = {"0": 0, "1": 1}
fib_memo = n => if cache[n] != nil {
    cache[n]
} else {
    cache[n] = fib_memo(n - 1) + fib_memo(n - 2)
}
fib_memo(20)
log("fib_memo: " + str(time() - t))

The test suite + example programs all run without error. But you shouldn't use this in production.