A+B: Difference between revisions

Content added Content deleted
(lambdatalk alternative)
Line 2,971: Line 2,971:
=={{header|Lambdatalk}}==
=={{header|Lambdatalk}}==
<lang scheme>
<lang scheme>
Lambdatalk works in a wiki, lambdatank.
1) writing this lambdatalk code
{center
Enter any sequence of numbers in the field below
{div
{@ contenteditable
style="box-shadow:0 0 8px #000;"
ondblclick="addme(this.innerHTML)"}}
and double-clic to display their sum.
}


1) Open the wiki frame-editor and define a contenteditable box
and this javascript code


{def box
{script
{pre
var addme = function(x) {
{@ contenteditable
alert( LAMBDATALK.eval_forms(
style="box-shadow:0 0 8px #000; padding:5px;"
"The sum of " + x + " is equal to {+ " + x + "}") )
ondblclick="this.innerHTML=LAMBDATALK.eval_forms(this.innerHTML)"
};
}
}}}
-> blockedit


2) create this box
displays an editable field in the wiki page
_______________________________________________________________


{box}
Enter any sequence of numbers in the editable field below
[ 12 34 56 ]
and double-clic on it to display its sum.
_______________________________________________________________


and close the wiki frame-editor. The wiki-page displays a shadowed box,
The result is displayed in an alert box
(here simulated as a space between square brackets)
"The sum of 12 34 56 is equal to 102"

[ ]

3) Enter any valid lambdatalk expression, for instance

1+2+3 is equal to {+ 1 2 3}

then double-click. The expression is evaluated and the box displays

[ 1+2+3 is equal to 6 ]

Several boxes can be created in the wiki page
with any valid lambdatalk expressions.
</lang>
</lang>