Skip to content

Oyvindkg/SwiftProductGenerator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SwiftProductGenerator

A generic cartesian product generator written in swift similar to Python's itertools.Product.

Mission

Reduce memory consumption and processing time for cartesian product of arbitrary collections.

Usage

The generator is initialized with an array containing the collections to be combined:

let arrays = [
  [0,1],
  [0,1],
  [0,1]
]

let generator = product(arrays)

An equivalent statement would be:

let generator = product(repeating: [0,1], count: 3)

The generator from the examples will generate this array lazily

[
  [0, 0, 0]
  [0, 0, 1]
  [0, 1, 0]
  [0, 1, 1]
  [1, 0, 0]
  [1, 0, 1]
  [1, 1, 0]
  [1, 1, 1]
]

About

A cartesian product generator written in swift

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages