sxpr.py
sxpr.py
Functions for working with s-expressions.
s-expressions are inspired from ELisp.
SatSxpr
Bases: Sxpr[Src, bool]
A subclass of Sxpr[--, bool].
Parameters:
Name | Type | Description | Default |
---|---|---|---|
op |
obj: |
required | |
terms |
obj: |
required |
Returns:
Type | Description |
---|---|
Computes |
Source code in normal_form/sxpr.py
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
|
__repr__()
Use for pretty-printing an S-expression.
Source code in normal_form/sxpr.py
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
|
Sxpr
dataclass
Bases: Generic[Src, Trgt]
Define generic S-expression.
Source code in normal_form/sxpr.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
|
reduce()
Use ft.reduce to evaluate the s-expression.
Example
(+, (1 2 3 4), 0) will evaluate to ((((0 + 1) + 2) + 3) + 4).
Source code in normal_form/sxpr.py
28 29 30 31 32 33 34 |
|
Last update:
September 11, 2022