Skip to content

Commit 02248ce

Browse files
Technologicatclaude
andcommitted
List the in-place path updates in the same order as the functional ones
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent 8c5268b commit 02248ce

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

doc/features.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ The exception are the features marked **[M]**, which are primarily intended as a
6565
- [`fupdate_in_to`, `fupdate_in_with`](#fupdate_in_to-fupdate_in_with): functionally update one item deep inside nested containers.
6666
- [`view`: writable, sliceable view into a sequence](#view-writable-sliceable-view-into-a-sequence) with scalar broadcast on assignment.
6767
- [`mogrify`: update a mutable container in-place](#mogrify-update-a-mutable-container-in-place)
68-
- [`mogrify_in_with`, `mogrify_in_to`: update one item at a path, in-place](#mogrify_in_with-mogrify_in_to-update-one-item-at-a-path-in-place)
68+
- [`mogrify_in_to`, `mogrify_in_with`: update one item at a path, in-place](#mogrify_in_to-mogrify_in_with-update-one-item-at-a-path-in-place)
6969
- [`s`, `imathify`, `gmathify`, `slift1`, `slift2`: lazy mathematical sequences with infix arithmetic](#s-imathify-gmathify-slift1-slift2-lazy-mathematical-sequences-with-infix-arithmetic)
7070
- [`sym`, `gensym`, `Singleton`: symbols and singletons](#sym-gensym-Singleton-symbols-and-singletons)
7171

@@ -2483,7 +2483,7 @@ The path is an iterable of steps, outermost first. The containers along it may b
24832483
24842484
The input is never mutated. Every container along the path is shallow-copied if mutable, or rebuilt if immutable (named tuples, `frozendict`, frozen dataclasses, `cons`, and other immutable sequences), so the result shares everything off the path with the input. A step that names nothing raises, as the lookup would.
24852485
2486-
For the in-place variants, see [`mogrify_in_with` and `mogrify_in_to`](#mogrify_in_with-mogrify_in_to-update-one-item-at-a-path-in-place). All four path updates are named on the same pattern — `_to` stores a value, `_with` applies a function:
2486+
For the in-place variants, see [`mogrify_in_to` and `mogrify_in_with`](#mogrify_in_to-mogrify_in_with-update-one-item-at-a-path-in-place). All four path updates are named on the same pattern — `_to` stores a value, `_with` applies a function:
24872487
24882488
| | to a value | with a function |
24892489
|------------------|-----------------------------------------|-----------------------------------------|
@@ -2579,15 +2579,15 @@ For convenience, we support some special cases:
25792579
Note that since `cons` is immutable, anyway, if you know you have a long linked list where you need to update the values, just iterate over it and produce a new copy - that will work as intended.
25802580
25812581
2582-
### `mogrify_in_with`, `mogrify_in_to`: update one item at a path, in-place
2582+
### `mogrify_in_to`, `mogrify_in_with`: update one item at a path, in-place
25832583
25842584
**Added in v2.5.0.**
25852585
2586-
Like [`update-in`](https://clojuredocs.org/clojure.core/update-in) and [`assoc-in`](https://clojuredocs.org/clojure.core/assoc-in) from Clojure, but with the update semantics of `mogrify`: walk a path into nested containers, and replace the item found at the end. `mogrify_in_with` replaces it with the result of calling a function on it; `mogrify_in_to` replaces it with a value.
2586+
Like [`assoc-in`](https://clojuredocs.org/clojure.core/assoc-in) and [`update-in`](https://clojuredocs.org/clojure.core/update-in) from Clojure, but with the update semantics of `mogrify`: walk a path into nested containers, and replace the item found at the end. `mogrify_in_to` replaces it with a value; `mogrify_in_with` replaces it with the result of calling a function on it.
25872587
25882588
```python
25892589
from collections import namedtuple
2590-
from unpythonic import mogrify_in_with, mogrify_in_to
2590+
from unpythonic import mogrify_in_to, mogrify_in_with
25912591
from unpythonic.env import env
25922592
25932593
d = {"devices": {"tts": {"device": "cpu"}}}
@@ -2606,7 +2606,7 @@ Nothing is mutated until the final store, so if a step cannot be taken, the inpu
26062606
26072607
Steps are looked up as in `fupdate_in_to`: a key into a mapping, an index into a sequence (or a sequence `view`) when the step is an `int`, and an attribute name otherwise. Negative indices work. A step that names nothing raises (`KeyError`, `IndexError`, or `AttributeError`); no containers are created along the way.
26082608
2609-
The parameter order is curry-friendly: `mogrify_in_with(func, path, container)` and `mogrify_in_to(value, path, container)`.
2609+
The parameter order is curry-friendly: `mogrify_in_to(value, path, container)` and `mogrify_in_with(func, path, container)`.
26102610
26112611
For a functional update, which never mutates its input, see [`fupdate_in_to` and `fupdate_in_with`](#fupdate_in_to-fupdate_in_with), which also has a table of all four path updates.
26122612

0 commit comments

Comments
 (0)