Category:Lambdatalk: Difference between revisions

m
→‎{lambda talk} full: adding a new link
No edit summary
m (→‎{lambda talk} full: adding a new link)
 
(17 intermediate revisions by 2 users not shown)
Line 1:
{{language|Lamdatalk}}
 
 
The {lambda way} project is a web application built on two engines:
Line 7 ⟶ 8:
2) {lambda talk}, a purely functional language unifying authoring, styling and scripting in a single and coherent s-expression based syntax.
 
==A) {lambda talk} in a few words==
 
1) Expressions are written in a prefix notation using curly braces.
Line 16 ⟶ 17:
-> 2+3 is equal to 5
 
3) Functions are created with '''lambda''' and named with '''def'''.
 
{def foo
Line 25 ⟶ 26:
-> 2+3 is equal to 5
 
==B) more about {lambda talk}==
 
{lambda talk} is freely inspired by the '''λ-calculus'''. At the lowest level a {lambda talk} expression is exclusively made of words, abstractions and applications:
 
===structure & evaluation===
Line 49 ⟶ 50:
{def word expression}
 
allowing to create constants added to the dictionary and to give names to anonymous functions.
 
What can be done with so little?
 
===Examples===
 
Out of curly braces words are not evaluated.:
 
Hello World
-> Hello World
 
Sequences of words can be given a name.:
Out of curly braces words are not evaluated.
 
{def HI Hello World}
Line 65 ⟶ 68:
-> HI, I just say Hello World
 
Abstractions can be defined and immediately called:
Sequences of words can be given a name.
 
{{lambda {o :a :b} oh:b happy day!:a} oOOOoHello aaAAaaWorld}
-> World Hello
-> oOOOoh haaAAaappy daaAAaay!
 
The abstraction {lambda {:a :b} :b :a} is definedfirst andevaluated immediatelyto called.a Theword abstraction(a isreference firstto a function added evaluatedinto a dictionary), the application gets the awaited values oOOOoHello and aaAAaaWorld, calls the abstraction which makes the substitution and returns the result, oOOOohWorld haaAAaappy daaAAaay!Hello. Abstractions can be given a name and then called easily several times:
 
Abstractions can be given a name and then called easily several times:
{def GOOD_DAY {lambda {o a} oh happy day!}}
 
-> GOOD_DAY
{def GOOD_DAYswap {lambda {o :a :b} oh:b happy day!:a}}
{GOOD_DAY oOOOo aaAaa}
-> swap
-> oOOOoh haaAaappy daaAaay!
{GOOD_DAYswap Hello World}
-> ♠hWorld h♥ppy d♥y!Hello
{GOOD_DAY oOOOoJames aaAaaBond}
-> Bond James
 
Most of the time expressions are nested. The expression below returns the first word of Hello World:
Line 93 ⟶ 98:
{def CDR {lambda {:z} {:z {lambda {:x :y} :y}}}} -> CDR
{CAR {CONS Hello World}} -> Hello
{CARCDR {CONS Hello World}} -> World
 
===about the implementation===
Line 108 ⟶ 113:
};
 
'''1) eval_forms()''': Using a single '''regular expression''' the eval_forms() function loops over the code string, skips the words out of curly braces, matches nested forms {first rest} from inside out, and replaces them by words. The repeated substitutions inside the code string overcomes limitations of regular language. It's a kind of Turing machine.
 
The'''2) eval_lambdas()''': this function uses arguments as '''regular expressions''' to successively replace occurrences found in the function's body by the given values. Lambdas have the following properties:
 
- lambdas are '''first class functions''', they can be called as functions' arguments and returned from functions,
Line 116 ⟶ 121:
- lambdas are pure black boxes, they '''don't create closures''' and are context free, inner lambdas don't see outer functions' arguments, there are no lexical scoping, no free variables,
 
- lambdas accept de facto '''partial function application''': called with a number of values lesser than its arity, a lambda memorizes the given values and returns a new lambda waiting for the rest.missing ones,
 
