diff --git a/concepts/assocs/links.json b/concepts/assocs/links.json index d5ce5f36..b0fd0b48 100644 --- a/concepts/assocs/links.json +++ b/concepts/assocs/links.json @@ -2,5 +2,13 @@ { "url": "https://docs.factorcode.org/content/article-assocs.html", "description": "Associative mapping — Factor handbook" + }, + { + "url": "https://docs.factorcode.org/content/vocab-assocs.html", + "description": "assocs vocabulary reference" + }, + { + "url": "https://docs.factorcode.org/content/article-hashtables.html", + "description": "Hashtables — the default associative implementation" } ] diff --git a/concepts/basics/links.json b/concepts/basics/links.json index fbbd22aa..c5be1a23 100644 --- a/concepts/basics/links.json +++ b/concepts/basics/links.json @@ -2,5 +2,13 @@ { "url": "https://docs.factorcode.org/content/article-effects.html", "description": "Stack effect declarations — Factor handbook" + }, + { + "url": "https://docs.factorcode.org/content/article-shuffle-words.html", + "description": "Shuffle words: dup, drop, swap, over, pick, and friends" + }, + { + "url": "https://docs.factorcode.org/content/article-cookbook.html", + "description": "Factor cookbook — a tour of the language for new readers" } ] diff --git a/concepts/booleans/links.json b/concepts/booleans/links.json index eaaf7baa..390564b5 100644 --- a/concepts/booleans/links.json +++ b/concepts/booleans/links.json @@ -2,5 +2,9 @@ { "url": "https://docs.factorcode.org/content/article-booleans.html", "description": "Booleans — Factor handbook" + }, + { + "url": "https://docs.factorcode.org/content/vocab-kernel.html", + "description": "kernel vocabulary — home of and, or, not, xor" } ] diff --git a/concepts/case/links.json b/concepts/case/links.json index 3f494021..5b97688e 100644 --- a/concepts/case/links.json +++ b/concepts/case/links.json @@ -2,5 +2,9 @@ { "url": "https://docs.factorcode.org/content/word-case,combinators.html", "description": "case — combinators vocabulary" + }, + { + "url": "https://docs.factorcode.org/content/vocab-combinators.html", + "description": "combinators vocabulary — home of case, cond, and cond>quot" } ] diff --git a/concepts/combinators/links.json b/concepts/combinators/links.json index 5376c361..3a0ee333 100644 --- a/concepts/combinators/links.json +++ b/concepts/combinators/links.json @@ -2,5 +2,13 @@ { "url": "https://docs.factorcode.org/content/article-dataflow-combinators.html", "description": "Dataflow combinators — Factor handbook" + }, + { + "url": "https://docs.factorcode.org/content/article-cleave-combinators.html", + "description": "Cleave combinators — bi, tri, and their multi-input cousins" + }, + { + "url": "https://docs.factorcode.org/content/vocab-combinators.html", + "description": "combinators vocabulary reference" } ] diff --git a/concepts/conditionals/links.json b/concepts/conditionals/links.json index 6a934436..ca957954 100644 --- a/concepts/conditionals/links.json +++ b/concepts/conditionals/links.json @@ -2,5 +2,9 @@ { "url": "https://docs.factorcode.org/content/article-conditionals.html", "description": "Conditionals — Factor handbook" + }, + { + "url": "https://docs.factorcode.org/content/vocab-combinators.html", + "description": "combinators vocabulary — home of cond and case" } ] diff --git a/concepts/curry-compose-fry/links.json b/concepts/curry-compose-fry/links.json index 6c4c6e16..02934c7e 100644 --- a/concepts/curry-compose-fry/links.json +++ b/concepts/curry-compose-fry/links.json @@ -2,5 +2,9 @@ { "url": "https://docs.factorcode.org/content/vocab-fry.html", "description": "fry vocabulary reference" + }, + { + "url": "https://docs.factorcode.org/content/article-dataflow-combinators.html", + "description": "Dataflow combinators — context for curry and compose" } ] diff --git a/concepts/destructors/links.json b/concepts/destructors/links.json index 4e96b63b..b758a0a1 100644 --- a/concepts/destructors/links.json +++ b/concepts/destructors/links.json @@ -2,5 +2,13 @@ { "url": "https://docs.factorcode.org/content/article-destructors.html", "description": "Destructors — Factor handbook" + }, + { + "url": "https://docs.factorcode.org/content/vocab-destructors.html", + "description": "destructors vocabulary reference" + }, + { + "url": "https://docs.factorcode.org/content/word-cleanup%2Ccontinuations.html", + "description": "cleanup — the underlying continuations primitive" } ] diff --git a/concepts/dynamic-variables/links.json b/concepts/dynamic-variables/links.json index f2e71a7f..161d636f 100644 --- a/concepts/dynamic-variables/links.json +++ b/concepts/dynamic-variables/links.json @@ -2,5 +2,9 @@ { "url": "https://docs.factorcode.org/content/vocab-namespaces.html", "description": "namespaces vocabulary reference" + }, + { + "url": "https://docs.factorcode.org/content/article-namespaces-global.html", + "description": "Global namespaces — how dynamic variables are scoped" } ] diff --git a/concepts/errors/links.json b/concepts/errors/links.json index 09966a54..e4472ba7 100644 --- a/concepts/errors/links.json +++ b/concepts/errors/links.json @@ -2,5 +2,9 @@ { "url": "https://docs.factorcode.org/content/article-errors.html", "description": "Errors — Factor handbook" + }, + { + "url": "https://docs.factorcode.org/content/vocab-continuations.html", + "description": "continuations vocabulary — home of throw, catch, and cleanup" } ] diff --git a/concepts/indexed-iteration/links.json b/concepts/indexed-iteration/links.json index 17f82f31..fb2f7e82 100644 --- a/concepts/indexed-iteration/links.json +++ b/concepts/indexed-iteration/links.json @@ -2,5 +2,9 @@ { "url": "https://docs.factorcode.org/content/vocab-sequences.html", "description": "sequences vocabulary reference" + }, + { + "url": "https://docs.factorcode.org/content/article-sequences.html", + "description": "Sequences — Factor handbook (covers each-index, map-index, ...)" } ] diff --git a/concepts/locals/links.json b/concepts/locals/links.json index 598207ab..45cfe4f2 100644 --- a/concepts/locals/links.json +++ b/concepts/locals/links.json @@ -2,5 +2,9 @@ { "url": "https://docs.factorcode.org/content/vocab-locals.html", "description": "locals vocabulary reference" + }, + { + "url": "https://docs.factorcode.org/content/article-locals.html", + "description": "Lexical variables — Factor handbook" } ] diff --git a/concepts/quotations-call/links.json b/concepts/quotations-call/links.json index 3baa81ae..4c34e432 100644 --- a/concepts/quotations-call/links.json +++ b/concepts/quotations-call/links.json @@ -2,5 +2,13 @@ { "url": "https://docs.factorcode.org/content/word-call,kernel.html", "description": "call — kernel vocabulary" + }, + { + "url": "https://docs.factorcode.org/content/vocab-kernel.html", + "description": "kernel vocabulary reference" + }, + { + "url": "https://docs.factorcode.org/content/article-dataflow-combinators.html", + "description": "Dataflow combinators — call sites for quotations" } ] diff --git a/concepts/quotations/links.json b/concepts/quotations/links.json index 359cf8ce..3501607a 100644 --- a/concepts/quotations/links.json +++ b/concepts/quotations/links.json @@ -2,5 +2,9 @@ { "url": "https://docs.factorcode.org/content/article-quotations.html", "description": "Quotations — Factor handbook" + }, + { + "url": "https://docs.factorcode.org/content/vocab-quotations.html", + "description": "quotations vocabulary reference" } ] diff --git a/concepts/recursion/links.json b/concepts/recursion/links.json index 25ae6577..42175be5 100644 --- a/concepts/recursion/links.json +++ b/concepts/recursion/links.json @@ -2,5 +2,9 @@ { "url": "https://docs.factorcode.org/content/article-words.html", "description": "Defining words — Factor handbook" + }, + { + "url": "https://docs.factorcode.org/content/article-cookbook.html", + "description": "Factor cookbook — control-flow idioms in depth" } ] diff --git a/concepts/sequences/links.json b/concepts/sequences/links.json index a0153de6..41030f06 100644 --- a/concepts/sequences/links.json +++ b/concepts/sequences/links.json @@ -2,5 +2,13 @@ { "url": "https://docs.factorcode.org/content/article-sequences.html", "description": "Sequences — Factor handbook" + }, + { + "url": "https://docs.factorcode.org/content/vocab-sequences.html", + "description": "sequences vocabulary reference" + }, + { + "url": "https://docs.factorcode.org/content/vocab-arrays.html", + "description": "arrays vocabulary — the default sequence type" } ] diff --git a/concepts/subclasses/about.md b/concepts/subclasses/about.md index 89945db7..b4ecd187 100644 --- a/concepts/subclasses/about.md +++ b/concepts/subclasses/about.md @@ -71,5 +71,5 @@ USING: accessors ; an existing class by a runtime predicate. A separate Factor feature; not covered here. -[generics]: https://docs.factorcode.org/content/article-generic-words.html +[generics]: https://docs.factorcode.org/content/article-generic.html [accessors]: https://docs.factorcode.org/content/vocab-accessors.html diff --git a/concepts/subclasses/introduction.md b/concepts/subclasses/introduction.md index 32505f4a..06132882 100644 --- a/concepts/subclasses/introduction.md +++ b/concepts/subclasses/introduction.md @@ -24,4 +24,4 @@ Generic methods dispatched on the parent fire for every descendant — but that lesson lives with [`generics`][generics]; this exercise stays focused on the data side. -[generics]: https://docs.factorcode.org/content/article-generic-words.html +[generics]: https://docs.factorcode.org/content/article-generic.html diff --git a/concepts/subclasses/links.json b/concepts/subclasses/links.json index d3cd2e11..a780f038 100644 --- a/concepts/subclasses/links.json +++ b/concepts/subclasses/links.json @@ -2,5 +2,13 @@ { "url": "https://docs.factorcode.org/content/article-tuple-subclassing.html", "description": "Tuple subclassing — Factor handbook" + }, + { + "url": "https://docs.factorcode.org/content/article-generic.html", + "description": "Generic words — method dispatch over class hierarchies" + }, + { + "url": "https://docs.factorcode.org/content/vocab-accessors.html", + "description": "accessors vocabulary — auto-generated slot readers and writers" } ] diff --git a/concepts/tuples/links.json b/concepts/tuples/links.json index 093602e6..af7d906d 100644 --- a/concepts/tuples/links.json +++ b/concepts/tuples/links.json @@ -2,5 +2,9 @@ { "url": "https://docs.factorcode.org/content/article-tuples.html", "description": "Tuples — Factor handbook" + }, + { + "url": "https://docs.factorcode.org/content/vocab-accessors.html", + "description": "accessors vocabulary — auto-generated slot readers and writers" } ] diff --git a/concepts/unicode/links.json b/concepts/unicode/links.json index bdc8fc0b..1c0380a5 100644 --- a/concepts/unicode/links.json +++ b/concepts/unicode/links.json @@ -2,5 +2,9 @@ { "url": "https://docs.factorcode.org/content/vocab-unicode.html", "description": "unicode vocabulary reference" + }, + { + "url": "https://docs.factorcode.org/content/article-strings.html", + "description": "Strings — Factor handbook" } ] diff --git a/concepts/vocabularies/links.json b/concepts/vocabularies/links.json index 057ab7b3..7b7a4491 100644 --- a/concepts/vocabularies/links.json +++ b/concepts/vocabularies/links.json @@ -4,7 +4,7 @@ "description": "Vocabularies: official Factor documentation" }, { - "url": "https://docs.factorcode.org/content/article-vocab-search.html", - "description": "Vocabulary search path" + "url": "https://docs.factorcode.org/content/article-syntax.html", + "description": "Syntax — including USING:, USE:, IN:" } ] diff --git a/concepts/wire-format/links.json b/concepts/wire-format/links.json index bc88f56d..576af81c 100644 --- a/concepts/wire-format/links.json +++ b/concepts/wire-format/links.json @@ -8,7 +8,7 @@ "description": "Cleave combinators — including 2bi, 3bi, 2tri, 3tri" }, { - "url": "https://docs.factorcode.org/content/vocab-slices.html", - "description": "slices vocabulary — head-slice, tail-slice, and friends" + "url": "https://docs.factorcode.org/content/word-slice%2Csequences.html", + "description": "slice — sequences vocabulary (head-slice, tail-slice and friends)" } ] diff --git a/exercises/concept/dragons-descendants/.docs/introduction.md b/exercises/concept/dragons-descendants/.docs/introduction.md index 7ef79187..50064b2a 100644 --- a/exercises/concept/dragons-descendants/.docs/introduction.md +++ b/exercises/concept/dragons-descendants/.docs/introduction.md @@ -55,4 +55,4 @@ every descendant unless a more-specific override takes priority. You'll see that in `boatswains-bilge` immediately after this exercise. -[generics]: https://docs.factorcode.org/content/article-generic-words.html +[generics]: https://docs.factorcode.org/content/article-generic.html diff --git a/exercises/concept/log-levels/.docs/hints.md b/exercises/concept/log-levels/.docs/hints.md index 94c6e88d..769636b9 100644 --- a/exercises/concept/log-levels/.docs/hints.md +++ b/exercises/concept/log-levels/.docs/hints.md @@ -11,7 +11,8 @@ - Cut the line on `": "` with `split1` (stack effect `( seq subseq -- before after )`); discard the part before, keep - the part after. + the part after. `nip ( x y -- y )` from `kernel` drops the second + value down — so `split1 nip` keeps the right half. - Strip whitespace from what's left with `[ blank? ] trim`. ## 2. Get log level from a log line diff --git a/exercises/concept/mosaic-mischief/.docs/hints.md b/exercises/concept/mosaic-mischief/.docs/hints.md index 1c5f558e..6079d042 100644 --- a/exercises/concept/mosaic-mischief/.docs/hints.md +++ b/exercises/concept/mosaic-mischief/.docs/hints.md @@ -14,11 +14,15 @@ ## 2. Place a tile -- `set-nth` does the assignment. +- `set-nth` does the assignment, but it expects + `( elt n seq -- )` and the inputs arrive as `( row position colour -- )`. + `spin ( x y z -- z y x )` from `kernel` reorders three values on + the stack in a single word so they land in `set-nth`'s order. ## 3. Chip a tile out -- "Set this position to `f`" — same shape as task 2. +- "Set this position to `f`" — same shape as task 2, but you'll + need to push `f` onto the stack first. ## 4. Re-colour a tile diff --git a/exercises/concept/quayside-crew/.docs/introduction.md b/exercises/concept/quayside-crew/.docs/introduction.md index 02f7e600..bd47b974 100644 --- a/exercises/concept/quayside-crew/.docs/introduction.md +++ b/exercises/concept/quayside-crew/.docs/introduction.md @@ -61,6 +61,22 @@ USING: concurrency.promises kernel threads ; hand-rolling them is useful when each task does something other than "compute one element." +The typical fan-out/join shape over a sequence is: for each input +make a fresh promise, spawn a thread that does the work and +`fulfill`s the promise, collect every promise into a sequence, then +`?promise` each one to wait for completion. Locals make this +readable — bind the promise to a name with `:>` inside a `[| | ]` +lambda so the spawned quotation can close over it: + +```factor +! DOCTEST: SKIP (`:>` only works inside [let, [|, or :: forms) +inputs [| x | + :> p + [ x do-work t p fulfill ] "worker" spawn drop + p +] map [ ?promise drop ] each +``` + ## Locks — mutual exclusion ``` diff --git a/exercises/concept/rpn-calculator/.docs/hints.md b/exercises/concept/rpn-calculator/.docs/hints.md index 01bcad49..776d6f25 100644 --- a/exercises/concept/rpn-calculator/.docs/hints.md +++ b/exercises/concept/rpn-calculator/.docs/hints.md @@ -28,5 +28,22 @@ sequence. Every iteration sees the running stack, pops the next operation off the program, and applies it. +## 5. Evaluate by name + +- Look each name up in the assoc with `at` (in [`assocs`][assocs]) + to get its operation, then reuse `evaluate`. +- A fry quotation `'[ _ at ]` from [`curry-compose-fry`][fry] + closes over the assoc so `map` can swap each name for its + operation in one pass. + +## 6. Divide with safety + +- `throw` (in [`kernel`][kernel]) raises an error. `zero-divisor-error` + is already declared, so `zero-divisor-error throw` is the call. +- Guard the divide path with an `if` that checks whether the + bottom-most divisor is `0`. + [sequences]: https://docs.factorcode.org/content/vocab-sequences.html [kernel]: https://docs.factorcode.org/content/vocab-kernel.html +[assocs]: https://docs.factorcode.org/content/vocab-assocs.html +[fry]: https://docs.factorcode.org/content/vocab-fry.html