Traversing values
The preserves.fold module exports various utilities for traversing compound Value
s.
map_embeddeds(f, v)
Returns an equivalent copy of v
, except where each contained
Embedded value is replaced by f
applied to the Embedded's
embeddedValue
attribute.
>>> map_embeddeds(lambda w: Embedded(f'w={w}'), ['a', Embedded(123), {'z': 6.0}])
('a', #!'w=123', {'z': 6.0})
Source code in preserves/fold.py
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
|
Last update:
March 16, 2023
Created: March 16, 2023
Created: March 16, 2023