function
boot.janet on line 1896 , column 1
(update x key f & args )
For a given key in `x` , replace its associated value with the
result of applying `f` to that value. If `args` are provided , they
will be passed along to `f` as well. Returns updated `x` .
`x` can be a buffer , array , table , or suitable abstract type with
`get` and `put` methods.
(update @{:data @[:cherry :orange ]} :data (comp sorted |(array/push $ :apple )))
# => {:data @[:apple :cherry :orange]}
# note that all data structures must be mutable with @
(def c @{:size :small :roast :dark :add-ins @[:soy :almond :soy ]})
(defn add! [coffee extra ]
(update coffee :extras (comp sort |(array/push $ extra ))))
(add! c :chocolate )
(-> @{:a 0 :b 0 }
(update :a inc )
(update :b inc ))
# => @{:a 1 :b 1}
(update @{:a 1 } :a inc )
# => @{:a 2}
(update @[3 4 5 ] 1 dec ) # => @[3 3 5]
(update (update @[3 4 5 ] 1 dec ) 2 inc ) # => @[3 3 6]