diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2025-05-21 14:25:45 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2025-05-21 14:25:45 -0400 |
| commit | 6d15697edce2217a2bbc82def26262d18dac6373 (patch) | |
| tree | 9c00c6211a10dffc99c3a6566ee3fb03f4d6849d /api | |
| parent | e4d7ab31057868739f48638cadc5d70aa4929fae (diff) | |
Added Set infix operations, as well as Table.with_fallback() and fixed
some bugs with update assignment.
Diffstat (limited to 'api')
| -rw-r--r-- | api/sets.yaml | 23 | ||||
| -rw-r--r-- | api/tables.yaml | 25 |
2 files changed, 47 insertions, 1 deletions
diff --git a/api/sets.yaml b/api/sets.yaml index 6bf0d8cc..08111932 100644 --- a/api/sets.yaml +++ b/api/sets.yaml @@ -229,4 +229,25 @@ Set.without: example: | >> |1, 2|.without(|2, 3|) = |1| - + +Table.xor: + short: symmetric difference + description: > + Return set with the elements in one, but not both of the arguments. This is + also known as the symmetric difference or disjunctive union. + return: + type: '|T|' + description: > + A set with the symmetric difference of the arguments. + args: + a: + type: '|T|' + description: > + The first set. + b: + type: '|T|' + description: > + The second set. + example: | + >> |1, 2, 3|.xor(|2, 3, 4|) + = |1, 4| diff --git a/api/tables.yaml b/api/tables.yaml index 6a58e818..f3b648da 100644 --- a/api/tables.yaml +++ b/api/tables.yaml @@ -160,3 +160,28 @@ Table.set: >> t = {"A"=1, "B"=2, "C"=3} +Table.with_fallback: + short: return a table with a new fallback + description: > + Return a copy of a table with a different fallback table. + return: + type: '{K=V}' + description: > + The original table with a different fallback. + args: + t: + type: '{K=V}' + description: > + The table whose fallback will be replaced. + fallback: + type: '{K=V}?' + description: > + The new fallback table value. + example: | + t := {"A"=1; fallback={"B"=2}} + t2 = t.with_fallback({"B"=3"}) + >> t2["B"] + = 3? + t3 = t.with_fallback(none) + >> t2["B"] + = none |
