Skip to content

Commit 770ff44

Browse files
authored
Merge pull request #13 from calcit-lang/nested-updates
Nested updates
2 parents e2f4e7c + bb632d2 commit 770ff44

File tree

4 files changed

+1058
-639
lines changed

4 files changed

+1058
-639
lines changed

README.md

Lines changed: 40 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,46 @@ It's not tested yet, but is trying to trade memory and performance with caching.
3333

3434
### Diff Operations
3535

36-
| tag | meaning |
37-
| ----------- | ---------------------- |
38-
| :assoc | `assoc-in` |
39-
| :dissoc | `dissoc-in` |
40-
| :vec-append | append items to vector |
41-
| :vec-drop | pop items from vector |
42-
| :set-splice | remove and add to set |
43-
| :map-splice | remove and add to map |
36+
| tag | meaning |
37+
| ----------- | ------------------------------ |
38+
| :update | update field with single op |
39+
| :update-in | update path with single op |
40+
| :pick | update field with multiple ops |
41+
| :pick-in | update path with multiple ops |
42+
| :assoc | set in field |
43+
| :replace | replace |
44+
| :vec-append | append items to vector |
45+
| :vec-drop | pop items from vector |
46+
| :set-splice | remove and add to set |
47+
| :map-splice | remove and add to map |
48+
49+
```cirru
50+
tag-match change
51+
(:replace data) data
52+
(:vec-append data)
53+
patch-vector-append base data
54+
(:vec-drop data)
55+
patch-vector-drop base data
56+
(:assoc k data)
57+
patch-map-set base k data
58+
(:set-splice removed added)
59+
patch-set base removed added
60+
(:map-splice removed added)
61+
patch-map base removed added
62+
(:update k c0)
63+
update base k $ fn (o)
64+
patch-one o c0
65+
(:update-in ks c0)
66+
update-in base ks $ fn (o)
67+
patch-one o c0
68+
(:pick k changes)
69+
update base k $ fn (o)
70+
patch-twig o changes
71+
(:pick-in ks changes)
72+
update-in base ks $ fn (o)
73+
patch-twig o changes
74+
_ $ do (eprintln "|Unkown op:" change) base
75+
```
4476

4577
For vectors, data is supposed to be manipulated from the tail.
4678
Items in the new vector are mapped to its old ones by index.

0 commit comments

Comments
 (0)