Skip to content

Instantly share code, notes, and snippets.

Daryle Walker CTMacUser

  • Connecticut, USA
Block or report user

Report or block CTMacUser

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@CTMacUser
CTMacUser / FirstRange.swift
Created May 25, 2020
A generalized and Swift-y adaptation of NSString.replacingOccurrences(of: with: options: range:). See <https://forums.swift.org/t/additional-string-processing-apis/36255/25?u=ctmacuser> for more.
View FirstRange.swift
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.
View DropAffix.swift
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
@CTMacUser
CTMacUser / ArrayManifestoV3.md
Created Mar 10, 2020
Version 3 of a proposal to add fixed-size, scoped-storage arrays to Swift. See <https://forums.swift.org/t/fixed-size-scoped-storage-array-manifesto-version-3/34427> for discussion.
View ArrayManifestoV3.md

Fixed-Size Array Manifesto

Introduction

This manifesto outlines a plan to add compound types corresponding to fixed-size scoped-storage homogenous containers.

Motivation/Goals

  • Bring a fixed-size, scoped-storage array type to Swift
  • Use declaration and dereference syntax similar to Array. Possibly other members too.
@CTMacUser
CTMacUser / ChunkedCollection.swift
Created Feb 29, 2020
For Swift 5.1; wrapping types for sequences and collections that vend their source into fixed-sized chunks. See <https://forums.swift.org/t/yet-another-chunked-sequence-collection-idea/34198> for more information.
View ChunkedCollection.swift
//===--- 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.
@CTMacUser
CTMacUser / AdjacentPermutation.swift
Last active Dec 9, 2019
Confirming permutations, rotating to the next or previous permutation, or going through all permutations; inspired by the C++ Standard Library. See <https://forums.swift.org/t/how-about-detection-and-iteration-of-permutations/31404> for more information.
View AdjacentPermutation.swift
//===--- 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.
//
@CTMacUser
CTMacUser / MergedSortedSequence.swift
Last active Nov 26, 2019
Merging, Combining, and Testing of Sorted Sequences in Swift, inspired by the C++ Standard Library. See <https://forums.swift.org/t/sorted-sequence-operations-merge-sort-set-operations-inclusion-testing/31145> for more information.
View MergedSortedSequence.swift
// MARK: Per-Element Sharing in Merged Sorted Sequences
/// Primary source categories when merging two sets together.
public enum MergedSetElementSource<Element> {
/// The given element is only in the first set.
case exclusivelyFirst(Element)
/// The element is in both sets. Both versions are given.
case shared(Element, Element)
/// The given element is only in the second set.
@CTMacUser
CTMacUser / Heap.swift
Last active Nov 26, 2019
Heap operation methods and Priority Queues in Swift, inspired by the C++ Standard Library. See <https://forums.swift.org/t/heaps-structure-not-storage-and-priority-queues/31135> for more information.
View Heap.swift
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
@CTMacUser
CTMacUser / IntegerNull.swift
Last active Aug 30, 2019
Another zero-width signed and unsigned integer type pair for Swift
View IntegerNull.swift
//
// IntegerNull.swift
// ZeroInteger
//
// Created by Daryle Walker on 8/27/19.
// Copyright © 2019 Daryle Walker. All rights reserved.
//
// MARK: Zero-bit Integer Primary Definitions
@CTMacUser
CTMacUser / BinarySearch.swift
Last active Sep 23, 2019
A set type, in Swift 5(.1), that stores its elements in strictly increasing order, requiring Comparable instead of Hashable. Also includes: binary search, sort detection, streaming set operations, and (space-wise) debouncing.
View BinarySearch.swift
//
// BinarySearch.swift
// SortedSet
//
// Created by Daryle Walker on 8/22/19.
// Copyright © 2019 Daryle Walker. All rights reserved.
//
extension Collection {
@CTMacUser
CTMacUser / ArrayManifesto.md
Last active Jul 2, 2019
A manifesto to outline how to add fixed-size scoped-storage arrays to Swift.
View ArrayManifesto.md

Fixed-Size, Scoped-Storage Array Manifesto

Introduction

This manifesto is for collecting the ideas needed to introduce the classic fixed-size array family of types to Swift.

You can’t perform that action at this time.