Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| records [2021/10/26 17:07] – created sprowell | records [2021/10/28 18:27] (current) – Added grammar for simple rules and binds. sprowell | ||
|---|---|---|---|
| Line 3: | Line 3: | ||
| ===== Records ===== | ===== Records ===== | ||
| - | A //record// is an unordered collection of terms, where each term has an associated unique name. The following is an example. | + | A //record// is an unordered collection of terms, where each term has an associated unique name given by an untyped symbol. The following is an example. |
| - | < | + | < |
| { name => " | { name => " | ||
| birthday => { year => 1996, month => 3, day => 21 } } | birthday => { year => 1996, month => 3, day => 21 } } | ||
| Line 11: | Line 11: | ||
| Note that the terms in a record can be anything, including other records. | Note that the terms in a record can be anything, including other records. | ||
| + | |||
| + | < | ||
| + | record = " | ||
| + | </ | ||
| ===== Binds ===== | ===== Binds ===== | ||
| - | A //bind// associates variables by name with terms. | + | A //bind// associates variables by name with terms. |
| - | < | + | < |
| { $x => 21, $y => ( $z -> 21 ) } | { $x => 21, $y => ( $z -> 21 ) } | ||
| </ | </ | ||
| Line 24: | Line 28: | ||
| When a binding is applied to a term, free instances of the named variables are replaced with the associated term. | When a binding is applied to a term, free instances of the named variables are replaced with the associated term. | ||
| - | < | + | < |
| { $x => 21 } . iadd(17, $x) | { $x => 21 } . iadd(17, $x) | ||
| --> iadd(17, 21) | --> iadd(17, 21) | ||
| Line 30: | Line 34: | ||
| </ | </ | ||
| - | Again, this works for free variables, only. Lambda variables are no rewritten. | + | Again, this works for free variables, only. Lambda variables, which are not free, are not rewritten. |
| - | < | + | < |
| { $x => 21 } . ( $x -> 17 ) | { $x => 21 } . ( $x -> 17 ) | ||
| --> $x -> 17 | --> $x -> 17 | ||
| + | </ | ||
| + | |||
| + | < | ||
| + | bind = " | ||
| </ | </ | ||
| ===== Simple Rules ===== | ===== Simple Rules ===== | ||
| - | A //simple rule// | + | A //simple rule// is a sequence of lambda expressions, |
| - | < | + | < |
| { %($x: INTEGER, $y: INTEGER) -> iadd($x, | { %($x: INTEGER, $y: INTEGER) -> iadd($x, | ||
| %($x: FLOAT, $y: FLOAT) -> fadd($x, | %($x: FLOAT, $y: FLOAT) -> fadd($x, | ||
| Line 50: | Line 58: | ||
| When a simple rule is applied to a term, each of the lambdas is tried, in order. | When a simple rule is applied to a term, each of the lambdas is tried, in order. | ||
| - | < | + | < |
| { %($x: INTEGER, $y: INTEGER) -> iadd($x, | { %($x: INTEGER, $y: INTEGER) -> iadd($x, | ||
| %($x: FLOAT, $y: FLOAT) -> fadd($x, | %($x: FLOAT, $y: FLOAT) -> fadd($x, | ||
| Line 58: | Line 66: | ||
| </ | </ | ||
| - | ===== Special Form ===== | + | < |
| + | simple_rule | ||
| + | </ | ||