Handbook
Glossary
rename-at ( newkey key assoc -- )
Factor handbook
»
The language
»
Collections
»
Associative mapping operations
»
Storing keys and values in assocs
Prev:
delete-at* ( key assoc -- value/f ? )
Next:
change-at ( ..a key assoc quot: ( ..a value -- ..b newvalue ) -- ..b )
Vocabulary
assocs
Inputs
newkey
an
object
key
an
object
assoc
an
assoc
Outputs
None
Word description
Removes the values associated to
key
and re-adds it as
newkey
. Does nothing if the assoc does not contain
key
.
Definition
USING:
kernel
;
IN:
assocs
:
rename-at
( newkey key assoc -- )
[
delete-at*
]
keep
[
[
swap
]
]
dip
[
set-at
]
curry
compose
[
2drop
]
if
;