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 / RotateSwapMove.swift
Last active Mar 2, 2019
Extensions to MutableCollection to swap multiple elements at a time, plus support methods to rotate, and example methods to move elements.
View RotateSwapMove.swift
// RotateSwapMove.swift by Daryle Walker
extension MutableCollection {
Rotates the elements such that the value at the given index is now at `startIndex`.
Passing `startIndex` as `i` has no effect.
The method applies a left-rotation, bringing the target element's value to `startIndex`.
View BasicSetSubtraction.swift
// BasicSetSubtraction.swift by Daryle Walker
/// An iterator that vends elements from a sorted wrapped iterator, subtracting the elements from in another wrapped sorted filter iterator.
public struct SetSubtractionIterator<Base: IteratorProtocol, Filter: IteratorProtocol> where Base.Element == Filter.Element, Base.Element: Comparable {
/// The iterator where the vended elements come from.
var base: Base
/// The iterator where matches to be filtered come from.
var filters: Filter
CTMacUser / StridingSequence.swift
Created Feb 1, 2019
A sequence that strides over most of its wrapped sequence's elements.
View StridingSequence.swift
// StridingSequence.swift
// CLITest
// Created by Daryle Walker on 1/31/19.
// Copyright © 2019 Daryle Walker. All rights reserved.
// WARNING: I think this requires Swift 5, since it needs Sequence to no longer have an SubSequence member.
CTMacUser / MultipleSearch.swift
Last active Jan 23, 2019
Searching for a subsequence within a sequence. Also, rotating elements and a ring-buffer collection.
View MultipleSearch.swift
MultipleSearch.swift -- Sequence and collection multi-element search, all locations
Copyright (c) 2019 Daryle Walker
// MARK: Searching for every occurance of a string of elements within a sequence
extension Sequence {
CTMacUser / LazyEmptyAdmittingSplitCollection.swift
Created Dec 22, 2018
Attempts to make a lazy version of the Collection.split function.
View LazyEmptyAdmittingSplitCollection.swift
A lazy wrapper for `Collection.split`, but only when empty subsequences can also be vended.
Based off the `LazySplitCollection` sample type in the [article "Conditional Conformance in the Standard Library" at the Swift Blog]( by [Ben Cohen](, but extended only to support maximum subsequence counts.
public struct LazyEmptyAdmittingSplitCollection<Base: Collection> {
/// The wrapped collection, whose subsequences will be vended as elements of `self`.
let base: Base
/// The maximum number of splits allowed; the count of subsequences vended is at most one greater than this.
CTMacUser /
Created Aug 15, 2018
A proposal to generalize the Sequence comparison methods, with specializations for Collections.

Locating Sequence-Commonality Breaks


CTMacUser / Int4.swift
Created Jun 23, 2018
Four-bit signed and unsigned integer types in Swift.
View Int4.swift
// Int4.swift
// NegaSuperBinary
// Created by Daryle Walker on 6/22/18.
// Copyright © 2018 Daryle Walker. All rights reserved.
import Foundation
CTMacUser / SegmentedArray.swift
Created Apr 18, 2018
An array with distributed storage, in Swift.
View SegmentedArray.swift
// SegmentedArray.swift
// NodeCollections
// Created by Daryle Walker on 4/15/18.
// Copyright © 2018 Daryle Walker. All rights reserved.
// MARK: Globals
CTMacUser / LeftOpenRange.swift
Last active Apr 16, 2018
Linked-List Protocol and Singly-Linked List Type in Swift
View LeftOpenRange.swift
// LeftOpenRange.swift
// NodeCollections
// Created by Daryle Walker on 4/6/18.
// Copyright © 2018 Daryle Walker. All rights reserved.
// MARK: Primary Definitions
CTMacUser / SinglyLinkedList.swift
Created Mar 19, 2018
A quick & dirty singly-linked list in Swift 4.
View SinglyLinkedList.swift
/// A singly-linked list.
public final class SinglyLinkedList<T>: RangeReplaceableCollection, MutableCollection {
/// A node for a singly-linked list.
final class Node {
/// The node's data. May be absent (like for sentinel nodes).
var value: T?
/// The link to the next node, or `nil` when none.
var next: Node!
You can’t perform that action at this time.