Skip to content

jzwood/portcullis

Repository files navigation

Portcullis

A minimalist / functional / dataflow programming language.

fib.po

portcullis source code for Fibonacci function

compiles to fib.js

// signature: (Num -> Num)
export function fib(n) {
  return (
    _lte_(n)(1.0) ? 1.0 : _plus_(fib(_minus_(n)(1.0)))(fib(_minus_(n)(2.0)))
  );
}

compiles to fib.py

# signature: (Num -> Num)
def fib(n):
  return (1.0 if _lte_(n)(1.0) else _plus_(fib(_minus_(n)(1.0)))(fib(_minus_(n)(2.0))))

compiles to fib.lua

-- signature: (Num -> Num)
function fib(n)
  return (_lte_(n)(1.0) > 0 and 1.0 or _plus_(fib(_minus_(n)(1.0)))(fib(_minus_(n)(2.0))))
end

fizzbuzz.po

portcullis source code for Fizzbuzz algorithm

Deno 1.22.0
exit using ctrl+d or close()
> fizzbuzz(20)
[
   1,  2, -1,  4, -2, -1,  7,
   8, -1, -2, 11, -1, 13, 14,
  -3, 16, 17, -1, 19, -2
]

About

I wrote the compiler for Portcullis purely for my own education and amusement. Painfully specific goals guided the development of this project and account for both the language features I chose to include as well as omit.

Some of these goals include

More