Testing Microtalk

We try a few examples of microtalk, a subset of lambdatalk, a dialect of lisp.

Here is an html only experiment with a few lines of javascript and a download from Alain Marti. page

We write expressions in a prefix notation using brackets. Away from brackets words are just words.

the answer is {+ 2 3}

We have at our disposal all of the functions in lib.

{lib}

We create functions with lambda and name them with def.

{pre {def castel.interpol {lambda {:p0 :p1 :t} {cons {+ {* {car :p0} {- 1 :t}} {* {car :p1} :t}} {+ {* {cdr :p0} {- 1 :t}} {* {cdr :p1} :t}}}}} {def castel.sub {lambda {:l :t} {if {equal? {cdr :l} nil} then nil else {cons {castel.interpol {car :l} {car {cdr :l}} :t} {castel.sub {cdr :l} :t}}}}} {def castel.point {lambda {:l :t} {if {equal? {cdr :l} nil} then {car :l} else {castel.point {castel.sub :l :t} :t}}}} {def castel.build {lambda {:p :t0 :t1 :dt} {list.new {map {{lambda {:q} {castel.point :q}} :p} {serie :t0 :t1 :dt}}}}} {def castel.split {def last {lambda {:l} {if {equal? {cdr :l} nil} then {car :l} else {last {cdr :l}}}}} {def split_g {lambda {:l :g :t} {if {equal? :l nil} then :g else {cons {car :l} {split_g {castel.sub :l :t} :g :t}} }}} {def split_d {lambda {:l :d :t} {if {equal? :l nil} then :d else {cons {last :l} {split_d {castel.sub :l :t} :d :t}} }}} {lambda {:l :t0 :t1} {split_d {split_g :l nil :t1} nil :t0} }} {def svg.frame {lambda {:w :h} svg {@ width=":wpx" height=":hpx" style="border:1px solid #888; box-shadow:0 0 8px;"}}} {def svg.dot {lambda {:p} {circle {@ cx="{car :p}" cy="{cdr :p}" r="5" stroke="black" stroke-width="3" fill="rgba(255,0,0,0.5)"}} }} {def svg.poly {def svg.list2xy {lambda {:l} {if {equal? :l nil} then else {car {car :l}} {cdr {car :l}} {svg.list2xy {cdr :l}}}}} {lambda {:p :c :w} {polyline {@ points="{svg.list2xy :p}" stroke=":c" fill="transparent" stroke-width=":w" }}}} {def p0 {cons 80 20}} = {cons.disp {p0}} {def p1 {cons 280 100}} = {cons.disp {p1}} {def p2 {cons 60 150}} = {cons.disp {p2}} {def p3 {cons 200 190}} = {cons.disp {p3}} {def p4 {cons 280 30}} = {cons.disp {p4}} {def p5 {cons 160 150}} = {cons.disp {p5}} {def L6 {list.new {p0} {p1} {p2} {p3} {p4} {p5}}} {def sL6 {castel.split {L6} 0.25 0.75}} } {{svg.frame 350 200} {svg.dot {p0}} {svg.dot {p1}} {svg.dot {p2}} {svg.dot {p3}} {svg.dot {p4}} {svg.dot {p5}} {svg.poly {L6} grey 1} {svg.poly {castel.build {L6} -0.025 1.05 0.02} black 2} {svg.poly {sL6} grey 1} {svg.poly {castel.build {sL6} 0 1 0.05} red 4} }

Microtalk could be integrated into federated wiki a number of different ways. Since its roots are as a whole document markup language it feels a little confined in the input/output format we use here.

See About Method Plugin for the style we mimic.

We've given little thought to how we manage scope. The wiki convention is to look up and to the left in the lineup for definitions. For now the plugin holds definitions and updates them whenever rendered.

{fac 20}

wiki-plugin-microtalk