Category:Lambdatalk: Difference between revisions
Content added Content deleted
No edit summary |
No edit summary |
||
Line 11: | Line 11: | ||
2) {lambda talk}, a purely functional language unifying authoring, styling and scripting in a single and coherent s-expression based syntax. |
2) {lambda talk}, a purely functional language unifying authoring, styling and scripting in a single and coherent s-expression based syntax. |
||
=={lambda talk} in few words== |
=={lambda talk} in a few words== |
||
1) Expressions are written in a prefix notation using curly braces. |
1) Expressions are written in a prefix notation using curly braces. |
||
Line 20: | Line 20: | ||
-> 2+3 is equal to 5 |
-> 2+3 is equal to 5 |
||
3) Functions are created with '''lambda''' and named with '''def'''. |
|||
{def foo |
{def foo |
||
Line 31: | Line 31: | ||
==more about {lambda talk}== |
==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: |
{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=== |
===structure & evaluation=== |
||
Line 53: | Line 53: | ||
{def word expression} |
{def word expression} |
||
allowing to create constants added to the dictionary and give names to anonymous functions. |
allowing to create constants added to the dictionary and to give names to anonymous functions. |
||
What can be done with so little? |
What can be done with so little? |
||
Line 101: | Line 101: | ||
{def CDR {lambda {:z} {:z {lambda {:x :y} :y}}}} -> CDR |
{def CDR {lambda {:z} {:z {lambda {:x :y} :y}}}} -> CDR |
||
{CAR {CONS Hello World}} -> Hello |
{CAR {CONS Hello World}} -> Hello |
||
{ |
{CDR {CONS Hello World}} -> World |
||
===about the implementation=== |
===about the implementation=== |
||
Line 116: | Line 116: | ||
}; |
}; |
||
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. |
'''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. |
||
'''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, |
- lambdas are '''first class functions''', they can be called as functions' arguments and returned from functions, |
||
Line 125: | Line 125: | ||
- 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. |
- 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. |
||
'''Note:''': This is what Ward Cunningham wrote about that: ''« 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?=== |
===and?=== |