Projects

I am currently attempting to design a system involving:

  • abstract pattern matching with:
    • constraints
    • bindings
    • composition
    • other magic
  • state update accumulation
  • composable update batches
  • meta data
  • priority management
  • modules

These are the main features of a project idea I’ve had for a while, which has recently become rather more colourful.

I originally wanted to try to build a generic pattern matching system with a new type of regular expression for almost any data type: (lists, trees, graphs, …). Similar to clojure’s core.match.

Recently I’ve been having ideas about CSS: how terrible it is at it’s job, and how I would design a replacement.

It turns out that both of these projects have similar components and ideas have crossed between them; so much so that now the projects have merged into one!

This project touches on a few computing science areas that peek my interest: programming languages and semantics, logic programming, functional programming, and pattern matching.

I still have a lot to work out, but it should be interesting and fun :]

LastCalc

Today I discovered something called LastCalc. It’s very early stages, but it’s a kind of pattern matching, logic programming, functional programming system.

I’ve been experimenting with it for a few hours, you can fork my results here: http://www.lastcalc.com/z6S1svwW

To start a new sheet, just go to http://www.lastcalc.com/

The following is my declarations list so far:

map(Fn) = map(Fn)
map(Fn)([]) = []
map(Fn)([H...T]) = [Fn(H)...map(Fn)(T)]

reduce(Fn) = reduce(Fn)
reduce(Fn)([H...T]) = reduce(Fn)(H)(T)
reduce(Fn)(V)([]) = V
reduce(Fn)(V)([H...T]) = reduce(Fn)(Fn(V)(H))(T)

filter(Fn) = filter(Fn)
filter(Fn)([]) = []
filter(Fn)([H...T]) = if Fn(H) then [H...filter(Fn)(T)] else filter(Fn)(T)

nth(Coll) = nth(Coll)
nth([])(Index) = nil
nth(Coll)(-Index) = nil
nth([H...T])(Index) = if Index==0 then H else nth(T)(Index-1)

lookup(Map) = lookup(Map)
lookup({})(Key) = nil
lookup({K:V...T})(Key) = if K==Key then V else lookup(T)(Key)

element(Coll) = element(Coll)
element([])(Value) = nil
element([H...T])(Value) = if H==Value then H else element(T)(Value)
element({})(Value) = nil
element({K:V...T})(Value) = if V==Value then V else element(T)(Value)

head([H...T]) = H
tail([H...T]) = T

abs(A) = A
abs(-A) = A

floor(A) = int(A-0.5)

"Ratios, use as such" "1//4 + 3//4 = 1"
X//Y = X//Y
Op X//Y = Op (X/Y)
X//Y Op = (X/Y) Op

isSeq([Head...Tail]) = true
isSeq([]) = true
isSeq(Other) = false

isColl([Head...Tail]) = true
isColl([]) = true
isColl({Key:Value...Tail}) = true
isColl({}) = true
isColl(Other) = false

range(X)(Y) = if X<Y then [X...range(X+1)(Y)] else []
range(X) = range(0)(X)

step([]) = []
step([H...T]) = if T!=[] then [H,step(T)] else [H]

keys({}) = []
keys({K:V...T}) = [K...keys(T)]

vals({}) = []
vals({K:V...T}) = [V...vals(T)]