ChunkSequence 🔪🍰

Have cake and eat it Have a cake and consume the cake by the Swift [https://developer.apple.com/swift/] function, at the same time. Magic. The nature of the Swift type is that it is copied or copied on write [https://en.wikipedia.org/wiki/Copy-on-write]. When I assign…

Generic Array of Int - what, why, how?

One of the great feature introduced by Swift 2.0 is possibility to define generic functions for type of Array. Array is container for values of some type. The type is known upfront. It's called Element now. what? Array is a struct with element and is defined like…

Fast pattern search in Swift... since 1974

> the fastest known ways to find one string of characters in another [1] Stay with me. At the beginning brief introduction, later on Swift implementation, tests and conclusion. Halt and Catch Fire thing I really enjoy Halt and Catch Fire [http://www.amc.com/shows/halt-and-catch-fire] tv show. Season…

Collection Index and magic factor

> An index is an indirect shortcut derived from and pointing into, a greater volume of values, data, information or knowledge. (wikipedia) In general (however it is not the rule) in modern programming languages Index values start at 0 position and ends at "length - 1" position. A…

Practical Swift: pages generator - build once, use many

In the real world, at some point, we all have to deal with data that is fetched from a backend service, page by page. It's called paging. Everybody does this! Nothing to be ashamed of ;-) Here is one of the ways in which a Swift pattern (well,…