- lambdas are '''variadic''': called with a number of values greater than its arity, a lambda feeds the extra values in the last argument.
 
'''Note:''': This is what Ward Cunningham wrote about such an iconoclastic implementation: ''« I was surprised that the technique worked so well in so many cases. I knew that regex are highly optimized and the cpus themselves optimize sequential access to memory which the regex must have at its core. [..] Yes, this has at its heart the repeated application of a text transformation. The fact that it is repeated application of the same transformation makes it exceptional. [..] Repeated application of Regular Expressions can perform Touring Complete computations. This works because the needed "state" is in the partially evaluated text itself. »'' All is said!
 
===and?===
 
Upon these foundations, after '''Alonzo Church''', we could define the set of natural numbers [ZERO, ONE, TWO, ...] and their associate operators, [SUCC, ADD, MUL, POWER, PRED, ...] allowing to build '''iterationsiterative''' and ''recursions'recursive''' processes. For instance, computing factorials:
 
{CHURCH
Line 133 ⟶ 142:
-> 120
 
==B) {lambda talk} full==
 
ButIn fact, {lambda talk} can taketakes benefit from the extraordinary power of modern '''web browsers''' and, without ''re-inventinging the wheel'', {lambda talk} simply adds a coherent and unique language on existing tools.
 
In its complete state, {lambda talk} comes with a more complete set of special forms, ['''lambda''', '''def''', if, let, quote, macro, require, script, style], and a dictionary containing about 200 primitivesprimitive functions built on the Javascript Math objectObject, HTML tags and, CSS rules, SVG, the DOM and more, pairs, lists, arrays, light-show, spreadsheet, splines, turtle graphics, big numbers, ... and some other specific to the wiki context. Example:
 
{def ! {lambda {:a :b}
{if {< :b 2}
then :a
else {! {* :a :b} {- :b 1}}}}}
-> !
{! 1 6}
-> 720
 
What for? Well, you could compute the famous Euler's number:
But {lambda talk} can take benefit from the extraordinary power of modern '''web browsers''' and, without ''re-inventinging the wheel'', {lambda talk} simply adds a coherent and unique language on existing tools.
 
{def euler {lambda {:n}
In its complete state, {lambda talk} comes with a more complete set of special forms, ['''lambda''', '''def''', if, let, quote, macro, require, script, style], and a dictionary containing about 200 primitives built on Javascript Math object, HTML tags and CSS rules, the DOM and more, pairs, lists, arrays, ... and some other specific to the wiki context.
{+ {map {lambda {:n} {/ 1 {! 1 :n}}} {serie 0 :n}}}}}
-> euler
{euler 17}
-> 2.7182818284590455
 
Web design is not forgotten and examples can be seen in the workshop's website. Thanks to the language's unicity, authors, web-designers and coders can share their experiences to build rich web pages.
The {lambda way} project adds on browsers a thin overlay, {lambda tank}, proposing a small ''Interactive Development Environment'' without any external dependencies and thereby easy to download (50kb) and install on any web account provider running PHP. From any web browser, on any system, complex and dynamic web pages can be created, enriched, structured and tested in real time on the web.
 
The {lambda way} project adds on browsers a thin overlay, {lambda tank}, proposinggiving to {lambda talk} a small ''Interactive Development Environment'' without any external dependencies and thereby easy to download (50kb) and install on any web account provider running PHP. From any web browser, on any system, complex and dynamic web pages can be created, enriched, structured and tested in real time on the web.
A full presentation of {lambda talk} can be seen in:
 
A full presentation of the {lambda way} project can be seen in this version: http://lambdaway.free.fr/lambdaspeech followed by this last one under construction: http://lambdaway.free.fr/lambdawalks
- http://lambdaway.free.fr/
- http://lambdaway.free.fr/workshop/?view=about
- http://lambdaway.free.fr/workshop/?view=oxford_slides
- and several other pages of the workshop.
 
Your opinion is welcome. Alain Marty