├── .gitignore ├── LICENSE ├── List.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ └── contents.xcworkspacedata └── xcshareddata │ └── xcschemes │ └── List.xcscheme ├── List ├── Info.plist ├── List.h └── List.swift ├── ListTests ├── Info.plist └── ListTests.swift └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | build 3 | xcuserdata 4 | *.mode* 5 | *.pbxuser 6 | *.xcuserdatad 7 | *.xccheckout 8 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Rob Rix 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /List.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | D40D2683195F198500BC535B /* List.h in Headers */ = {isa = PBXBuildFile; fileRef = D40D2682195F198500BC535B /* List.h */; settings = {ATTRIBUTES = (Public, ); }; }; 11 | D40D2689195F198500BC535B /* List.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D40D267D195F198500BC535B /* List.framework */; }; 12 | D40D2690195F198500BC535B /* ListTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D40D268F195F198500BC535B /* ListTests.swift */; }; 13 | D40D269A195F1A5200BC535B /* List.swift in Sources */ = {isa = PBXBuildFile; fileRef = D40D2699195F1A5200BC535B /* List.swift */; }; 14 | D4E5C9241B5EED14003EF435 /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D4E5C9231B5EED14003EF435 /* CoreFoundation.framework */; }; 15 | /* End PBXBuildFile section */ 16 | 17 | /* Begin PBXContainerItemProxy section */ 18 | D40D268A195F198500BC535B /* PBXContainerItemProxy */ = { 19 | isa = PBXContainerItemProxy; 20 | containerPortal = D40D2674195F198500BC535B /* Project object */; 21 | proxyType = 1; 22 | remoteGlobalIDString = D40D267C195F198500BC535B; 23 | remoteInfo = List; 24 | }; 25 | /* End PBXContainerItemProxy section */ 26 | 27 | /* Begin PBXFileReference section */ 28 | D40D267D195F198500BC535B /* List.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = List.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 29 | D40D2681195F198500BC535B /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 30 | D40D2682195F198500BC535B /* List.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = List.h; sourceTree = ""; }; 31 | D40D2688195F198500BC535B /* ListTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = ListTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 32 | D40D268E195F198500BC535B /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 33 | D40D268F195F198500BC535B /* ListTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListTests.swift; sourceTree = ""; }; 34 | D40D2699195F1A5200BC535B /* List.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = List.swift; sourceTree = ""; }; 35 | D4E5C9231B5EED14003EF435 /* CoreFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreFoundation.framework; path = System/Library/Frameworks/CoreFoundation.framework; sourceTree = SDKROOT; }; 36 | /* End PBXFileReference section */ 37 | 38 | /* Begin PBXFrameworksBuildPhase section */ 39 | D40D2679195F198500BC535B /* Frameworks */ = { 40 | isa = PBXFrameworksBuildPhase; 41 | buildActionMask = 2147483647; 42 | files = ( 43 | D4E5C9241B5EED14003EF435 /* CoreFoundation.framework in Frameworks */, 44 | ); 45 | runOnlyForDeploymentPostprocessing = 0; 46 | }; 47 | D40D2685195F198500BC535B /* Frameworks */ = { 48 | isa = PBXFrameworksBuildPhase; 49 | buildActionMask = 2147483647; 50 | files = ( 51 | D40D2689195F198500BC535B /* List.framework in Frameworks */, 52 | ); 53 | runOnlyForDeploymentPostprocessing = 0; 54 | }; 55 | /* End PBXFrameworksBuildPhase section */ 56 | 57 | /* Begin PBXGroup section */ 58 | D40D2673195F198500BC535B = { 59 | isa = PBXGroup; 60 | children = ( 61 | D40D267F195F198500BC535B /* List */, 62 | D40D268C195F198500BC535B /* ListTests */, 63 | D40D267E195F198500BC535B /* Products */, 64 | ); 65 | sourceTree = ""; 66 | }; 67 | D40D267E195F198500BC535B /* Products */ = { 68 | isa = PBXGroup; 69 | children = ( 70 | D40D267D195F198500BC535B /* List.framework */, 71 | D40D2688195F198500BC535B /* ListTests.xctest */, 72 | ); 73 | name = Products; 74 | sourceTree = ""; 75 | }; 76 | D40D267F195F198500BC535B /* List */ = { 77 | isa = PBXGroup; 78 | children = ( 79 | D40D2682195F198500BC535B /* List.h */, 80 | D40D2699195F1A5200BC535B /* List.swift */, 81 | D40D2680195F198500BC535B /* Supporting Files */, 82 | ); 83 | path = List; 84 | sourceTree = ""; 85 | }; 86 | D40D2680195F198500BC535B /* Supporting Files */ = { 87 | isa = PBXGroup; 88 | children = ( 89 | D4E5C9231B5EED14003EF435 /* CoreFoundation.framework */, 90 | D40D2681195F198500BC535B /* Info.plist */, 91 | ); 92 | name = "Supporting Files"; 93 | sourceTree = ""; 94 | }; 95 | D40D268C195F198500BC535B /* ListTests */ = { 96 | isa = PBXGroup; 97 | children = ( 98 | D40D268F195F198500BC535B /* ListTests.swift */, 99 | D40D268D195F198500BC535B /* Supporting Files */, 100 | ); 101 | path = ListTests; 102 | sourceTree = ""; 103 | }; 104 | D40D268D195F198500BC535B /* Supporting Files */ = { 105 | isa = PBXGroup; 106 | children = ( 107 | D40D268E195F198500BC535B /* Info.plist */, 108 | ); 109 | name = "Supporting Files"; 110 | sourceTree = ""; 111 | }; 112 | /* End PBXGroup section */ 113 | 114 | /* Begin PBXHeadersBuildPhase section */ 115 | D40D267A195F198500BC535B /* Headers */ = { 116 | isa = PBXHeadersBuildPhase; 117 | buildActionMask = 2147483647; 118 | files = ( 119 | D40D2683195F198500BC535B /* List.h in Headers */, 120 | ); 121 | runOnlyForDeploymentPostprocessing = 0; 122 | }; 123 | /* End PBXHeadersBuildPhase section */ 124 | 125 | /* Begin PBXNativeTarget section */ 126 | D40D267C195F198500BC535B /* List */ = { 127 | isa = PBXNativeTarget; 128 | buildConfigurationList = D40D2693195F198500BC535B /* Build configuration list for PBXNativeTarget "List" */; 129 | buildPhases = ( 130 | D40D2678195F198500BC535B /* Sources */, 131 | D40D2679195F198500BC535B /* Frameworks */, 132 | D40D267A195F198500BC535B /* Headers */, 133 | D40D267B195F198500BC535B /* Resources */, 134 | ); 135 | buildRules = ( 136 | ); 137 | dependencies = ( 138 | ); 139 | name = List; 140 | productName = List; 141 | productReference = D40D267D195F198500BC535B /* List.framework */; 142 | productType = "com.apple.product-type.framework"; 143 | }; 144 | D40D2687195F198500BC535B /* ListTests */ = { 145 | isa = PBXNativeTarget; 146 | buildConfigurationList = D40D2696195F198500BC535B /* Build configuration list for PBXNativeTarget "ListTests" */; 147 | buildPhases = ( 148 | D40D2684195F198500BC535B /* Sources */, 149 | D40D2685195F198500BC535B /* Frameworks */, 150 | D40D2686195F198500BC535B /* Resources */, 151 | ); 152 | buildRules = ( 153 | ); 154 | dependencies = ( 155 | D40D268B195F198500BC535B /* PBXTargetDependency */, 156 | ); 157 | name = ListTests; 158 | productName = ListTests; 159 | productReference = D40D2688195F198500BC535B /* ListTests.xctest */; 160 | productType = "com.apple.product-type.bundle.unit-test"; 161 | }; 162 | /* End PBXNativeTarget section */ 163 | 164 | /* Begin PBXProject section */ 165 | D40D2674195F198500BC535B /* Project object */ = { 166 | isa = PBXProject; 167 | attributes = { 168 | LastSwiftUpdateCheck = 0700; 169 | LastUpgradeCheck = 0700; 170 | ORGANIZATIONNAME = "Rob Rix"; 171 | TargetAttributes = { 172 | D40D267C195F198500BC535B = { 173 | CreatedOnToolsVersion = 6.0; 174 | }; 175 | D40D2687195F198500BC535B = { 176 | CreatedOnToolsVersion = 6.0; 177 | TestTargetID = D40D267C195F198500BC535B; 178 | }; 179 | }; 180 | }; 181 | buildConfigurationList = D40D2677195F198500BC535B /* Build configuration list for PBXProject "List" */; 182 | compatibilityVersion = "Xcode 3.2"; 183 | developmentRegion = English; 184 | hasScannedForEncodings = 0; 185 | knownRegions = ( 186 | en, 187 | ); 188 | mainGroup = D40D2673195F198500BC535B; 189 | productRefGroup = D40D267E195F198500BC535B /* Products */; 190 | projectDirPath = ""; 191 | projectRoot = ""; 192 | targets = ( 193 | D40D267C195F198500BC535B /* List */, 194 | D40D2687195F198500BC535B /* ListTests */, 195 | ); 196 | }; 197 | /* End PBXProject section */ 198 | 199 | /* Begin PBXResourcesBuildPhase section */ 200 | D40D267B195F198500BC535B /* Resources */ = { 201 | isa = PBXResourcesBuildPhase; 202 | buildActionMask = 2147483647; 203 | files = ( 204 | ); 205 | runOnlyForDeploymentPostprocessing = 0; 206 | }; 207 | D40D2686195F198500BC535B /* Resources */ = { 208 | isa = PBXResourcesBuildPhase; 209 | buildActionMask = 2147483647; 210 | files = ( 211 | ); 212 | runOnlyForDeploymentPostprocessing = 0; 213 | }; 214 | /* End PBXResourcesBuildPhase section */ 215 | 216 | /* Begin PBXSourcesBuildPhase section */ 217 | D40D2678195F198500BC535B /* Sources */ = { 218 | isa = PBXSourcesBuildPhase; 219 | buildActionMask = 2147483647; 220 | files = ( 221 | D40D269A195F1A5200BC535B /* List.swift in Sources */, 222 | ); 223 | runOnlyForDeploymentPostprocessing = 0; 224 | }; 225 | D40D2684195F198500BC535B /* Sources */ = { 226 | isa = PBXSourcesBuildPhase; 227 | buildActionMask = 2147483647; 228 | files = ( 229 | D40D2690195F198500BC535B /* ListTests.swift in Sources */, 230 | ); 231 | runOnlyForDeploymentPostprocessing = 0; 232 | }; 233 | /* End PBXSourcesBuildPhase section */ 234 | 235 | /* Begin PBXTargetDependency section */ 236 | D40D268B195F198500BC535B /* PBXTargetDependency */ = { 237 | isa = PBXTargetDependency; 238 | target = D40D267C195F198500BC535B /* List */; 239 | targetProxy = D40D268A195F198500BC535B /* PBXContainerItemProxy */; 240 | }; 241 | /* End PBXTargetDependency section */ 242 | 243 | /* Begin XCBuildConfiguration section */ 244 | D40D2691195F198500BC535B /* Debug */ = { 245 | isa = XCBuildConfiguration; 246 | buildSettings = { 247 | ALWAYS_SEARCH_USER_PATHS = NO; 248 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 249 | CLANG_CXX_LIBRARY = "libc++"; 250 | CLANG_ENABLE_MODULES = YES; 251 | CLANG_ENABLE_OBJC_ARC = YES; 252 | CLANG_WARN_BOOL_CONVERSION = YES; 253 | CLANG_WARN_CONSTANT_CONVERSION = YES; 254 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 255 | CLANG_WARN_EMPTY_BODY = YES; 256 | CLANG_WARN_ENUM_CONVERSION = YES; 257 | CLANG_WARN_INT_CONVERSION = YES; 258 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 259 | CLANG_WARN_UNREACHABLE_CODE = YES; 260 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 261 | COPY_PHASE_STRIP = NO; 262 | CURRENT_PROJECT_VERSION = 1; 263 | ENABLE_STRICT_OBJC_MSGSEND = YES; 264 | ENABLE_TESTABILITY = YES; 265 | GCC_C_LANGUAGE_STANDARD = gnu99; 266 | GCC_DYNAMIC_NO_PIC = NO; 267 | GCC_OPTIMIZATION_LEVEL = 0; 268 | GCC_PREPROCESSOR_DEFINITIONS = ( 269 | "DEBUG=1", 270 | "$(inherited)", 271 | ); 272 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 273 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 274 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 275 | GCC_WARN_UNDECLARED_SELECTOR = YES; 276 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 277 | GCC_WARN_UNUSED_FUNCTION = YES; 278 | GCC_WARN_UNUSED_VARIABLE = YES; 279 | MACOSX_DEPLOYMENT_TARGET = 10.9; 280 | METAL_ENABLE_DEBUG_INFO = YES; 281 | ONLY_ACTIVE_ARCH = YES; 282 | SDKROOT = macosx; 283 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 284 | VERSIONING_SYSTEM = "apple-generic"; 285 | VERSION_INFO_PREFIX = ""; 286 | }; 287 | name = Debug; 288 | }; 289 | D40D2692195F198500BC535B /* Release */ = { 290 | isa = XCBuildConfiguration; 291 | buildSettings = { 292 | ALWAYS_SEARCH_USER_PATHS = NO; 293 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 294 | CLANG_CXX_LIBRARY = "libc++"; 295 | CLANG_ENABLE_MODULES = YES; 296 | CLANG_ENABLE_OBJC_ARC = YES; 297 | CLANG_WARN_BOOL_CONVERSION = YES; 298 | CLANG_WARN_CONSTANT_CONVERSION = YES; 299 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 300 | CLANG_WARN_EMPTY_BODY = YES; 301 | CLANG_WARN_ENUM_CONVERSION = YES; 302 | CLANG_WARN_INT_CONVERSION = YES; 303 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 304 | CLANG_WARN_UNREACHABLE_CODE = YES; 305 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 306 | COPY_PHASE_STRIP = YES; 307 | CURRENT_PROJECT_VERSION = 1; 308 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 309 | ENABLE_NS_ASSERTIONS = NO; 310 | ENABLE_STRICT_OBJC_MSGSEND = YES; 311 | GCC_C_LANGUAGE_STANDARD = gnu99; 312 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 313 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 314 | GCC_WARN_UNDECLARED_SELECTOR = YES; 315 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 316 | GCC_WARN_UNUSED_FUNCTION = YES; 317 | GCC_WARN_UNUSED_VARIABLE = YES; 318 | MACOSX_DEPLOYMENT_TARGET = 10.9; 319 | METAL_ENABLE_DEBUG_INFO = NO; 320 | SDKROOT = macosx; 321 | VERSIONING_SYSTEM = "apple-generic"; 322 | VERSION_INFO_PREFIX = ""; 323 | }; 324 | name = Release; 325 | }; 326 | D40D2694195F198500BC535B /* Debug */ = { 327 | isa = XCBuildConfiguration; 328 | buildSettings = { 329 | CLANG_ENABLE_MODULES = YES; 330 | COMBINE_HIDPI_IMAGES = YES; 331 | DEFINES_MODULE = YES; 332 | DYLIB_COMPATIBILITY_VERSION = 1; 333 | DYLIB_CURRENT_VERSION = 1; 334 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 335 | FRAMEWORK_VERSION = A; 336 | INFOPLIST_FILE = List/Info.plist; 337 | INSTALL_PATH = "@rpath"; 338 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; 339 | PRODUCT_BUNDLE_IDENTIFIER = "com.antitypical.${PRODUCT_NAME:rfc1034identifier}"; 340 | PRODUCT_NAME = "$(TARGET_NAME)"; 341 | SKIP_INSTALL = YES; 342 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 343 | VALID_ARCHS = x86_64; 344 | }; 345 | name = Debug; 346 | }; 347 | D40D2695195F198500BC535B /* Release */ = { 348 | isa = XCBuildConfiguration; 349 | buildSettings = { 350 | CLANG_ENABLE_MODULES = YES; 351 | COMBINE_HIDPI_IMAGES = YES; 352 | DEFINES_MODULE = YES; 353 | DYLIB_COMPATIBILITY_VERSION = 1; 354 | DYLIB_CURRENT_VERSION = 1; 355 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 356 | FRAMEWORK_VERSION = A; 357 | INFOPLIST_FILE = List/Info.plist; 358 | INSTALL_PATH = "@rpath"; 359 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; 360 | PRODUCT_BUNDLE_IDENTIFIER = "com.antitypical.${PRODUCT_NAME:rfc1034identifier}"; 361 | PRODUCT_NAME = "$(TARGET_NAME)"; 362 | SKIP_INSTALL = YES; 363 | VALID_ARCHS = x86_64; 364 | }; 365 | name = Release; 366 | }; 367 | D40D2697195F198500BC535B /* Debug */ = { 368 | isa = XCBuildConfiguration; 369 | buildSettings = { 370 | COMBINE_HIDPI_IMAGES = YES; 371 | FRAMEWORK_SEARCH_PATHS = ( 372 | "$(DEVELOPER_FRAMEWORKS_DIR)", 373 | "$(inherited)", 374 | ); 375 | GCC_PREPROCESSOR_DEFINITIONS = ( 376 | "DEBUG=1", 377 | "$(inherited)", 378 | ); 379 | INFOPLIST_FILE = ListTests/Info.plist; 380 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; 381 | METAL_ENABLE_DEBUG_INFO = YES; 382 | PRODUCT_BUNDLE_IDENTIFIER = "com.antitypical.${PRODUCT_NAME:rfc1034identifier}"; 383 | PRODUCT_NAME = "$(TARGET_NAME)"; 384 | }; 385 | name = Debug; 386 | }; 387 | D40D2698195F198500BC535B /* Release */ = { 388 | isa = XCBuildConfiguration; 389 | buildSettings = { 390 | COMBINE_HIDPI_IMAGES = YES; 391 | FRAMEWORK_SEARCH_PATHS = ( 392 | "$(DEVELOPER_FRAMEWORKS_DIR)", 393 | "$(inherited)", 394 | ); 395 | INFOPLIST_FILE = ListTests/Info.plist; 396 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; 397 | METAL_ENABLE_DEBUG_INFO = NO; 398 | PRODUCT_BUNDLE_IDENTIFIER = "com.antitypical.${PRODUCT_NAME:rfc1034identifier}"; 399 | PRODUCT_NAME = "$(TARGET_NAME)"; 400 | }; 401 | name = Release; 402 | }; 403 | /* End XCBuildConfiguration section */ 404 | 405 | /* Begin XCConfigurationList section */ 406 | D40D2677195F198500BC535B /* Build configuration list for PBXProject "List" */ = { 407 | isa = XCConfigurationList; 408 | buildConfigurations = ( 409 | D40D2691195F198500BC535B /* Debug */, 410 | D40D2692195F198500BC535B /* Release */, 411 | ); 412 | defaultConfigurationIsVisible = 0; 413 | defaultConfigurationName = Release; 414 | }; 415 | D40D2693195F198500BC535B /* Build configuration list for PBXNativeTarget "List" */ = { 416 | isa = XCConfigurationList; 417 | buildConfigurations = ( 418 | D40D2694195F198500BC535B /* Debug */, 419 | D40D2695195F198500BC535B /* Release */, 420 | ); 421 | defaultConfigurationIsVisible = 0; 422 | defaultConfigurationName = Release; 423 | }; 424 | D40D2696195F198500BC535B /* Build configuration list for PBXNativeTarget "ListTests" */ = { 425 | isa = XCConfigurationList; 426 | buildConfigurations = ( 427 | D40D2697195F198500BC535B /* Debug */, 428 | D40D2698195F198500BC535B /* Release */, 429 | ); 430 | defaultConfigurationIsVisible = 0; 431 | defaultConfigurationName = Release; 432 | }; 433 | /* End XCConfigurationList section */ 434 | }; 435 | rootObject = D40D2674195F198500BC535B /* Project object */; 436 | } 437 | -------------------------------------------------------------------------------- /List.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /List.xcodeproj/xcshareddata/xcschemes/List.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 29 | 35 | 36 | 37 | 38 | 39 | 44 | 45 | 47 | 53 | 54 | 55 | 56 | 57 | 63 | 64 | 65 | 66 | 67 | 68 | 78 | 79 | 85 | 86 | 87 | 88 | 89 | 90 | 96 | 97 | 103 | 104 | 105 | 106 | 108 | 109 | 112 | 113 | 114 | -------------------------------------------------------------------------------- /List/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | ${PRODUCT_NAME} 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | ${CURRENT_PROJECT_VERSION} 23 | NSHumanReadableCopyright 24 | Copyright © 2014 Rob Rix. All rights reserved. 25 | NSPrincipalClass 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /List/List.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 Rob Rix. All rights reserved. 2 | 3 | //! Project version number for List. 4 | extern double ListVersionNumber; 5 | 6 | //! Project version string for List. 7 | extern const unsigned char ListVersionString[]; 8 | -------------------------------------------------------------------------------- /List/List.swift: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 Rob Rix. All rights reserved. 2 | 3 | /// A singly-linked lazy list. 4 | public enum List: NilLiteralConvertible, CustomStringConvertible, SequenceType { 5 | // MARK: Constructors 6 | 7 | /// Constructs an empty list. 8 | public init() { 9 | self = Nil 10 | } 11 | 12 | /// List of one element. 13 | public init(_ element: Element) { 14 | self = Cons(element, nil) 15 | } 16 | 17 | /// Prepending. 18 | public init(_ element: Element, _ rest: List) { 19 | self = Cons(element, rest) 20 | } 21 | 22 | /// N-ary list from a generator. 23 | public init(var generator: G) { 24 | self = generator.next().map { List($0, List(generator: generator)) } ?? nil 25 | } 26 | 27 | /// N-ary list from a sequence. 28 | public init(elements: S) { 29 | self = List(generator: elements.generate()) 30 | } 31 | 32 | 33 | // MARK: Properties 34 | 35 | /// Returns the head element, or `nil` if the receiver is empty. 36 | public var head: Element? { 37 | return analysis { head, _ in head } 38 | } 39 | 40 | /// Returns the tail, i.e. the (possibly empty) list of elements following the head element. 41 | public var tail: List { 42 | return analysis { _, tail in tail } ?? nil 43 | } 44 | 45 | /// `true` if the receiver is empty, `false` otherwise. 46 | public var isEmpty: Bool { 47 | return analysis { _, _ in false } ?? true 48 | } 49 | 50 | 51 | /// Case analysis. 52 | /// 53 | /// If the receiver is empty, returns `nil`. Otherwise returns the result of applying `f` to the receiver’s head & tail. 54 | public func analysis(f: (Element, List) -> T) -> T? { 55 | switch self { 56 | case let Cons(head, tail): 57 | return f(head, tail) 58 | 59 | case Nil: 60 | return nil 61 | } 62 | } 63 | 64 | 65 | // MARK: Higher-order functions 66 | 67 | public func map(transform: Element -> T) -> List { 68 | return analysis { List(transform($0), $1.map(transform)) } ?? nil 69 | } 70 | 71 | public func filter(includeElement: Element -> Bool) -> List { 72 | return analysis { 73 | let rest = $1.filter(includeElement) 74 | return includeElement($0) ? List($0, rest) : rest 75 | } ?? nil 76 | } 77 | 78 | public func reduce(initial: Result, _ combine: (Result, Element) -> Result) -> Result { 79 | return analysis { $1.reduce(combine(initial, $0), combine) } ?? initial 80 | } 81 | 82 | 83 | // MARK: NilLiteralConvertible 84 | 85 | public init(nilLiteral: ()) { 86 | self.init() 87 | } 88 | 89 | 90 | // MARK: Printable 91 | 92 | public var description: String { 93 | let joined = " ".join(lazy(self).map{ String($0) }) 94 | return "(\(joined))" 95 | } 96 | 97 | 98 | // MARK: SequenceType 99 | 100 | public func generate() -> AnyGenerator { 101 | var list = self 102 | return anyGenerator { 103 | list.analysis { 104 | list = $1 105 | return $0 106 | } ?? nil 107 | } 108 | } 109 | 110 | 111 | // MARK: Cases 112 | 113 | indirect case Cons(Element, List) 114 | case Nil 115 | } 116 | 117 | 118 | infix operator ++ { associativity right precedence 145 } 119 | 120 | /// Concatenation of lists. 121 | public func ++ (left: List, right: List) -> List { 122 | func swap(into: List -> List, each: Element) -> List -> List { 123 | return { into(List(each, $0)) } 124 | } 125 | return right.reduce(left.reduce({ $0 }, swap), swap)(nil) 126 | } 127 | -------------------------------------------------------------------------------- /ListTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | ${PRODUCT_NAME} 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /ListTests/ListTests.swift: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 Rob Rix. All rights reserved. 2 | 3 | final class ListTests: XCTestCase { 4 | func testDescription() { 5 | XCTAssert(List(elements: [1, 2, 3, 4]).description == "(1 2 3 4)") 6 | } 7 | 8 | func testConcatenation() { 9 | let a = List(elements: [1, 2, 3]) 10 | let b = List(elements: [4, 5, 6]) 11 | XCTAssert((a ++ b).description == "(1 2 3 4 5 6)") 12 | } 13 | 14 | func testNilConversion() { 15 | let x: List = nil 16 | XCTAssert(x.description == "()") 17 | } 18 | 19 | 20 | func testMap() { 21 | XCTAssertEqual(Array(List(0, List(1, List(2))).map(String.init)), ["0", "1", "2"]) 22 | } 23 | 24 | func testFilter() { 25 | XCTAssertEqual(Array(List(elements: [0, 1, 2, 3]).filter { $0 % 2 == 0 }), [0, 2]) 26 | } 27 | 28 | func testReduce() { 29 | XCTAssertEqual(List(elements: [1, 2, 3, 4, 5]).reduce(0, +), 15) 30 | } 31 | } 32 | 33 | 34 | @testable import List 35 | import XCTest 36 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # List 2 | 3 | This is a Swift microframework which implements an immutable singly-linked List. 4 | 5 | ## Use 6 | 7 | ```swift 8 | // Concatenation 9 | List(elements: [1, 2, 3]) ++ List(elements: [4, 5, 6]) 10 | // => List(elements: [1, 2, 3, 4, 5, 6]) 11 | ``` 12 | 13 | See [`List.swift`][List.swift] for more details. 14 | 15 | ## Integration 16 | 17 | 1. Add this repo as a submodule in e.g. `External/List`: 18 | 19 | git submodule add https://github.com/robrix/List.git External/List 20 | 2. Drag `List.xcodeproj` into your `.xcworkspace`/`.xcodeproj`. 21 | 3. Add `List.framework` to your target’s `Link Binary With Libraries` build phase. 22 | 4. You may also want to add a `Copy Files` phase which copies `List.framework` (and any other framework dependencies you need) into your bundle’s `Frameworks` directory. If your target is a framework, you may instead want the client app to include `List.framework`. 23 | 24 | [List.swift]: https://github.com/robrix/List/blob/master/List/List.swift 25 | --------------------------------------------------------------------------------