walker navigator to fail to walk records. ALL has been updated to operate over MapEntry in ClojureScript, fixing the issue.vtransform variant of transform that takes in collected values as a vector in the first argument rather than spliced into argument list.vterminal that takes in collected vals as vector in first argument rather than spliced into argument list.compact navigator. After each step of navigation of its subpath, compact removes the collection if it's empty.terminal to be a no-op on select codepathsubselect/filterer removes first matched element instead of setting to nil when transformed to empty sequenceregex-nav navigator for regexes, which navigates to every match in a string and supports replacement with a new substring (thanks @mwfogleman)regex-nav in pathskeypath in pathsindexed-vals navigator, a variant of INDEXED-VALS that allows for a customized start index.INDEXED-VALS invalidly overwriting elements in some transforms involving multiple index changesbefore-index navigator for inserting a single element into a sequence.index-nav navigator for moving an element in a sequence to a new index, shifting other elements in the process.INDEXED-VALS navigator for navigating to every element of a sequence as [index elem] pair. Transform on index portion works the same as index-nav.pred=, pred<, pred>, pred<=, pred>= for filtering using common comparisonsmap-key navigatorset-elem navigatorALL-WITH-META navigatorwalker and codewalker can now be used with NONE to remove elementswalker performance by 70% by replacing clojure.walk implementation with custom recursive pathALL to work on records (navigate to key/value pairs)srange-dynamic that takes in the result of the start index fn. Use end-fn macro to declare this function (takes in 2 args of [collection, start-index]). Functions defined with normal mechanisms (e.g. fn) will still only take in the collection as an argument.NONE, added as private var to cljs.core with 1.9.562)subselect/filterer can remove entries in source by transforming to a smaller sequencesatisfies-protpath?ALL transform on lists by 20%pred no longer inserts unnecessary coerce-nav call at callsitecom.rpl.specter/NONE to remove elements from data structures. Works with keypath (for both sequences and maps), must, nthpath, ALL, MAP-VALS, FIRST, and LASTnthpath navigatorwith-fresh-collected higher order navigatortraverse-all which returns a transducer that traverses over all elements matching the given path.select-first and select-any now avoid traversal beyond the first value matched by the path (like when using ALL), so they are faster now for those use cases.MAP-KEYS navigator that's more efficient than [ALL FIRST]NAME and NAMESPACE navigatorssrange, BEGINNING, END to work on strings. Navigates to a substring.FIRST and LAST to work on strings. Navigates to a character.BEFORE-ELEM and AFTER-ELEM for prepending or appending a single element to a sequenceNONE-ELEM to efficiently add a single element to a setALL performance for PersistentHashSetif-path, selected?, and not-selected?LAST, FIRST, BEGINNING, and END properly transform subvector types to a vector typeeachnav to turn any 1-argument navigator into a navigator that accepts any number of arguments, navigating by each argument in orderkeypath and must enhanced to take in multiple arguments for concisely specifying multiple stepstraversedcom.rpl.specter.macros namespace removed and all macros moved into core com.rpl.specter namespaceNavigator changed to RichNavigator and functions now have an extra argument.defnav and its variations from com.rpl.specter. The core protocols may no longer be extended. Existing types can be turned into navigators with the new IndirectNav protocol.fixed-pathed-nav and variable-pathed-nav and replaced with much more generic late-bound-nav. late-bound-nav can have normal values be late-bound parameterized (not just paths). Use late-path function to indicate which parameters are paths. If all bindings given to late-bound-nav are static, the navigator will be resolved and cached immediately. See transformed and selected? for examples.path macro to handle the parameterization.(defprotocolpath MyProtPath [a])
(extend-protocolpath MyProtPath
clojure.lang.PersistentArrayMap
(must a))
defpathedfn and replaced with much more generic defdynamicnav. defdynamicnav works similar to a macro and takes as input the parameters seen during inline caching. Use dynamic-param? to distinguish which parameters are statically specified and which are dynamic. defdynamicnav is typically used in conjunction with late-bound-nav – see implementation of selected? for an example.RichNavigator interface.local-declarepath to assist in making local recursive or mutually recursive paths. Use with providepath.recursive-path to assist in making recursive paths, both parameterized and unparameterized. Example:(let [tree-walker (recursive-path [] p (if-path vector? [ALL p] STAY))]
(select tree-walker [1 [2 [3 4] 5] [[6]]]))
IndirectNav protocol for turning a value type into a navigator.must-cache-paths!. No longer relevant since all paths can now be compiled and cached.with-inline-debug macro that prints information about the code being analyzed and produced by the inline compiler / cacher.defnav now generates helper functions for every method. For example, keypath now has helpers keypath-select* and keypath-transform*. These functions take parameters [key structure next-fn]Navigator protocol select* in order to enable very large performance improvements to select, select-one, select-first, and select-one!. Custom navigators will need to be updated to conform to the new required semantics. Codebases that do not use custom navigators do not require any changes. See the docstring on the protocol for the details.select-any operation which selects a single element navigated to by the path. Which element returned is undefined. If no elements are navigated to, returns com.rpl.specter/NONE. This is the fastest selection operation.selected-any? operation that returns true if any element is navigated to.traverse operation which returns a reducible object of all the elements navigated to by the path. Very efficient.multi-transform operation which can be used to perform multiple transformations in a single traversal. Much more efficient than doing the
transformations with transform one after another when the transformations share a lot of navigation. multi-transform is used in conjunction with terminal and terminal-val – see the docstring for details.select, select-one, select-first, and select-one!multi-pathcollected? macro to create a filter function which operates on the collected values.richnav macro for creating navigators with full flexibilitysetval no longer throws exceptionif-path, cond-path, selected?, and not-selected?, especially for condition path containing only static functionsEND on vectorstransformed transform-fn no longer factors into pred when an anonymous function during inline factoringfalsepath macro does intelligent inline caching of the provided path. The path is factored into a static portion and into params which may change on each usage of the path (e.g. local parameters). The static part is factored and compiled on the first run-through, and then re-used for all subsequent invocations. As an example, [ALL (keypath k)] is factored into [ALL keypath], which is compiled and cached, and [k], which is provided on each execution. If it is not possible to precompile the path (e.g. [ALL some-local-variable]), nothing is cached and the path will be compiled on each run-through.select/transform/setval/replace-in functions changed to macros and moved to com.rpl.specter.macros namespace. The new macros now automatically wrap the provided path in path to enable inline caching. Expect up to a 100x performance improvement without using explicit precompilation, and to be within 2% to 15% of the performance of explicitly precompiled usage.select*/transform*/setval*/replace-in*/etc. functions that have the same functionality as the old select/transform/setval/replace-in functions.must-cache-paths! function to throw an error if it is not possible to factor a path into a static portion and dynamic parameters.defpath renamed to defnavpath renamed to navfixed-pathed-path and variable-pathed-path renamed to fixed-pathed-nav and variabled-pathed-navmust navigator to navigate to a key if and only if it exists in the structurecontinuous-subseqs navigatorATOM navigator (thanks @rakeshp)defnavconstructor. These allow defining a flexible function to parameterize a defnav, and the function integrates with inline caching for high performance.parser path (thanks @thomasathorne)submap path (thanks @bfabry)subselect path (thanks @aengelberg)Can you improve this documentation?Edit on GitHub
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |