function
boot.janet on line 1493, column 1
(put-in ds ks v)
Put a value into a nested data structure `ds`. Looks into `ds` via
a sequence of keys. Missing data structures will be replaced with
tables. Returns the modified, original data structure.
(def record @{:recipient @{:name "Bob" :age 60} :sender @{:name "Alice" :age 21}})
(put-in
record
[:sender :age]
26)
# @{:recipient @{:name "Bob" :age 60} :sender @{:name "Alice" :age 26}}
(put-in
record
[:recipient]
@{:name "Carl"})
# @{:recipient @{:name "Carl"} :sender @{:name "Alice" :age 26}}
(put-in @{:a @{:aa 5} :b @{:bb 6}} [:c] 9) # => @{:a @{:aa 5} :b @{:bb 6} :c 9}
(put-in @{:a @{:aa 5} :b @{:bb 6}} [:a :aa] 9) # => @{:a @{:aa 9} :b @{:bb 6}}
(put-in @{:a @{:aa 5} :b @{:bb 6}} [:a :cc :ddd] 9) # => @{:a @{:cc @{:ddd 9} :aa 5} :b @{:bb 6}}
(put-in @[:a :b @[:aa :bb :cc]] [2 1] :zz ) # => @[:a :b @[:aa :zz :cc]]
(put-in @[:a :b @[:aa :bb :cc]] [5] :z ) # => @[:a :b @[:aa :bb :cc] nil nil :z]
(put-in @[:a :b @[:aa :bb :cc]] [4 0] :zz ) # => @[:a :b @[:aa :bb :cc] nil @{0 :zz}]
(put-in @[:a :b @[:aa :bb :cc]] [4 :yy] :zz ) # => @[:a :b @[:aa :bb :cc] nil @{:yy :zz}]