In keynote, line spacing is specified per-paragraph. Paragraphs are line-wrapped into physical lines.
For now, we're only interested in text boxes where spacing is specified in “lines.”
For a physical line β and a character γ:
| struct CrossProduct2<Base0: Collection, Base1: Collection>: Collection { | |
| public private(set) var base0: Base0 | |
| public private(set) var base1: Base1 | |
| init(_ base0: Base0, _ base1: Base1) { | |
| self.base0 = base0 | |
| self.base1 = base1 | |
| } | |
| struct Index: Comparable { |
| extension Grammar { | |
| /// Returns the set of nullable symbols (which sometimes derive 𝝐) and the subset of nulling | |
| /// symbols (which always derive 𝝐) in a grammar that is not yet in nihilist normal form. | |
| func nullSymbolSets(rulesByRHS: MultiMap<Symbol, Rule>) | |
| -> (nullable: Set<Symbol>, nulling: Set<Symbol>) | |
| { | |
| // - Common setup. | |
| // Mapping from symbol to the set of ruleIDs having that symbol as a LHS. | |
| let rulesByLHS = MultiMap(grouping: ruleIDs, by: lhs) |
| private typealias Word = UInt | |
| /* | |
| /// Returns the offset at which the `i`th bit can be found in an array of | |
| /// `Word`s. | |
| private func wordOffset(ofBit i: Int) -> Int { | |
| precondition(i >= 0) | |
| return i / Word.bitWidth | |
| } | |
| /// Returns a mask that isolates the `i`th bit within its `Word` in an array of |
| /// A simple bottom-up chart parser. | |
| /// | |
| /// - The chart is a lookup table of sets of partial parses (a.k.a. dotted | |
| /// rules), indexed by (predicted-symbol, source-location) pairs. | |
| /// | |
| /// - A partial parse is a triple (B, R, N) where: | |
| /// - B is the position in the token stream where the partially-parsed input begins. | |
| /// - R is the partially-recognized BNF rule. | |
| /// - N is the number of RHS symbols of R that have been recognized. | |
| /// |
| /// Example of a recursive sum type representing a tree. | |
| /// | |
| /// The compiler uses copy-on-write under the covers to give instances value | |
| /// semantics. | |
| indirect enum Tree<Body> { | |
| case o(_ body: Body, _ left: Tree?, _ right: Tree?) | |
| } | |
| extension Tree : Equatable where Body: Equatable {} |
| (* Exactly what appears in the paper *) | |
| datatype term = IND of int (* de Bruijn index *) | |
| | ABS of term | |
| | APP of term * term | |
| structure Eval0 | |
| = struct | |
| datatype denval = THUNK of unit -> expval | |
| and expval = FUNCT of denval -> expval |
lmt is a tool for extracting text from the code blocks in markdown files. This file demonstrates all the lmt features in a C++-centric way.
First, install the go language if you don't have it (homebrew: brew install go).
| /// Returns `(source, transform(source.pointee))` and destroys `source.pointee`. | |
| /// | |
| /// This is a low-level utility for creating mutable projections of values without | |
| /// causing needless copy-on-write. | |
| /// | |
| /// Typical usage: | |
| /// | |
| /// func f(x: inout X) { // inout means we have exclusive access to `x`. | |
| /// var (xAddress, xFrobnication) | |
| /// = unsafeMoveMap(destroying: &x) { x.frobnication() } |
| #if os(Linux) | |
| import Glibc | |
| #else | |
| import Darwin | |
| #endif | |
| extension Collection { | |
| /// Returns the index of the first element that matches the predicate. | |
| /// | |
| /// The collection must already be partitioned according to the predicate, as if |