Tuesday, December 05, 2006


part1:
  When I wrote programs in APL, I found that many programs looks like it gives input parameter at the right side, maps it over functions and outputs it at the left side.
output < fun1 p1 < fun2 p2 < fun3 p3 < input
p - params

after that I wrote haskell and used the same style code, (.) helps to do it:
(filter (<16) . map (*2)) [1,2,3,4,5]
we can present it in lisp-style code:
(fun1 p1 (fun2 p2 (fun3 p3)))

if  define "expr1 ,expr2" to push the result of th expr2 into the end of expr2, we can rewrite the lisp code like:
fun1 p1, fun2, p2, fun3 p3

part2:
  Everybody knows that value is function in functional languages.
  we have 3 values: a b and c. what should expression "a b c" do? don't know, maybe it's smth like lisp - first value if a function, maybe b is infix function like (+).
we can only solve the expression if we know types of the values, so I decide to define special character "," to point function which we should run, so ",a b c" means run function a with parameters b and c.

part3:
  join part1 and part2, and join two meaning of the comma, so "," is "run and push to the prev fuction"  "fun1 p1 ,fun2 p2" is run function fun2 with parameter p2 and push the result as the last parameter to fun1 function with p1 parameter. looks like we move value over the stream, and its the main feature the of SPL (stream programming language).

I decided to do it static typing, but its a not simple task, because some functions can have different number of parameters (,list for example), I think I removed this function

,filter [,less 16] ,map [,mul 2] ,list 1 2 3 4 5

I hosted prototype of the language here:
http://code.google.com/p/inv/

mail-list: spl_dev@googlegroups.com
(http://groups.google.com/group/spl_dev)

$ runhugs e9.hs

test_ok: incr
test_ok: ,incr
test_ok: 1
test_ok: ,incr 1
test_ok: ,incr 1 2
test_ok: ,map
test_ok: ,list 1 2 3 4 5
test_ok: ,incr ,incr ,incr 3
test_ok: ,map incr,list 1 2 3 4 5
test_ok: ,sum 1 2
test_ok: [,sum 2]
test_ok: ,[,sum 2] 3
test_ok: ,[incr] 2
test_ok: [,incr,incr]
test_ok: ,[,incr,incr] 3
test_ok: ,map [,incr,incr],list 1 2 3 4 5
test_ok: ,map [,sum 10],list 1 2 3 4 5

all passed


To Be Continue

Labels: , , ,