Skip to content

Instantly share code, notes, and snippets.

View CTMacUser's full-sized avatar

Daryle Walker CTMacUser

View GitHub Profile
@CTMacUser
CTMacUser / NNNN-entity-duplication.md
Last active August 8, 2017 16:23
Swift proposal for a "macro" for generating comma-separated lists.

Entity Duplication

Introduction

This is a proposal to add a macro-like facility to automatically create lists.

@CTMacUser
CTMacUser / Stern-Calkin-Wilf-sequences.swift
Created January 1, 2018 22:21
Stern's Diatomic and the Calkin–Wilf Sequences in Swift
// Copyright (c) 2018 Daryle Walker.
// Distributed under the MIT License.
// Based off <https://en.wikipedia.org/wiki/Calkin–Wilf_tree>.
// "fusc" from Edsger W. Dijkstra.
// To-Do: Add the iterative version of "fusc"
struct SternDiatomicSequenceIterator: IteratorProtocol {
var cache = [0: 0, 1: 1]
@CTMacUser
CTMacUser / BinaryInteger+Extensions.swift
Last active February 14, 2018 20:01
(See "UInt72.swift.") An unsigned integer type larger than the one from the Standard Library.
/*
BinaryInteger+Extensions.swift
Created by Daryle Walker on 1/29/18.
Copyright (c) 2018 Daryle Walker.
Distributed under the MIT License.
Various properties and methods for BitArray's bit-twiddling.
@CTMacUser
CTMacUser / SinglyLinkedList.swift
Created March 19, 2018 01:16
A quick & dirty singly-linked list in Swift 4.
/// 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!
@CTMacUser
CTMacUser / LeftOpenRange.swift
Last active April 16, 2018 02:02
Linked-List Protocol and Singly-Linked List Type in Swift
//
// LeftOpenRange.swift
// NodeCollections
//
// Created by Daryle Walker on 4/6/18.
// Copyright © 2018 Daryle Walker. All rights reserved.
//
// MARK: Primary Definitions
@CTMacUser
CTMacUser / SegmentedArray.swift
Created April 18, 2018 08:39
An array with distributed storage, in Swift.
//
// SegmentedArray.swift
// NodeCollections
//
// Created by Daryle Walker on 4/15/18.
// Copyright © 2018 Daryle Walker. All rights reserved.
//
// MARK: Globals
@CTMacUser
CTMacUser / Int4.swift
Created June 23, 2018 22:34
Four-bit signed and unsigned integer types in Swift.
//
// Int4.swift
// NegaSuperBinary
//
// Created by Daryle Walker on 6/22/18.
// Copyright © 2018 Daryle Walker. All rights reserved.
//
import Foundation
@CTMacUser
CTMacUser / NNNN-diverges.md
Last active May 14, 2020 04:25
A proposal to generalize the Sequence comparison methods, with specializations for Collections.

Locating Sequence-Commonality Breaks

Introduction

@CTMacUser
CTMacUser / LazyEmptyAdmittingSplitCollection.swift
Created December 22, 2018 00:52
Attempts to make a lazy version of the Collection.split function.
/**
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](https://swift.org/blog/conditional-conformance/) by [Ben Cohen](https://twitter.com/airspeedswift/), 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
CTMacUser / MultipleSearch.swift
Last active January 23, 2019 23:50
Searching for a subsequence within a sequence. Also, rotating elements and a ring-buffer collection.
/*
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 {