3 ms·
Interesting how different some of the approaches are in the same language, never mind different languages. In clojure, the “atom” version is 5 lines (not includ
by ghufran_syed 6y ago
Interesting how different some of the approaches are in the same language, never mind different languages. In clojure, the “atom” version is 5 lines (not including data or tests), while the “zipper” version is 47 lines and the “reduce” version is 31 lines
- raspasov 6y agoYes, the atom is a hack and discouraged but when you're stuck with a poorly defined data structure, it can be an escape hatch.
- Nihilartikel 6y agoClojure also has some third party libraries like Specter [1] that make nested traversal and mutation very succinct and performant. The author of Specter goes so far as to label traversal/update of deep immutable structures as "Clojure's Missing Piece". [1] https://github.com/redplanetlabs/specter https://github.com/redplanetlabs/specter
- deleted 6y ago[deleted]
- lilactown 6y agoThe Clojure reduce solution is pretty low quality. Here's my 15 line proposal: https://github.com/josevalim/nested-data-structure-traversal/pull/147 https://github.com/josevalim/nested-data-structure-traversal...