Skip to content

Applying a function to a nested map #285

Open
@practicalli-johnny

Description

@practicalli-johnny

What’s the idiomatic way to map a function into a nested collection? For example, in Haskell I’d do:

The best I could come up with in clojure was:
(((comp #(partial map %) #(partial map %)) inc) [[1 2][3 4]])
but that seems pretty ugly

clojure.walk/ post-replace works on every value
clojure.walk/postwalk applies a function

 (clojure.walk/postwalk 
  #(if (number? %) 
    (inc %) 
    %) 
    the-data)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions