+
1
|
list
|
skin
|
login
|
editor
α-wwwiki
::
alphawiki_2.0
user:none
(2881 bytes)
_h1 alphawiki++ _p See you soon in {b alphawiki++} ! _p In the next days, a better engine for alphawiki's syntax will replace the current one. It benefitted a lot from my long travel in the Lisp World. For instance : _ul the 4 obfuscated [{b [[define]], [[lambda]], [[defun]] and alpha}] operators are reduced to the standard operators, [{b lambda and def}], using the Lambdatalk syntax, ie : {b °°{def add {lambda {:a :b} {+ :a :b}}} and as usual : {add 1 2} -> 3°°} _ul the {b [[input]]} operator becomes the unique (and more secure) door to the JavaScript code, _ul some operator's behaviors have been improved, more later, _ul speed has been improved (upto 2x in the long 1.2Mo page [[julesverne]]) _ul and bugs have been fixed. {hr} _p For instance, let us compare the previous code generating postits (cf page [[postit]]) to the new one and see how the code became more straightforward. _h4 1) code in the current alphawiki _p The code is written in Javascript : {pre °° {define postits (n) •• function fac (n) { return (n< 1)? 1 : n*fac(n-1); } function postit (x) { var css = "font:bold "+(x/3)+"em courier new;" + "background:rgb("+(25*x)+","+(250-25*x)+",0);" + "transform:rotate("+x+"deg);" + "-webkit-transform:rotate("+x+"deg);" + "border:1px solid white;" + "text-align:center;"; return '{div {@ style="'+css+'"}'+x+'! = '+fac(x)+'}'; } var res = ''; for (var i=0; i< n; i++) res += postit(i); return res; ••} {postits 10} °°} _p OK, {i things could be better} ! So let's see the code in alphawiki++. _h4 2) code in the next alphawiki++ _p The code is written in Lambdatalk : {pre °° {def fac {lambda {:n} {if {< :n 1} then 1 else {* :n {fac {- :n 1}}}}}} {def postits {lambda {:n} {div {@ style=" font:bold {/ :n 3}em georgia; background:rgb({* :n 25},{- 250 {* :n 25}},0); border:1px solid white; text-align:center; -webkit-transform:rotate(:ndeg); -moz-transform:rotate(:ndeg); transform:rotate(:ndeg); "}:n! = {fac :n} } } } {map postits {serie 0 10}} °°} _p Note that Lambdatalk knows recursive functions and that the CSS rules are written as they are in a standard HTML code. The postits function's core is straightforward : {pre °° {def postits {lambda {:n} {div {@ style=" some CSS rules "} :n! = {fac :n} } } } °°} _p The postits function's parameter, {b :n}, is now easily inserted in the CSS expressions and can be embedded in S-expressions, ie {b °° rgb({* :n 25},{- 250 {* :n 25}},0)°°}. And this is a preview of the result : {center {show {@ src="data/alphawiki_postit.jpg" height="300" width="800" title="the syntax of the 'def' operator will be straightforward !"}}} _p So, if you like it, see you soon in {b alphawiki++} !