You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-[`sym`, `gensym`, `Singleton`: symbols and singletons](#sym-gensym-Singleton-symbols-and-singletons)
71
71
@@ -2483,7 +2483,7 @@ The path is an iterable of steps, outermost first. The containers along it may b
2483
2483
2484
2484
The inputis 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.
2485
2485
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:
@@ -2579,15 +2579,15 @@ For convenience, we support some special cases:
2579
2579
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.
2580
2580
2581
2581
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
2583
2583
2584
2584
**Added in v2.5.0.**
2585
2585
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.
2587
2587
2588
2588
```python
2589
2589
from collections import namedtuple
2590
-
from unpythonic importmogrify_in_with, mogrify_in_to
2590
+
from unpythonic importmogrify_in_to, mogrify_in_with
2591
2591
from unpythonic.env import env
2592
2592
2593
2593
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
2606
2606
2607
2607
Steps are looked up asin`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.
2608
2608
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)`.
2610
2610
2611
2611
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.
0 commit comments