Skip to content

Commit 048d185

Browse files
sequences protocol links (#240)
[no important files changed]
1 parent 7a2dcf2 commit 048d185

18 files changed

Lines changed: 87 additions & 52 deletions

File tree

concepts/arrays/about.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ the stack:
1313
| `<array>`| `( n elt -- array )``n` copies of `elt` |
1414
| `array?` | `( obj -- ? )` — type predicate |
1515

16-
A few protocol words from `sequences` come up so often with
16+
A few [protocol][sequence-protocol] words from `sequences` come up so often with
1717
arrays that they are worth knowing as a unit:
1818

1919
| word | effect |
@@ -39,3 +39,4 @@ sequence — handy when an array's elements should be deduplicated
3939
or checked for duplicates without first converting to a hash-set.
4040

4141
[sets]: https://docs.factorcode.org/content/vocab-sets.html
42+
[sequence-protocol]: https://docs.factorcode.org/content/article-sequence-protocol.html

concepts/assocs/about.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# About
22

3-
`assocs` is a protocol, not a single data type. Hashtables (`H{ }`),
3+
`assocs` is a [protocol][assoc-protocol], not a single data type. Hashtables (`H{ }`),
44
association lists (sequences of `{ key value }` pairs), and tree
55
maps all implement it, and most words on assocs are interchangeable
66
between them.
@@ -29,3 +29,5 @@ but most exercise-level work involves a small set:
2929

3030
`sort-keys` and `sort-values` (in `sorting`) sort an alist by the
3131
chosen field.
32+
33+
[assoc-protocol]: https://docs.factorcode.org/content/article-assocs-protocol.html

concepts/assocs/introduction.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Introduction
22

33
Factor's associative arrays — hashtables and friends — share a
4-
common protocol from [`assocs`][assocs]. The hashtable literal is
4+
common [protocol][assoc-protocol] from [`assocs`][assocs]. The hashtable literal is
55
`H{ }`:
66

77
```factor
@@ -29,3 +29,4 @@ Hashtables are *mutable* — `clone` an `H{ }` literal before
2929
modifying so the literal isn't shared between calls.
3030

3131
[assocs]: https://docs.factorcode.org/content/vocab-assocs.html
32+
[assoc-protocol]: https://docs.factorcode.org/content/article-assocs-protocol.html

concepts/concurrency/about.md

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ The standard concurrency primitives are layered:
1414

1515
| Vocab | Provides |
1616
|-----------------------------|----------------------------------------|
17-
| `threads` | `spawn`, `yield`, thread identity |
18-
| `concurrency.promises` | `<promise>`, `fulfill`, `?promise` |
19-
| `concurrency.locks` | `<lock>`, `with-lock` |
20-
| `concurrency.combinators` | `parallel-map`, `parallel-each` |
21-
| `concurrency.semaphores` | `<semaphore>`, `acquire`, `release` |
22-
| `concurrency.mailboxes` | per-thread inboxes, `send`, `receive` |
23-
| `concurrency.channels` | rendezvous handles, `to`, `from` |
17+
| [`threads`][threads] | `spawn`, `yield`, thread identity |
18+
| [`concurrency.promises`][concurrency.promises] | `<promise>`, `fulfill`, `?promise` |
19+
| [`concurrency.locks`][concurrency.locks] | `<lock>`, `with-lock` |
20+
| [`concurrency.combinators`][concurrency.combinators] | `parallel-map`, `parallel-each` |
21+
| [`concurrency.semaphores`][concurrency.semaphores] | `<semaphore>`, `acquire`, `release` |
22+
| [`concurrency.mailboxes`][concurrency.mailboxes] | per-thread inboxes, `send`, `receive` |
23+
| [`concurrency.channels`][concurrency.channels] | rendezvous handles, `to`, `from` |
2424

2525
```factor
2626
USING: concurrency.combinators concurrency.locks
@@ -50,3 +50,11 @@ hashtable that more than one thread reads or writes. Treat both reads
5050
and writes as needing the lock if there's any non-atomic compound
5151
update; missing a lock on either side is the classic recipe for a
5252
torn read.
53+
54+
[concurrency.channels]: https://docs.factorcode.org/content/vocab-concurrency.channels.html
55+
[concurrency.combinators]: https://docs.factorcode.org/content/vocab-concurrency.combinators.html
56+
[concurrency.locks]: https://docs.factorcode.org/content/vocab-concurrency.locks.html
57+
[concurrency.mailboxes]: https://docs.factorcode.org/content/vocab-concurrency.mailboxes.html
58+
[concurrency.promises]: https://docs.factorcode.org/content/vocab-concurrency.promises.html
59+
[concurrency.semaphores]: https://docs.factorcode.org/content/vocab-concurrency.semaphores.html
60+
[threads]: https://docs.factorcode.org/content/vocab-threads.html

concepts/deques/about.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
`<dlist>` (in [`dlists`][dlists]) constructs a fresh doubly-linked
44
list. The operations live in [`deques`][deques] and dispatch on
5-
the deque protocol, so other containers — chiefly `<dlist>`
5+
the [deque protocol][deque-protocol], so other containers — chiefly `<dlist>`
66
can implement them.
77

88
| word | effect |
@@ -83,3 +83,4 @@ finite, manageable set.
8383
[dlists]: https://docs.factorcode.org/content/vocab-dlists.html
8484
[memoize]: https://docs.factorcode.org/content/vocab-memoize.html
8585
[memo-decl]: https://docs.factorcode.org/content/word-MEMO__colon__%2Csyntax.html
86+
[deque-protocol]: https://docs.factorcode.org/content/article-deques.html

concepts/hash-sets/about.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# About
22

3-
Hash-sets implement the [`sets`][sets] protocol with hashing
3+
Hash-sets implement the [`sets`][sets] [protocol][set-protocol] with hashing
44
under the hood, giving O(1) average insert, lookup, and delete.
55
They're mutable in place, which makes them ideal for the
66
*visited set* pattern in graph traversals.
@@ -64,3 +64,4 @@ reachability question, which is why a vector-as-stack is enough
6464
[dlist]: https://docs.factorcode.org/content/word-__lt__dlist__gt__%2Cdlists.html
6565

6666
[sets]: https://docs.factorcode.org/content/vocab-sets.html
67+
[set-protocol]: https://docs.factorcode.org/content/article-sets.html

concepts/higher-order-sequences/about.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,15 @@ Beyond the core sequence ops:
4848

4949
| vocab | provides |
5050
|--------------------|-----------------------------------------------|
51-
| `sorting` | `sort`, `sort-by` |
52-
| `math.statistics` | `cum-sum`, `cum-product`, `cum-min`, `cum-max` |
53-
| `grouping` | `group`, `clump`, `monotonic-split` |
54-
| `sets` | `members`, `all-unique?` |
51+
| [`sorting`][sorting] | `sort`, `sort-by` |
52+
| [`math.statistics`][math.statistics] | `cum-sum`, `cum-product`, `cum-min`, `cum-max` |
53+
| [`grouping`][grouping] | `group`, `clump`, `monotonic-split` |
54+
| [`sets`][sets] | `members`, `all-unique?` |
5555

5656
Pairs (`bi`, `tri`) and "n-ary" combinators (`2map`, `2each`, `zip`)
5757
extend the same pattern when the quotation needs more than one input.
58+
59+
[grouping]: https://docs.factorcode.org/content/vocab-grouping.html
60+
[math.statistics]: https://docs.factorcode.org/content/vocab-math.statistics.html
61+
[sets]: https://docs.factorcode.org/content/vocab-sets.html
62+
[sorting]: https://docs.factorcode.org/content/vocab-sorting.html

concepts/io-streams/about.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Factor splits stream I/O into two layers. The lower layer is the
44
*explicit-stream* API: every word takes the stream as an
55
argument. The upper layer is the *ambient-stream* API: short,
66
one-line words that act on whichever stream is currently bound.
7-
Both layers sit on the same protocol — the upper-layer words
7+
Both layers sit on the same [protocol][stream-protocol] — the upper-layer words
88
just look up the ambient stream and forward the call.
99

1010
## Explicit-stream words
@@ -47,10 +47,10 @@ redirecting `print` to a string is just a matter of binding
4747

4848
| word | vocab | what it builds |
4949
|-------------------|----------------------|---------------------------------|
50-
| `<string-reader>` | `io.streams.string` | reads a literal string |
51-
| `<string-writer>` | `io.streams.string` | collects writes into a string |
52-
| `<file-reader>` | `io.files` | reads a file with an encoding |
53-
| `<file-writer>` | `io.files` | writes a file with an encoding |
50+
| `<string-reader>` | [`io.streams.string`][io.streams.string] | reads a literal string |
51+
| `<string-writer>` | [`io.streams.string`][io.streams.string] | collects writes into a string |
52+
| `<file-reader>` | [`io.files`][io.files] | reads a file with an encoding |
53+
| `<file-writer>` | [`io.files`][io.files] | writes a file with an encoding |
5454

5555
All four produce disposables — they extend `disposable` from
5656
`destructors`, so the `with-…` combinators below release them
@@ -98,6 +98,6 @@ For *implementing* a stream — defining your own class that
9898
plugs into the protocol — see the `streams` concept (taught in
9999
`telegraphers-tape`).
100100

101-
[io]: https://docs.factorcode.org/content/vocab-io.html
102101
[io.streams.string]: https://docs.factorcode.org/content/vocab-io.streams.string.html
103102
[io.files]: https://docs.factorcode.org/content/vocab-io.files.html
103+
[stream-protocol]: https://docs.factorcode.org/content/article-stream-protocol.html

concepts/sequences/about.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# About
22

3-
The [`sequences`][sequences] vocabulary defines a single protocol
4-
that arrays (`{ … }`), vectors (`V{ … }`), strings, ranges, and
3+
The [`sequences`][sequences] vocabulary defines a single
4+
[protocol][sequence-protocol] that arrays (`{ … }`), vectors (`V{ … }`), strings, ranges, and
55
slices all implement. Anything you can do with one, you can do
66
with the others.
77

@@ -63,3 +63,4 @@ V{ 1 2 3 } >array . ! => { 1 2 3 }
6363
```
6464

6565
[sequences]: https://docs.factorcode.org/content/vocab-sequences.html
66+
[sequence-protocol]: https://docs.factorcode.org/content/article-sequence-protocol.html

concepts/sequences/introduction.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Introduction
22

33
Most data in Factor lives in *sequences*. Arrays (`{ … }`), vectors
4-
(`V{ … }`), and strings all share the same protocol from
5-
[`sequences`][sequences].
4+
(`V{ … }`), and strings all share the same [protocol][sequence-protocol]
5+
from [`sequences`][sequences].
66

77
```factor
88
{ 1 2 3 } length . ! => 3
@@ -24,3 +24,4 @@ back from a generic operation.
2424
[arrays]: https://docs.factorcode.org/content/vocab-arrays.html
2525

2626
[sequences]: https://docs.factorcode.org/content/vocab-sequences.html
27+
[sequence-protocol]: https://docs.factorcode.org/content/article-sequence-protocol.html

0 commit comments

Comments
 (0)