JanetDocsPlaygroundI'm feeling luckyGitHub sign in

update



    function
    boot.janet on line 1452, column 1

    (update ds key func & args)

    Accepts a key argument and passes its associated value to a 
    function. The key is then re-associated to the function's return 
    value. Returns the updated data structure `ds`.


3 examplesSign in to add an example
Loading...
(-> @{:a 0 :b 0}
    (update :a inc)
    (update :b inc))
# => @{:a 1 :b 1}
sogaiuPlayground
(update @{:a 1} :a inc)
# => @{:a 2}
sogaiuPlayground
(update @[3 4 5] 1 dec)  # => @[3 3 5]
(update (update @[3 4 5] 1 dec) 2 inc)  # => @[3 3 6]
cellularmitosisPlayground