Skip to content

Latest commit

 

History

28 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

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

Stars

3 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages