Candidate programs: code plus the provenance that justifies it.
{:code program text :via realization and wrapper ids, pre-order :requires every capability the text relies on :stack languages from outermost to innermost :cost structural cost, a number >= 0: realization and wrapper costs summed, a literal encoder adding 0 :key the ranks on the way in pre-order, each [kind cost id], kind 0 for a realization and 1 for a wrapper; it orders equal costs}
Every key is mandatory: stamp, enclose and merge-parts add to :cost and :key, so a hand-built candidate without them throws. Ranks come from realization-rank and wrapper-rank and queue entries from bound and stream, so the [kind cost id] grammar of keys is written only here.
Candidate programs: code plus the provenance that justifies it.
{:code program text
:via realization and wrapper ids, pre-order
:requires every capability the text relies on
:stack languages from outermost to innermost
:cost structural cost, a number >= 0: realization and wrapper costs
summed, a literal encoder adding 0
:key the ranks on the way in pre-order, each [kind cost id], kind
0 for a realization and 1 for a wrapper; it orders equal costs}
Every key is mandatory: stamp, enclose and merge-parts add to :cost and
:key, so a hand-built candidate without them throws. Ranks come from
realization-rank and wrapper-rank and queue entries from bound and
stream, so the [kind cost id] grammar of keys is written only here.How combine builds a product: (fn [f seqs] candidates). Default best-first-product. The seam a reference test binds to the full, unordered product, to check the search against an enumeration that does not share its ordering code.
How combine builds a product: (fn [f seqs] candidates). Default best-first-product. The seam a reference test binds to the full, unordered product, to check the search against an enumeration that does not share its ordering code.
(best-first entries)Lazy seq of candidates, cheapest :cost first, from queue entries:
a candidate emitted when popped {:open f ...} a bound: f returns an ascending seq of entries {:stream s ...} an ascending seq of entries, opened one at a time
An entry's :cost is a lower bound for everything it opens; :key ranks ties. A bound costs nothing until it reaches the front of the queue.
Lazy seq of candidates, cheapest :cost first, from queue entries:
a candidate emitted when popped
{:open f ...} a bound: f returns an ascending seq of entries
{:stream s ...} an ascending seq of entries, opened one at a time
An entry's :cost is a lower bound for everything it opens; :key ranks
ties. A bound costs nothing until it reaches the front of the queue.(best-first-product f seqs)Lazy product of the candidate seqs in seqs, cheapest total cost first. Each seq must be ascending by :cost. f receives the codes and returns the combined code. Ties pop by key, then by index tuple, so the walk is deterministic. An element of an input seq is realized only once an output needs it.
Lazy product of the candidate seqs in seqs, cheapest total cost first. Each seq must be ascending by :cost. f receives the codes and returns the combined code. Ties pop by key, then by index tuple, so the walk is deterministic. An element of an input seq is realized only once an output needs it.
(bound cost key open)A queue entry costing cost, ranked by key, that opens (open) only when it reaches the front: open returns an ascending seq of entries, each costing at least cost and keyed under key.
A queue entry costing cost, ranked by key, that opens (open) only when it reaches the front: open returns an ascending seq of entries, each costing at least cost and keyed under key.
(combine f & seqs)Lazy product of candidate seqs, cheapest total cost first (see best-first-product, the default product).
Lazy product of candidate seqs, cheapest total cost first (see best-first-product, the default *product*).
(enclose w ic oc)The candidate of wrapper w around inner candidate ic, oc being the candidate w rendered for ic's code in w's outer language: oc's code, provenance in pre-order (w, then ic, then oc), w's cost added to both, w's rank leading the key.
The candidate of wrapper w around inner candidate ic, oc being the candidate w rendered for ic's code in w's outer language: oc's code, provenance in pre-order (w, then ic, then oc), w's cost added to both, w's rank leading the key.
(entry-kind e)The kind of queue entry e: :bound when it has an :open fn, :stream when it has a :stream, else :candidate.
The kind of queue entry e: :bound when it has an :open fn, :stream when it has a :stream, else :candidate.
What popping entry e yields: {:emit candidate} or {:enqueue entries}, entries to push in order. Only a popped bound calls its :open, and only a popped stream realizes its next element.
What popping entry e yields: {:emit candidate} or {:enqueue entries},
entries to push in order. Only a popped bound calls its :open, and only a
popped stream realizes its next element.(leaf code)A single candidate from an encoder result, or none when it returned nil. It costs nothing by itself; stamp adds the realization's cost.
A single candidate from an encoder result, or none when it returned nil. It costs nothing by itself; stamp adds the realization's cost.
(merge-parts f parts)One candidate from candidates parts, in order: :code is f applied to their codes, :via and :key concatenate, :requires unions, :stack is the longest, :cost sums.
One candidate from candidates parts, in order: :code is f applied to their codes, :via and :key concatenate, :requires unions, :stack is the longest, :cost sums.
(pop-min queue)[e rest] for the least entry e of queue and the queue without it, or nil when queue is empty. e carries no insertion number.
[e rest] for the least entry e of queue and the queue without it, or nil when queue is empty. e carries no insertion number.
(push queue e)(push queue e n)queue with entry e added, numbered n, by default the queue's insertion count; nil leaves it unchanged. Entries of equal :cost and :key pop by number, so in push order when numbered by default.
That FIFO is the queue's, not best-first's: a popped bound re-enters as a stream with a fresh number. Pre-order among equal costs in best-first rests on keys being unique, not on push order.
queue with entry e added, numbered n, by default the queue's insertion count; nil leaves it unchanged. Entries of equal :cost and :key pop by number, so in push order when numbered by default. That FIFO is the queue's, not best-first's: a popped bound re-enters as a stream with a fresh number. Pre-order among equal costs in best-first rests on keys being unique, not on push order.
(realization-rank r)The key rank of realization r: [0 cost id].
The key rank of realization r: [0 cost id].
(stamp cand r lang)Attribute cand to realization r rendered in lang: r's weight is added and its rank leads the key.
Attribute cand to realization r rendered in lang: r's weight is added and its rank leads the key.
(stream s)(stream cost key s)A queue entry over s, an ascending seq of entries, realized one element at a time. cost and key rank it until its head is realized.
A queue entry over s, an ascending seq of entries, realized one element at a time. cost and key rank it until its head is realized.
(successors t)The index tuples after tuple t: t with one coordinate incremented, for each coordinate at or after its last nonzero one. From the zero tuple this reaches every tuple of naturals exactly once.
The index tuples after tuple t: t with one coordinate incremented, for each coordinate at or after its last nonzero one. From the zero tuple this reaches every tuple of naturals exactly once.
(weight r)What realization r adds to a candidate's :cost: its :cost, except a literal encoder, which adds nothing; its cost ranks ties through :key.
What realization r adds to a candidate's :cost: its :cost, except a literal encoder, which adds nothing; its cost ranks ties through :key.
(wrapper-rank w)The key rank of wrapper w: [1 cost id], after every realization of equal cost, so a direct realization wins a tie against a delegation.
The key rank of wrapper w: [1 cost id], after every realization of equal cost, so a direct realization wins a tie against a delegation.
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 |