adobe / ferrum

Features from the rust language in javascript: Provides Traits/Type classes & a hashing infrastructure and an advanced library for working with sequences/iterators in js
https://www.ferrumjs.org
Apache License 2.0
519 stars 25 forks source link

Tree traversal functions #157

Open koraa opened 3 years ago

koraa commented 3 years ago

We should provide functions for traversing trees make from containers that implement Get/Set

const treeGet = (seq, tree) => foldl(seq, tree, (c, k) => get(c, k));
const treeSet = (seq, tree, value) =>…
const tryTreeGet = (seq, tree, default) => // Returns default if a node didn't exist
const tryTreeSet = (seq, tree, value) => // Won't throw an exception if an intermediate node didn't exist
const treeCreateNodes = (seq, tree) => // Will create intermediate nodes (default values in sequence which is of the form [[key, defaultValue],...])