Last active
June 9, 2017 11:17
-
-
Save Woodsphreaker/9a552b82a4d71ac7f37466b4935ba97b to your computer and use it in GitHub Desktop.
Merging Strings with Matrix
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const plus = (a = '') => (b = '') => a + b | |
const applyOperation = (fn) => (acc, cur) => acc.map((value, index) => fn(cur[index])(value)) | |
const matrix = (list) => (fn) => list.reduceRight(applyOperation(fn)) | |
const solve = (list) => (fn) => matrix(list)(fn).join('') | |
const str1 = "Testando".split('') | |
const str2 = "String".split('') | |
const str3 = "de".split('') | |
const str4 = "Varios".split('') | |
const str5 = "Tamanhos".split('') | |
const array = [ | |
str1, | |
str2, | |
str3, | |
str4, | |
str5 | |
] | |
console.log(solve(array)(plus)) //TSdVTeteaasrrmtiiaanonngshdoos |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment