- Proposal: SE-NNNN
- Authors: Daryle Walker, Author 2
- Review Manager: TBD
- Status: Awaiting review
During the review process, add the following fields as needed:
- Decision Notes: Rationale, Additional Commentary
import Foundation | |
/** | |
Run an incremental counter, but return only the values that survive the "lucky number" process. | |
The process is to list all the positive integers, then filter out entries in stages. For all the numbers in a stage, let *N* be the first unfiltered number that is neither 1 nor been already been used as a filter seed for a previous stage, and filter out every Nth number. The first pass uses 2 and therefore filters out every second number, i.e. the even numbers. The second pass uses 3 and therefore filters out every third number that survived the 2-stage. The third pass uses 7 and therefore filters out every seventh number that survived both the 2- and 3-stages. The fourth pass uses 9 and therefore filters out every ninth number that survived the 2-, 3-, and 7-stages. (Note that 2 is the only seed that eliminates itself in its filter. Some definitions of lucky numbers avoid this irregularity by starting with the odd positive integers.) | |
*/ | |
public struct LuckyNumberGenerator<C |
During the review process, add the following fields as needed:
// | |
// Int4.swift | |
// NegaSuperBinary | |
// | |
// Created by Daryle Walker on 6/22/18. | |
// Copyright © 2018 Daryle Walker. All rights reserved. | |
// | |
import Foundation |
extension Collection { | |
/// Computes the binary-tree children indices for the given starting index, | |
/// if the collection is long enough. | |
/// | |
/// Child elements of a flattened tree are consecutive, so if two indices | |
/// are returned, `distance(from: left!, to: right!) == 1`. | |
/// | |
/// - Parameter source: The index of the parent element. | |
/// - Returns: A tuple with the indices of the left and right binary-tree |
import Foundation | |
extension Collection { | |
/// Returns the index range for the earliest subsequence of this collection | |
/// that is equivalent to the given sequence, using the given predicate to | |
/// compare elements. | |
/// | |
/// The predicate must be an equivalence relation over the elements. |
extension Collection { | |
/// If the collection does not have the given sequence as a prefix when | |
/// using the given predicate to compare elements, returns the collection | |
/// as-is; otherwise, returns the part of the collection after that prefix. | |
/// | |
/// The predicate must be an equivalence relation over the elements. | |
/// | |
/// Whether a prefix was actually dropped can be tested by checking if the | |
/// returned sub-sequence's `startIndex` is greater than the collection's |
This manifesto outlines a plan to add compound types corresponding to fixed-size scoped-storage homogenous containers.
Array
. Possibly other members too.//===--- ChunkedCollection.swift ------------------------------*- swift -*-===// | |
// | |
// Created by Daryle Walker on 2020-Feb-29 | |
// | |
// Copyright © 2020 Daryle Walker | |
// | |
// A generic type that models a Collection that wraps another, vending fixed- | |
// sized sub-sequences (i.e. chunks) of the inner collection as the elements of | |
// the outer collection. There is an option whether or not to vend the last | |
// chunks if they occur late enough that they are shorter than expected. |
//===--- AdjacentPermutation.swift ----------------------------*- swift -*-===// | |
// | |
// Created by Daryle Walker on 2019-Nov-27 | |
// | |
// Copyright © 2019 Daryle Walker | |
// | |
// Methods to rearrange a collection to its next or previous permutation. | |
// Methods to return a sequence of all permutations of a collection, both lazy | |
// and eager. | |
// |