specter-wiki/Cheat-Sheet.md

92 lines
8.8 KiB
Markdown
Raw Normal View History

2018-02-11 22:04:17 +00:00
# Cheat Sheet
Most of Specter's API consists of an operation, a path and the data to operate on.
Generally usage is like this:
```
(Operation Path Data)
where
Operation: Query|Transform
Path: Navigator|Vector of Navigators
Data: User-provided data structure to operate on.
```
Refer to the specific API documentation to check usage.
2018-02-11 22:04:17 +00:00
## Operations
There are 2 types of operations: queries and transforms.
2018-02-11 22:04:17 +00:00
#### Query
[`select`](https://github.com/nathanmarz/specter/wiki/List-of-Macros#select), [`select-any`](https://github.com/nathanmarz/specter/wiki/List-of-Macros#select-any), [`select-first`](https://github.com/nathanmarz/specter/wiki/List-of-Macros#select-first), [`select-one`](https://github.com/nathanmarz/specter/wiki/List-of-Macros#select-one), [`select-one!`](https://github.com/nathanmarz/specter/wiki/List-of-Macros#select-one-1), [`selected-any?`](https://github.com/nathanmarz/specter/wiki/List-of-Macros#selected-any), [`traverse`](https://github.com/nathanmarz/specter/wiki/List-of-Macros#traverse), [`traverse-all`](https://github.com/nathanmarz/specter/wiki/List-of-Macros#traverse-all)
2018-02-11 22:04:17 +00:00
#### Transform
[`transform`](https://github.com/nathanmarz/specter/wiki/List-of-Macros#transform), [`multi-transform`](https://github.com/nathanmarz/specter/wiki/List-of-Macros#multi-transform), [`replace-in`](https://github.com/nathanmarz/specter/wiki/List-of-Macros#replace-in), [`setval`](https://github.com/nathanmarz/specter/wiki/List-of-Macros#setval), `vtransform`
2018-02-12 13:59:00 +00:00
2018-02-11 22:04:17 +00:00
## Paths
A path (often named `apath`) is a navigator or a vector of navigators.
Navigator sometimes operates on specific data structures.
#### Maps
[`MAP-KEYS`](https://github.com/nathanmarz/specter/wiki/List-of-Navigators#map-keys), [`MAP-VALS`](https://github.com/nathanmarz/specter/wiki/List-of-Navigators#map-vals), `compact`, [`keypath`](https://github.com/nathanmarz/specter/wiki/List-of-Navigators#keypath), [`map-key`](https://github.com/nathanmarz/specter/wiki/List-of-Navigators#map-key), [`submap`](https://github.com/nathanmarz/specter/wiki/List-of-Navigators#submap), [`must`](https://github.com/nathanmarz/specter/wiki/List-of-Navigators#must)
2018-02-11 22:04:17 +00:00
#### Sequences
[`ALL`](https://github.com/nathanmarz/specter/wiki/List-of-Navigators#all), [`ALL-WITH-META`](https://github.com/nathanmarz/specter/wiki/List-of-Navigators#all-with-meta), [`AFTER-ELEM`](https://github.com/nathanmarz/specter/wiki/List-of-Navigators#after-elem), [`BEFORE-ELEM`](https://github.com/nathanmarz/specter/wiki/List-of-Navigators#before-elem), [`BEGINNING`](https://github.com/nathanmarz/specter/wiki/List-of-Navigators#beginning), [`END`](https://github.com/nathanmarz/specter/wiki/List-of-Navigators#end), [`FIRST`](https://github.com/nathanmarz/specter/wiki/List-of-Navigators#first), [`INDEXED-VALS`](https://github.com/nathanmarz/specter/wiki/List-of-Navigators#indexed-vals), [`LAST`](https://github.com/nathanmarz/specter/wiki/List-of-Navigators#last)
2018-02-11 22:04:17 +00:00
[`before-index`](https://github.com/nathanmarz/specter/wiki/List-of-Navigators#before-index), `compact`, [`continuous-subseqs`](https://github.com/nathanmarz/specter/wiki/List-of-Navigators#continuous-subseqs), [`filterer`](https://github.com/nathanmarz/specter/wiki/List-of-Navigators#filterer), [`index-nav`](https://github.com/nathanmarz/specter/wiki/List-of-Navigators#index-nav), [`nthpath`](https://github.com/nathanmarz/specter/wiki/List-of-Navigators#nthpath), [`srange`](https://github.com/nathanmarz/specter/wiki/List-of-Navigators#srange), [`srange-dynamic`](https://github.com/nathanmarz/specter/wiki/List-of-Navigators#srange-dynamic)
2018-02-11 22:04:17 +00:00
#### Sets
[`NONE-ELEM`](https://github.com/nathanmarz/specter/wiki/List-of-Navigators#none-elem), `compact`, [`set-elem`](https://github.com/nathanmarz/specter/wiki/List-of-Navigators#set-elem), [`subset`](https://github.com/nathanmarz/specter/wiki/List-of-Navigators#subset)
2018-02-11 22:04:17 +00:00
#### Keywords/Symbols
[`NAME`](https://github.com/nathanmarz/specter/wiki/List-of-Navigators#name), [`NAMESPACE`](https://github.com/nathanmarz/specter/wiki/List-of-Navigators#namespace)
2018-02-11 22:04:17 +00:00
#### Atoms
[`ATOM`](https://github.com/nathanmarz/specter/wiki/List-of-Navigators#atom)
2018-02-11 22:04:17 +00:00
#### Strings
2018-02-11 22:04:17 +00:00
[`BEGINNING`](https://github.com/nathanmarz/specter/wiki/List-of-Navigators#beginning), [`END`](https://github.com/nathanmarz/specter/wiki/List-of-Navigators#end), [`FIRST`](https://github.com/nathanmarz/specter/wiki/List-of-Navigators#first), [`LAST`](https://github.com/nathanmarz/specter/wiki/List-of-Navigators#last), [`regex-nav`](https://github.com/nathanmarz/specter/wiki/List-of-Navigators#regex-nav), [`srange`](https://github.com/nathanmarz/specter/wiki/List-of-Navigators#srange)
2018-02-11 22:04:17 +00:00
#### Metadata
[`ALL-WITH-META`](https://github.com/nathanmarz/specter/wiki/List-of-Navigators#all-with-meta), [`META`](https://github.com/nathanmarz/specter/wiki/List-of-Navigators#meta)
2018-02-11 22:04:17 +00:00
#### Views
[`NIL->LIST`](https://github.com/nathanmarz/specter/wiki/List-of-Navigators#nil-list), [`NIL->SET`](https://github.com/nathanmarz/specter/wiki/List-of-Navigators#nil-set), [`NIL->VECTOR`](https://github.com/nathanmarz/specter/wiki/List-of-Navigators#nil-vector), [`nil->val`](https://github.com/nathanmarz/specter/wiki/List-of-Navigators#nil-val), [`parser`](https://github.com/nathanmarz/specter/wiki/List-of-Navigators#parser), [`transformed`](https://github.com/nathanmarz/specter/wiki/List-of-Navigators#transformed), [`traversed`](https://github.com/nathanmarz/specter/wiki/List-of-Navigators#traversed), [`view`](https://github.com/nathanmarz/specter/wiki/List-of-Navigators#view)
2018-02-11 22:04:17 +00:00
#### Value collection
[`DISPENSE`](https://github.com/nathanmarz/specter/wiki/List-of-Navigators#dispense), [`VAL`](https://github.com/nathanmarz/specter/wiki/List-of-Navigators#val), [`collect`](https://github.com/nathanmarz/specter/wiki/List-of-Navigators#collect), [`collect-one`](https://github.com/nathanmarz/specter/wiki/List-of-Navigators#collect-one), [`collected?`](https://github.com/nathanmarz/specter/wiki/List-of-Macros#collected), [`putval`](https://github.com/nathanmarz/specter/wiki/List-of-Navigators#putval), [`with-fresh-collected`](https://github.com/nathanmarz/specter/wiki/List-of-Navigators#with-fresh-collected)
2018-02-11 22:04:17 +00:00
#### Control
[`STAY`](https://github.com/nathanmarz/specter/wiki/List-of-Navigators#stay), [`STOP`](https://github.com/nathanmarz/specter/wiki/List-of-Navigators#stop), [`cond-path`](https://github.com/nathanmarz/specter/wiki/List-of-Navigators#cond-path), [`continue-then-stay`](https://github.com/nathanmarz/specter/wiki/List-of-Navigators#continue-then-stay), [`if-path`](https://github.com/nathanmarz/specter/wiki/List-of-Navigators#if-path), [`multi-path`](https://github.com/nathanmarz/specter/wiki/List-of-Navigators#multi-path), [`stay-then-continue`](https://github.com/nathanmarz/specter/wiki/List-of-Navigators#stay-then-continue), [`subselect`](https://github.com/nathanmarz/specter/wiki/List-of-Navigators#subselect)
2018-02-11 22:04:17 +00:00
#### Filters
[`pred`](https://github.com/nathanmarz/specter/wiki/List-of-Navigators#pred), [`pred=`](https://github.com/nathanmarz/specter/wiki/List-of-Navigators#pred-1), [`pred<`](https://github.com/nathanmarz/specter/wiki/List-of-Navigators#pred-2), [`pred>`](https://github.com/nathanmarz/specter/wiki/List-of-Navigators#pred-3), [`pred<=`](https://github.com/nathanmarz/specter/wiki/List-of-Navigators#pred-4), [`pred>=`](https://github.com/nathanmarz/specter/wiki/List-of-Navigators#pred-5), [`not-selected?`](https://github.com/nathanmarz/specter/wiki/List-of-Navigators#not-selected), [`selected?`](https://github.com/nathanmarz/specter/wiki/List-of-Navigators#selected)
2018-02-11 22:04:17 +00:00
#### Walking
[`codewalker`](https://github.com/nathanmarz/specter/wiki/List-of-Navigators#codewalker), [`walker`](https://github.com/nathanmarz/specter/wiki/List-of-Navigators#walker)
2018-02-11 22:04:17 +00:00
#### Multi-transform
[`terminal`](https://github.com/nathanmarz/specter/wiki/List-of-Navigators#terminal), [`terminal-val`](https://github.com/nathanmarz/specter/wiki/List-of-Navigators#terminal-val), `vterminal`
2018-02-11 22:04:17 +00:00
## Custom navigators
2018-02-11 22:04:17 +00:00
2018-02-12 18:38:44 +00:00
[`declarepath`](https://github.com/nathanmarz/specter/wiki/List-of-Macros#declarepath), [`defprotocolpath`](https://github.com/nathanmarz/specter/wiki/List-of-Macros#defprotocolpath), [`extend-protocolpath`](https://github.com/nathanmarz/specter/wiki/List-of-Macros#extend-protocolpath), `local-declarepath`, [`path`](https://github.com/nathanmarz/specter/wiki/List-of-Macros#path), [`providepath`](https://github.com/nathanmarz/specter/wiki/List-of-Macros#providepath), [`recursive-path`](https://github.com/nathanmarz/specter/wiki/List-of-Macros#recursive-path), [`defcollector`](https://github.com/nathanmarz/specter/wiki/List-of-Macros#defcollector), [`defdynamicnav`](https://github.com/nathanmarz/specter/wiki/List-of-Macros#defdynamicnav), [`defnav`](https://github.com/nathanmarz/specter/wiki/List-of-Macros#defnav), [`eachnav`](https://github.com/nathanmarz/specter/wiki/List-of-Macros#eachnav), [`nav`](https://github.com/nathanmarz/specter/wiki/List-of-Macros#nav)