Created
May 21, 2020 00:11
-
-
Save Yrds/5391af765e722b685973bb044d8824c5 to your computer and use it in GitHub Desktop.
This file contains 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 vect = ['h','e','l','l','o',' ','w','o','r','l','d']; | |
const newString = vect.reduce((acc, character) => acc.concat(character)); | |
console.log(newString); //hello world |
This file contains 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
#include <iostream> | |
#include <vector> | |
#include <algorithm> | |
#include <string> | |
#include <numeric> | |
int main(){ | |
std::vector<char> vect {'h','e','l','l','o',' ','w','o','r','l','d'}; | |
std::string result = std::accumulate(vect.begin(), vect.end(), std::string(), | |
[](std::string acc, char character){return acc + character;}); | |
std::cout << result; //hello world | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment