The following examples will give you a taste of how to get things done in Enchilada.
The map lambda takes a sequence holding a map pair, and another sequence to apply the map pair on:
{m={s=s m *}}
Here is an example that negates all the numbers in a number list:
10 ~ [-] {m={s=s m *}} 1 @
The fold lambda takes a sequence that holds a fold pair, a base and another sequence to apply the fold on:
{f={b={s=[b] s f * | {e==e}}}}
Here is an example that sums all the numbers in a number list:
10 ~ 0 [+] {f={b={s=[b] s f * |}}} {e==e}
The easiest way to define libraries is to store a multimap in the global slot and then to use this multimap to replace symbols with expressions via the replace operator.
Subsequently, the global slot can be re-used (across multiple sessions) to build a library of named lambdas. Here is a example of how to create and use a simple math library:
=[add=+;mul=*;div=/;min=&;max=|]
After the global slot is set, the library can be used via the global slot reference ():
[1 2 add 4 mul 5 mod] () ^ == [1 2 + 4 * 5 mod]
Additionally, the global slot can be set to a new multimap, adding the missing mod function:
=() [mod=%] <
The previous mathematical expression will now be correctly compiled:
[1 2 add 4 mul 5 mod] () ^ == [1 2 + 4 * 5 %]
Libraries can be referenced by other (computer) nodes after the global slot has been persisted on a filesystem or in a DHT.
TODO
TODO
TODO