Jump to content

Category:Lambdatalk: Difference between revisions

no edit summary
No edit summary
No edit summary
Line 16:
-> 2+3 is equal to 5
 
• 3) Functions are created with '''lambda''' and named with '''def'''.
 
{def foo
Line 37:
1) a word is any character except spaces and curly braces, and is not evaluated out of curly braces,
 
2) an abstraction is a '''special form''' (called a function) selecting words (called arguments) in an expression (called the body), and is evaluated to a word referencing an anonymous function added to a single dictionary, initially empty,
 
3) an application is a '''simple form''' calling an abstraction to replace selected words by some other words (called values), and is evaluated to words.
 
The evaluation stops when all expressions have been replaced by words.
 
In order to make code easier to write and read, we adddefine a second special form:
 
{def word expression}
Line 58:
{def HI Hello World}
-> HI
 
HI, I just say {HI}
-> HI, I just say Hello World
Line 71 ⟶ 70:
{def GOOD_DAY {lambda {o a} oh happy day!}}
-> GOOD_DAY
 
{GOOD_DAY oOOOo aaAaa}
-> oOOOoh haaAaappy daaAaay!
Line 90 ⟶ 88:
{def CAR {lambda {:z} {:z {lambda {:x :y} :x}}}} -> CAR
{def CDR {lambda {:z} {:z {lambda {:x :y} :y}}}} -> CDR
 
{CAR {CONS Hello World}} -> Hello
{CAR {CONS Hello World}} -> World
Line 111 ⟶ 108:
The eval_lambdas() 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,
 
- 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,
Line 117 ⟶ 114:
- 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.
 
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 iterations and recursions. But,For as a ''dwarf standing on their shoulders''instance, {lambda talk} can take benefit from the extraordinary power of modern '''web browsers'''. Without ''re-inventing the wheel'' {lambda talk} simply adds a coherent and unique language on existing tools. computing factorials:
 
{CHURCH
{{lambda {:n}
{{lambda {:g :n} {:g :g :n}}
{lambda {:g :n}
{{{ISZERO :n}
{CONS {lambda {:g :n} ONE}
{lambda {:g :n}
{MUL :n {:g :g {PRED :n}}}}
}} :g :n}} :n}} FIVE}}
-> 120
 
==B) {lambda talk} full==
 
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.
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, the DOM, HTML tags and CSS rules and more, pairs, lists, arrays, ... and more specific to the wiki context.
 
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, the DOM, HTML tags and CSS rules, the DOM and more, pairs, lists, arrays, ... and moresome other specific to the wiki context.
 
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.
Cookies help us deliver our services. By using our services, you agree to our use of cookies.