Skip to content

Instantly share code, notes, and snippets.

@camwest
camwest / permutations.js
Created February 14, 2018 22:23 — forked from wassname/permutations.js
Combinatorics permutatons and product in javascript using lodash.js (like python's itertools)
/**
* Lodash mixins for combinatorics
* Inspired by python itertools: https://docs.python.org/2.7/library/itertools.html
*
* Usage:
* permutations([0,1,2],2) // [[0,1],[0,2],[1,0],[1,2],[2,0],[2,1]]
* combinations([0,1,2],2) // [[0,1],[0,2],[1,2]]
* combinations_with_replacement([0,1,2],2)// [[0,0],[0,1],[0,2],[1,1],[1,2],[2,2]]
* product([0,1,2],[0,1,2]) // [[0,0],[0,1],[0,2],[1,0],[1,1],[1,2],[2,0],[2,1],[2,2]]
*
require 'csv'
def transform_merge(csv_file)
CSV.open(@csv_file).read.each do |line|
end
end
def multiple_merge(inputs)
errors = []